From 38f1ce32107c489e4de7b3697c7c54fe898e4501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= Date: Wed, 13 Nov 2024 19:32:44 +0200 Subject: [PATCH] mshtml: Forward deletion for GLOBAL_SCRIPTVAR to the script's object. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gabriel Ivăncescu --- dlls/mshtml/htmlwindow.c | 39 +++++++++++++++++++++++++++++++ dlls/mshtml/tests/documentmode.js | 3 --- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index d9ecf9d3d29..b6f66627dd9 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -3974,6 +3974,44 @@ HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, return hres; } +static HRESULT HTMLWindow_delete(DispatchEx *dispex, DISPID id) +{ + HTMLInnerWindow *This = impl_from_DispatchEx(dispex); + DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN; + global_prop_t *prop; + HRESULT hres = S_OK; + + if(idx >= This->global_prop_cnt) + return DISP_E_MEMBERNOTFOUND; + + prop = This->global_props + idx; + switch(prop->type) { + case GLOBAL_SCRIPTVAR: { + IDispatchEx *iface; + IDispatch *disp; + + disp = get_script_disp(prop->script_host); + if(!disp) + return E_UNEXPECTED; + + hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&iface); + if(SUCCEEDED(hres)) { + hres = IDispatchEx_DeleteMemberByDispID(iface, prop->id); + IDispatchEx_Release(iface); + }else { + WARN("No IDispatchEx, so can't delete\n"); + hres = S_OK; + } + IDispatch_Release(disp); + break; + } + default: + break; + } + + return hres; +} + static HRESULT HTMLWindow_next_dispid(DispatchEx *dispex, DISPID id, DISPID *pid) { DWORD idx = (id == DISPID_STARTENUM) ? 0 : id - MSHTML_DISPID_CUSTOM_MIN + 1; @@ -4200,6 +4238,7 @@ static const event_target_vtbl_t HTMLWindow_event_target_vtbl = { .lookup_dispid = HTMLWindow_lookup_dispid, .find_dispid = HTMLWindow_find_dispid, .invoke = HTMLWindow_invoke, + .delete = HTMLWindow_delete, .next_dispid = HTMLWindow_next_dispid, .get_prop_desc = HTMLWindow_get_prop_desc, .get_script_global = HTMLWindow_get_script_global, diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index ca89fdadbdb..0ee20de7a90 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -1386,7 +1386,6 @@ sync_test("delete_prop", function() { r = (delete window.encodeURIComponent); ok(v >= 9, "did not get an expect exception deleting encodeURIComponent"); ok(r, "delete returned " + r); - todo_wine. ok(!("encodeURIComponent" in obj), "encodeURIComponent is still in obj"); window.encodeURIComponent = prop; }catch(ex) { @@ -1424,7 +1423,6 @@ sync_test("delete_prop", function() { ok(r, "did not get an expected globalprop2 exception"); }else { ok(!r, "got an unexpected exception"); - todo_wine. ok(!("globalprop2" in obj), "globalprop2 is still in obj"); } @@ -1457,7 +1455,6 @@ sync_test("delete_prop", function() { r = (delete window.globalprop5); ok(v >= 9, "did not get an expected exception deleting globalprop5"); ok(r, "delete returned " + r); - todo_wine. ok(!("globalprop5" in obj), "globalprop5 is still in obj"); }catch(ex) { ok(v < 9, "expected exception deleting globalprop5");