Commit 710219a5 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

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

parent 0e2132fa
......@@ -403,9 +403,13 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
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;
}
}
if(argc >= 2) {
......@@ -413,8 +417,8 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
if(V_VT(get_arg(dp,1)) == VT_DISPATCH) {
arg_array = iface_to_jsdisp((IUnknown*)V_DISPATCH(get_arg(dp,1)));
if(arg_array && (
!is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) {
if(arg_array &&
(!is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) {
jsdisp_release(arg_array);
arg_array = NULL;
}
......
......@@ -1402,6 +1402,9 @@ function callTest3() {
callTest3.call();
callTest3.call(undefined);
callTest3.call(null);
callTest3.apply();
callTest3.apply(undefined);
callTest3.apply(null);
tmp = Number.prototype.toString.call(3);
ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);
......
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