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 committed by Alexandre Julliard
parent 12925e9113
commit 10cf578898
Notes: Alexandre Julliard 2024-11-18 23:19:10 +01:00
Approved-by: Jacek Caban (@jacek)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/wine/merge_requests/6678
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(desc->explicit_value) {
if(prop->type == PROP_JSVAL) if(prop->type == PROP_JSVAL)
jsval_release(prop->u.val); 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; prop->type = PROP_JSVAL;
}
hres = jsval_copy(desc->value, &prop->u.val); hres = jsval_copy(desc->value, &prop->u.val);
if(FAILED(hres)) { if(FAILED(hres)) {
prop->u.val = jsval_undefined(); prop->u.val = jsval_undefined();

View file

@ -2153,6 +2153,23 @@ sync_test("builtin_context", function() {
ok(obj.length === 1, "obj.length = " + obj.length); 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() { 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 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); var i, obj = Object.create(Function.prototype);