Commit fa09e3f3 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

jscript: Throw proper error when invoking non-method builtin.

Instead of crashing. Signed-off-by: 's avatarGabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 45d8af4c
......@@ -560,6 +560,9 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t
case PROP_BUILTIN: {
jsval_t vthis;
if(!prop->u.p->invoke)
return JS_E_FUNCTION_EXPECTED;
if(flags == DISPATCH_CONSTRUCT && (prop->flags & PROPF_METHOD)) {
WARN("%s is not a constructor\n", debugstr_w(prop->name));
return E_INVALIDARG;
......
......@@ -2611,6 +2611,8 @@ testException(function() {delete false;}, "E_INVALID_DELETE");
testException(function() {undefined.toString();}, "E_OBJECT_EXPECTED");
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() { return arguments.callee(); }, "E_STACK_OVERFLOW");
......
......@@ -1307,6 +1307,19 @@ sync_test("builtins_diffs", function() {
}catch(e) {
ok(e.number === 0xa1398 - 0x80000000, "RegExp.toString with non-regexp: exception = " + e.number);
}
try {
/a/.lastIndex();
ok(false, "/a/.lastIndex(): expected exception");
}catch(e) {
ok(e.number === 0xa138a - 0x80000000, "/a/.lastIndex(): exception = " + e.number);
}
try {
"a".length();
ok(false, "\"a\".length(): expected exception");
}catch(e) {
ok(e.number === 0xa138a - 0x80000000, "\"a\".length(): exception = " + e.number);
}
});
sync_test("__proto__", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment