From 68dddd8d8963bb7551abfbe8601d82138063feb6 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 20 Jun 2016 20:54:48 +0200 Subject: [PATCH] jscript: Properly handle arguments in Object constructor. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- 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 71bed7b26ab..827040bc6b9 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 ca6131b0424..1ca974d8b9c 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) {