Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/global.c | 7 +++---- dlls/jscript/jscript.c | 5 +++++ dlls/jscript/jscript.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c index 735e188..33869cd 100644 --- a/dlls/jscript/global.c +++ b/dlls/jscript/global.c @@ -1055,7 +1055,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype) HRESULT init_global(script_ctx_t *ctx) { unsigned const_flags = ctx->version >= SCRIPTLANGUAGEVERSION_ES5 ? 0 : PROPF_WRITABLE; - jsdisp_t *math, *object_prototype, *constr; + jsdisp_t *math, *constr; HRESULT hres;
if(ctx->global) @@ -1065,12 +1065,11 @@ HRESULT init_global(script_ctx_t *ctx) if(FAILED(hres)) return hres;
- hres = create_object_prototype(ctx, &object_prototype); + hres = create_object_prototype(ctx, &ctx->object_prototype); if(FAILED(hres)) return hres;
- hres = init_constructors(ctx, object_prototype); - jsdisp_release(object_prototype); + hres = init_constructors(ctx, ctx->object_prototype); if(FAILED(hres)) return hres;
diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c index c5c2388..67a25d1 100644 --- a/dlls/jscript/jscript.c +++ b/dlls/jscript/jscript.c @@ -483,6 +483,11 @@ static void decrease_state(JScript *This, SCRIPTSTATE state) This->ctx->site = NULL; }
+ if(This->ctx->object_prototype) { + jsdisp_release(This->ctx->object_prototype); + This->ctx->object_prototype = NULL; + } + if(This->ctx->global) { jsdisp_release(This->ctx->global); This->ctx->global = NULL; diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index b590e1a..d7d9dd7 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -451,6 +451,7 @@ struct _script_ctx_t { jsdisp_t *uri_error_constr; jsdisp_t *number_constr; jsdisp_t *object_constr; + jsdisp_t *object_prototype; jsdisp_t *regexp_constr; jsdisp_t *string_constr; jsdisp_t *vbarray_constr;
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/dispex.c | 3 +++ dlls/jscript/tests/lang.js | 8 ++++++++ 2 files changed, 11 insertions(+)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index f3eba68..a1a1af5 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -1855,6 +1855,9 @@ HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const built
if(is_object_instance(val) && get_object(val)) prot = iface_to_jsdisp(get_object(val)); + else + prot = ctx->object_prototype; + jsval_release(val); }
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index 211ae2f..94c3329 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -1878,6 +1878,14 @@ testNullPrototype.prototype = nullDisp; tmp = new testNullPrototype(); ok(tmp.x === 13, "tmp.x !== 13"); ok(!("y" in tmp), "tmp has 'y' property"); +ok(!tmp.hasOwnProperty("y"), "tmp has 'y' property"); +ok(!tmp.propertyIsEnumerable("y"), "tmp has 'y' property enumerable"); +ok(tmp.toString() == "[object Object]", "tmp.toString returned " + tmp.toString()); +testNullPrototype.prototype = null; +tmp = new testNullPrototype(); +ok(!tmp.hasOwnProperty("y"), "tmp has 'y' property"); +ok(!tmp.propertyIsEnumerable("y"), "tmp has 'y' property enumerable"); +ok(tmp.toString() == "[object Object]", "tmp.toString returned " + tmp.toString());
function do_test() {} function nosemicolon() {} nosemicolon();
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/tests/lang.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index 94c3329..fa8407c 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -1887,6 +1887,24 @@ ok(!tmp.hasOwnProperty("y"), "tmp has 'y' property"); ok(!tmp.propertyIsEnumerable("y"), "tmp has 'y' property enumerable"); ok(tmp.toString() == "[object Object]", "tmp.toString returned " + tmp.toString());
+testNullPrototype.prototype = 42; +tmp = new testNullPrototype(); +ok(tmp.hasOwnProperty("x"), "tmp does not have 'x' property"); +ok(!tmp.hasOwnProperty("y"), "tmp has 'y' property"); +ok(tmp.toString() == "[object Object]", "tmp.toString returned " + tmp.toString()); + +testNullPrototype.prototype = true; +tmp = new testNullPrototype(); +ok(tmp.hasOwnProperty("x"), "tmp does not have 'x' property"); +ok(!tmp.hasOwnProperty("y"), "tmp has 'y' property"); +ok(tmp.toString() == "[object Object]", "tmp.toString returned " + tmp.toString()); + +testNullPrototype.prototype = "foobar"; +tmp = new testNullPrototype(); +ok(tmp.hasOwnProperty("x"), "tmp does not have 'x' property"); +ok(!tmp.hasOwnProperty("y"), "tmp has 'y' property"); +ok(tmp.toString() == "[object Object]", "tmp.toString returned " + tmp.toString()); + function do_test() {} function nosemicolon() {} nosemicolon(); function () {} nosemicolon();
Signed-off-by: Jacek Caban jacek@codeweavers.com