jscript: Pass global object as this if 'this' argument is null or undefined in Function.call.

This commit is contained in:
Jacek Caban 2009-10-30 00:01:49 +01:00 committed by Alexandre Julliard
parent c214022eca
commit 0e2132faf7
2 changed files with 11 additions and 3 deletions
dlls/jscript

@ -455,9 +455,14 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
argc = arg_cnt(dp);
if(argc) {
hres = to_object(ctx, get_arg(dp,0), &this_obj);
if(FAILED(hres))
return hres;
VARIANT *v = get_arg(dp,0);
if(V_VT(v) != VT_EMPTY && V_VT(v) != VT_NULL) {
hres = to_object(ctx, v, &this_obj);
if(FAILED(hres))
return hres;
}
args.cArgs = argc-1;
}

@ -1395,10 +1395,13 @@ callTest2.apply(tmp);
(function () { callTest2.apply(tmp, arguments); })();
function callTest3() {
testThis(this);
ok(arguments.length === 0, "arguments.length = " + arguments.length + " expected 0");
}
callTest3.call();
callTest3.call(undefined);
callTest3.call(null);
tmp = Number.prototype.toString.call(3);
ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);