[PATCH v2 2/2] jscript: Use default object prototype if it's null.

Gabriel Ivăncescu gabrielopcode at gmail.com
Fri Mar 5 10:59:42 CST 2021


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 dlls/jscript/dispex.c      | 4 ++++
 dlls/jscript/tests/lang.js | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index 9d0357e..d5d6912 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -1855,6 +1855,10 @@ 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 if(SUCCEEDED(find_prop_name(ctx->object_constr, string_hash(L"prototype"), L"prototype", &prop)) &&
+                prop && prop->type != PROP_DELETED && SUCCEEDED(prop_get(constr, prop, &val)) && is_object_instance(val))
+            prot = iface_to_jsdisp(get_object(val));
+
         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();
-- 
2.30.0




More information about the wine-devel mailing list