Jacek Caban : jscript: Properly handle arguments in Object constructor.

Alexandre Julliard julliard at winehq.org
Tue Jun 21 11:13:47 CDT 2016


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Jun 20 20:54:48 2016 +0200

jscript: Properly handle arguments in Object constructor.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/jscript/object.c     |  6 +++---
 dlls/jscript/tests/api.js | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/dlls/jscript/object.c b/dlls/jscript/object.c
index 71bed7b..827040b 100644
--- a/dlls/jscript/object.c
+++ b/dlls/jscript/object.c
@@ -261,6 +261,9 @@ static HRESULT ObjectConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
 
     switch(flags) {
     case DISPATCH_METHOD:
+    case DISPATCH_CONSTRUCT: {
+        jsdisp_t *obj;
+
         if(argc) {
             if(!is_undefined(argv[0]) && !is_null(argv[0]) && (!is_object_instance(argv[0]) || get_object(argv[0]))) {
                 IDispatch *disp;
@@ -276,9 +279,6 @@ static HRESULT ObjectConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
                 return S_OK;
             }
         }
-        /* fall through */
-    case DISPATCH_CONSTRUCT: {
-        jsdisp_t *obj;
 
         hres = create_object(ctx, NULL, &obj);
         if(FAILED(hres))
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index ca6131b..1ca974d 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -350,12 +350,27 @@ ok(Object(1) instanceof Number, "Object(1) is not instance of Number");
 ok(Object("") instanceof String, "Object('') is not instance of String");
 ok(Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
 
+ok(new Object(1) instanceof Number, "Object(1) is not instance of Number");
+ok(new Object("") instanceof String, "Object('') is not instance of String");
+ok(new Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
+
 obj = new Object();
 ok(Object(obj) === obj, "Object(obj) !== obj");
 
 ok(typeof(Object()) === "object", "typeof(Object()) !== 'object'");
 ok(typeof(Object(undefined)) === "object", "typeof(Object(undefined)) !== 'object'");
 ok(typeof(Object(null)) === "object", "typeof(Object(null)) !== 'object'");
+ok(typeof(Object(nullDisp)) === "object", "typeof(Object(nullDisp)) !== 'object'");
+
+ok(Object(nullDisp) != nullDisp, "Object(nullDisp) == nullDisp");
+ok(new Object(nullDisp) != nullDisp, "new Object(nullDisp) == nullDisp");
+
+ok(Object(testObj) === testObj, "Object(testObj) != testObj\n");
+ok(new Object(testObj) === testObj, "new Object(testObj) != testObj\n");
+
+tmp = new Object();
+ok(Object(tmp) === tmp, "Object(tmp) != tmp");
+ok(new Object(tmp) === tmp, "new Object(tmp) != tmp");
 
 var obj = new Object();
 obj.toString = function (x) {




More information about the wine-cvs mailing list