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

Alexandre Julliard julliard at winehq.org
Fri Oct 30 11:04:32 CDT 2009


Module: wine
Branch: master
Commit: 0e2132faf76eedb5166119a7ec3a0feb77986d10
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0e2132faf76eedb5166119a7ec3a0feb77986d10

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Oct 30 00:01:49 2009 +0100

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

---

 dlls/jscript/function.c   |   11 ++++++++---
 dlls/jscript/tests/api.js |    3 +++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
index faf2daa..7d8e812 100644
--- a/dlls/jscript/function.c
+++ b/dlls/jscript/function.c
@@ -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;
     }
 
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index da32da4..9a9481e 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -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);




More information about the wine-cvs mailing list