jscript: Throw correct error in get_length.
authorJacek Caban <jacek@codeweavers.com>
Wed, 23 Sep 2009 14:24:11 +0000 (16:24 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 23 Sep 2009 15:08:31 +0000 (17:08 +0200)
dlls/jscript/array.c
dlls/jscript/jscript_En.rc
dlls/jscript/resource.h
dlls/jscript/tests/api.js

index b3dc780273c3cbed2e41c0204ec85b17cb851540..1fa20fe8cb9b3ad7386a119cc3098c2efae3de61 100644 (file)
@@ -69,10 +69,8 @@ static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsexcept_t *ei, Dis
         return S_OK;
     }
 
-    if(!is_jsdisp(vdisp)) {
-        FIXME("Not JScript object\n");
-        return E_FAIL;
-    }
+    if(!is_jsdisp(vdisp))
+        return throw_type_error(ctx, ei, IDS_JSCRIPT_EXPECTED, NULL);
 
     hres = jsdisp_propget_name(vdisp->u.jsdisp, lengthW, &var, ei, NULL/*FIXME*/);
     if(FAILED(hres))
index b7f8744d4f8b215865c837c3dddde7414452164d..79921b46e8fa043dd113c1b4d3544679fdb77af1 100644 (file)
@@ -38,6 +38,7 @@ STRINGTABLE DISCARDABLE
     IDS_ILLEGAL_ASSIGN      "Illegal assignment"
     IDS_UNDEFINED           "'|' is undefined"
     IDS_NOT_BOOL            "Boolean object expected"
+    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"
 }
index 9e33ebc9bc0eeeff6f2b2eae510f0ecdb9919de3..81cd74dfa1bd3212cd45d3295624e40bc13ce215 100644 (file)
@@ -34,5 +34,6 @@
 #define IDS_ILLEGAL_ASSIGN                  0x1390
 #define IDS_UNDEFINED                       0x1391
 #define IDS_NOT_BOOL                        0x1392
+#define IDS_JSCRIPT_EXPECTED                0x1396
 #define IDS_REGEXP_SYNTAX_ERROR             0x1399
 #define IDS_INVALID_LENGTH                  0x13A5
index ee3a058439c690949d74fe759ff788bdfc61b116..1c2f56b9a2f3fb10898929a1aadcd76fe9676406 100644 (file)
@@ -1621,6 +1621,16 @@ exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
 exception_test(function() {eval("nonexistingfunc()")}, "TypeError", -2146823281);
 exception_test(function() {RegExp(/a/, "g");}, "RegExpError", -2146823271);
 
+function testArrayHostThis(func) {
+    exception_test(function() { Array.prototype[func].call(testObj); }, "TypeError", -2146823274);
+}
+
+testArrayHostThis("push");
+testArrayHostThis("shift");
+testArrayHostThis("slice");
+testArrayHostThis("splice");
+testArrayHostThis("unshift");
+
 function testObjectInherit(obj, constr, ts, tls, vo) {
     ok(obj instanceof Object, "obj is not instance of Object");
     ok(obj instanceof constr, "obj is not instance of its constructor");