From 3f135a0611d4fbcffc62481ae4a3695efefb0f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= Date: Wed, 24 Nov 2021 16:10:32 +0200 Subject: [PATCH] jscript: Throw when defining a PROTREF prop on a non-extensible object. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gabriel Ivăncescu Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/jscript/dispex.c | 2 +- dlls/mshtml/tests/es5.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index ad6623f2648..8c0d84b8023 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -2555,7 +2555,7 @@ HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t if(FAILED(hres)) return hres; - if((!prop || prop->type == PROP_DELETED) && !obj->extensible) + if((!prop || prop->type == PROP_DELETED || prop->type == PROP_PROTREF) && !obj->extensible) return throw_error(obj->ctx, JS_E_OBJECT_NONEXTENSIBLE, name); if(!prop && !(prop = alloc_prop(obj, name, PROP_DELETED, 0))) diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index 81c06a4145e..ede94191ab6 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -999,6 +999,12 @@ sync_test("preventExtensions", function() { ok(o.prop === 1, "o.prop = " + o.prop); r = Object.isExtensible(o); ok(r === false, "isExtensible(o) returned " + r); + try { + Object.defineProperty(o, "prop", { value: true }); + ok(false, "expected exception"); + }catch(e) { + ok(e.name === "TypeError", "got " + e.name + " exception"); + } r = Object.isExtensible({}); ok(r === true, "isExtensible(o) returned " + r);