From be3dc38183d235ad01141e6462cdd2850eb0a9c9 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 16 Aug 2010 12:36:34 +0200 Subject: [PATCH] jscript: Throw TypeError in instanceof_expression_eval. --- dlls/jscript/engine.c | 6 ++---- dlls/jscript/jscript_En.rc | 1 + dlls/jscript/resource.h | 1 + dlls/jscript/tests/api.js | 3 +++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index b40a88eb591..167b5d99167 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -1999,10 +1999,8 @@ static HRESULT instanceof_eval(exec_ctx_t *ctx, VARIANT *inst, VARIANT *objv, js static const WCHAR prototypeW[] = {'p','r','o','t','o','t', 'y', 'p','e',0}; - if(V_VT(objv) != VT_DISPATCH) { - FIXME("throw TypeError\n"); - return E_FAIL; - } + if(V_VT(objv) != VT_DISPATCH || !V_DISPATCH(objv)) + return throw_type_error(ctx->parser->script, ei, IDS_NOT_FUNC, NULL); obj = iface_to_jsdisp((IUnknown*)V_DISPATCH(objv)); if(!obj) { diff --git a/dlls/jscript/jscript_En.rc b/dlls/jscript/jscript_En.rc index d98b0b691d0..b8c7ad155e0 100644 --- a/dlls/jscript/jscript_En.rc +++ b/dlls/jscript/jscript_En.rc @@ -26,6 +26,7 @@ STRINGTABLE IDS_INVALID_CALL_ARG "Invalid procedure call or argument" IDS_CREATE_OBJ_ERROR "Automation server can't create object" IDS_NO_PROPERTY "Object doesn't support this property or method" + IDS_UNSUPPORTED_ACTION "Object doesn't support this action" IDS_ARG_NOT_OPT "Argument not optional" IDS_SYNTAX_ERROR "Syntax error" IDS_SEMICOLON "Expected ';'" diff --git a/dlls/jscript/resource.h b/dlls/jscript/resource.h index b88621fb58c..074bdcd0adc 100644 --- a/dlls/jscript/resource.h +++ b/dlls/jscript/resource.h @@ -22,6 +22,7 @@ #define IDS_INVALID_CALL_ARG 0x0005 #define IDS_CREATE_OBJ_ERROR 0x01AD #define IDS_NO_PROPERTY 0x01B6 +#define IDS_UNSUPPORTED_ACTION 0x01BD #define IDS_ARG_NOT_OPT 0x01c1 #define IDS_SYNTAX_ERROR 0x03EA #define IDS_SEMICOLON 0x03EC diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index c57666dc260..9a253dcc692 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -1888,6 +1888,9 @@ exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273); exception_test(function() {eval("nonexistingfunc()")}, "TypeError", -2146823281); exception_test(function() {RegExp(/a/, "g");}, "RegExpError", -2146823271); exception_test(function() {encodeURI('\udcaa');}, "URIError", -2146823264); +exception_test(function() {(new Object()) instanceof 3;}, "TypeError", -2146823286); +exception_test(function() {(new Object()) instanceof null;}, "TypeError", -2146823286); +exception_test(function() {(new Object()) instanceof nullDisp;}, "TypeError", -2146823286); function testThisExcept(func, number) { exception_test(function() {func.call(new Object())}, "TypeError", number);