jscript: Delete external props before redefining them.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
This commit is contained in:
Gabriel Ivăncescu 2024-11-18 22:49:52 +02:00
parent ae6366b33c
commit f6b1bfa877
No known key found for this signature in database
GPG key ID: 4CEE4FF41CC69382
2 changed files with 24 additions and 1 deletions

View file

@ -3282,8 +3282,14 @@ HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t
if(desc->explicit_value) {
if(prop->type == PROP_JSVAL)
jsval_release(prop->u.val);
else
else {
if(prop->type == PROP_EXTERN && obj->builtin_info->prop_delete) {
hres = obj->builtin_info->prop_delete(obj, prop->u.id);
if(FAILED(hres))
return hres;
}
prop->type = PROP_JSVAL;
}
hres = jsval_copy(desc->value, &prop->u.val);
if(FAILED(hres)) {
prop->u.val = jsval_undefined();

View file

@ -2153,6 +2153,23 @@ sync_test("builtin_context", function() {
ok(obj.length === 1, "obj.length = " + obj.length);
});
sync_test("globals override", function() {
wineprop = 1337; /* global */
ok(window.hasOwnProperty("wineprop"), "wineprop not a prop of window");
ok(window.wineprop === 1337, "window.wineprop = " + window.wineprop);
ok(wineprop === 1337, "wineprop = " + wineprop);
var r = Object.defineProperty(window, "wineprop", { value: 42, configurable: true });
ok(r === window, "defineProperty(window.wineprop) returned " + r);
ok(window.hasOwnProperty("wineprop"), "wineprop not a prop of window after override");
ok(window.wineprop === 42, "window.wineprop after override = " + window.wineprop);
ok(wineprop === 42, "wineprop after override = " + wineprop);
r = (delete window.wineprop);
ok(r === true, "delete window.wineprop returned " + r);
ok(!("wineprop" in window), "wineprop in window after delete");
});
sync_test("host this", function() {
var tests = [ undefined, null, external.nullDisp, function() {}, [0], "foobar", true, 42, new Number(42), external.testHostContext(true), window, document ];
var i, obj = Object.create(Function.prototype);