From: Jacek Caban jacek@codeweavers.com
--- dlls/jscript/dispex.c | 18 +++++++++++------- dlls/jscript/tests/api.js | 1 + dlls/mshtml/tests/es5.js | 5 +++++ 3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 0e8650f12e5..3b1b4f83267 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -653,8 +653,8 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t This->prototype->props+prop->u.ref, flags, argc, argv, r, caller); case PROP_JSVAL: { if(!is_object_instance(prop->u.val)) { - FIXME("invoke %s\n", debugstr_jsval(prop->u.val)); - return E_FAIL; + FIXME("value %s is not a function\n", debugstr_jsval(prop->u.val)); + return JS_E_FUNCTION_EXPECTED; }
TRACE("call %s %p\n", debugstr_w(prop->name), get_object(prop->u.val)); @@ -672,12 +672,16 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t return hres;
if(is_object_instance(val)) { - hres = disp_call_value_with_caller(This->ctx, get_object(val), - jsval_disp(jsthis ? jsthis : to_disp(This)), - flags, argc, argv, r, caller); + jsdisp_t *jsfunc = to_jsdisp(get_object(val)); + if(!jsfunc || is_class(jsfunc, JSCLASS_FUNCTION)) + hres = disp_call_value_with_caller(This->ctx, get_object(val), + jsval_disp(jsthis ? jsthis : to_disp(This)), + flags, argc, argv, r, caller); + else + hres = JS_E_INVALID_PROPERTY; }else { - FIXME("invoke %s\n", debugstr_jsval(val)); - hres = E_NOTIMPL; + WARN("value %s is not a function\n", debugstr_jsval(val)); + hres = JS_E_FUNCTION_EXPECTED; }
jsval_release(val); diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index aea412347b9..a82e4756c24 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -2744,6 +2744,7 @@ testException(function() {null.toString();}, "E_OBJECT_EXPECTED"); testException(function() {RegExp.prototype.toString.call(new Object());}, "E_REGEXP_EXPECTED"); testException(function() {/a/.lastIndex();}, "E_NOT_FUNC"); testException(function() {"a".length();}, "E_NOT_FUNC"); +testException(function() {var o = {f: {}}; o.f();}, "E_NOT_FUNC"); testException(function() {((function() { var f = Number.prototype.toString; return (function() { return f(); }); })())();}, "E_NOT_NUM"); testException(function() {((function() { var f = Object.prototype.hasOwnProperty; return (function() { return f("f"); }); })())();}, "E_OBJECT_EXPECTED");
diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index f2e025ec864..1225a744de6 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -838,6 +838,11 @@ sync_test("defineProperty", function() { expect_exception(function() { Object.defineProperty(obj, "funcprop", nullDisp); }, JS_E_OBJECT_EXPECTED); + expect_exception(function() { + var o = {}; + Object.defineProperty(o, "f", { get: function() { return 0; } }); + o.f(); + }, JS_E_FUNCTION_EXPECTED); });
sync_test("defineProperties", function() {