jscript: Throw type error fot Array.toString with wrong 'this' call.
authorJacek Caban <jacek@codeweavers.com>
Wed, 23 Sep 2009 22:45:00 +0000 (00:45 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Thu, 24 Sep 2009 11:30:35 +0000 (13:30 +0200)
dlls/jscript/array.c
dlls/jscript/jscript_En.rc
dlls/jscript/resource.h
dlls/jscript/tests/api.js

index 1fa20fe8cb9b3ad7386a119cc3098c2efae3de61..941e414567b33f9eb8ca4d2b177cd33244310cdf 100644 (file)
@@ -936,10 +936,8 @@ static HRESULT Array_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
     TRACE("\n");
 
     array = array_this(jsthis);
-    if(!array) {
-        FIXME("not Array object\n");
-        return E_FAIL;
-    }
+    if(!array)
+        return throw_type_error(ctx, ei, IDS_ARRAY_EXPECTED, NULL);
 
     return array_join(ctx, &array->dispex, array->length, default_separatorW, retv, ei, sp);
 }
index 79921b46e8fa043dd113c1b4d3544679fdb77af1..7962ad36c8c041f86d862fe38294804ef8a9d3c4 100644 (file)
@@ -41,4 +41,5 @@ STRINGTABLE DISCARDABLE
     IDS_JSCRIPT_EXPECTED    "JScript object expected"
     IDS_REGEXP_SYNTAX_ERROR "Syntax error in regular expression"
     IDS_INVALID_LENGTH      "Array length must be a finite positive integer"
+    IDS_ARRAY_EXPECTED      "Array object expected"
 }
index 81cd74dfa1bd3212cd45d3295624e40bc13ce215..fcebcb903c26de3a9ea8607e5a7a0d2d938c4a58 100644 (file)
@@ -37,3 +37,4 @@
 #define IDS_JSCRIPT_EXPECTED                0x1396
 #define IDS_REGEXP_SYNTAX_ERROR             0x1399
 #define IDS_INVALID_LENGTH                  0x13A5
+#define IDS_ARRAY_EXPECTED                  0x13A7
index 1c2f56b9a2f3fb10898929a1aadcd76fe9676406..aed26ece24c93986a70a446a082a3704d2f9b95e 100644 (file)
@@ -1621,6 +1621,69 @@ exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
 exception_test(function() {eval("nonexistingfunc()")}, "TypeError", -2146823281);
 exception_test(function() {RegExp(/a/, "g");}, "RegExpError", -2146823271);
 
+function testThisExcept(func, number) {
+    exception_test(function() {func.call(new Object())}, "TypeError", number);
+}
+
+function testBoolThis(func) {
+    testThisExcept(Boolean.prototype[func], -2146823278);
+}
+
+testBoolThis("toString");
+testBoolThis("valueOf");
+
+function testDateThis(func) {
+    testThisExcept(Date.prototype[func], -2146823282);
+}
+
+testDateThis("getDate");
+testDateThis("getDay");
+testDateThis("getFullYear");
+testDateThis("getHours");
+testDateThis("getMilliseconds");
+testDateThis("getMinutes");
+testDateThis("getMonth");
+testDateThis("getSeconds");
+testDateThis("getTime");
+testDateThis("getTimezoneOffset");
+testDateThis("getUTCDate");
+testDateThis("getUTCDay");
+testDateThis("getUTCFullYear");
+testDateThis("getUTCHours");
+testDateThis("getUTCMilliseconds");
+testDateThis("getUTCMinutes");
+testDateThis("getUTCMonth");
+testDateThis("getUTCSeconds");
+testDateThis("setDate");
+testDateThis("setFullYear");
+testDateThis("setHours");
+testDateThis("setMilliseconds");
+testDateThis("setMinutes");
+testDateThis("setMonth");
+testDateThis("setSeconds");
+testDateThis("setTime");
+testDateThis("setUTCDate");
+testDateThis("setUTCFullYear");
+testDateThis("setUTCHours");
+testDateThis("setUTCMilliseconds");
+testDateThis("setUTCMinutes");
+testDateThis("setUTCMonth");
+testDateThis("setUTCSeconds");
+testDateThis("toDateString");
+testDateThis("toLocaleDateString");
+testDateThis("toLocaleString");
+testDateThis("toLocaleTimeString");
+testDateThis("toString");
+testDateThis("toTimeString");
+testDateThis("toUTCString");
+testDateThis("valueOf");
+
+function testArrayThis(func) {
+    testThisExcept(Array.prototype[func], -2146823257);
+}
+
+testArrayThis("toString");
+
 function testArrayHostThis(func) {
     exception_test(function() { Array.prototype[func].call(testObj); }, "TypeError", -2146823274);
 }