Jacek Caban : jscript: Throw correct error in get_length.
Alexandre Julliard
julliard at winehq.org
Wed Sep 23 11:03:59 CDT 2009
Module: wine
Branch: master
Commit: bb4050d79280dc83e4f3159eb121cb88d84721e9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bb4050d79280dc83e4f3159eb121cb88d84721e9
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Sep 23 16:24:11 2009 +0200
jscript: Throw correct error in get_length.
---
dlls/jscript/array.c | 6 ++----
dlls/jscript/jscript_En.rc | 1 +
dlls/jscript/resource.h | 1 +
dlls/jscript/tests/api.js | 10 ++++++++++
4 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c
index b3dc780..1fa20fe 100644
--- a/dlls/jscript/array.c
+++ b/dlls/jscript/array.c
@@ -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))
diff --git a/dlls/jscript/jscript_En.rc b/dlls/jscript/jscript_En.rc
index b7f8744..79921b4 100644
--- a/dlls/jscript/jscript_En.rc
+++ b/dlls/jscript/jscript_En.rc
@@ -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"
}
diff --git a/dlls/jscript/resource.h b/dlls/jscript/resource.h
index 9e33ebc..81cd74d 100644
--- a/dlls/jscript/resource.h
+++ b/dlls/jscript/resource.h
@@ -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
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index ee3a058..1c2f56b 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -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");
More information about the wine-cvs
mailing list