jscript: Pass global object as this if 'this' argument is null or undefined in Function.apply.
This commit is contained in:
parent
0e2132faf7
commit
710219a53d
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue