From 5947a66f4ce0eb5e12777f211889215f40d988db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= Date: Wed, 13 Nov 2024 19:32:43 +0200 Subject: [PATCH] mshtml: Throw invalid action for IE8 window prop deletion. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of E_NOTIMPL. We can't use the dispex's delete because it also applies to dynamic and builtin props and it also happens too late when deleting by name (after looking it up), where existing tests show it doesn't look up the dispid at all. Signed-off-by: Gabriel Ivăncescu --- dlls/mshtml/htmlwindow.c | 16 ++++++++++++++++ dlls/mshtml/tests/documentmode.js | 22 ++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index a4039ce08bc..731acd61cd7 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -3364,18 +3364,34 @@ static HRESULT WINAPI WindowDispEx_InvokeEx(IWineJSDispatchHost *iface, DISPID i static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IWineJSDispatchHost *iface, BSTR bstrName, DWORD grfdex) { HTMLOuterWindow *This = impl_from_IWineJSDispatchHost(iface); + compat_mode_t compat_mode = dispex_compat_mode(&This->base.inner_window->event_target.dispex); TRACE("(%p)->(%s %lx)\n", This, debugstr_w(bstrName), grfdex); + if(compat_mode < COMPAT_MODE_IE8) { + /* Not implemented by IE */ + return E_NOTIMPL; + } + if(compat_mode == COMPAT_MODE_IE8) + return MSHTML_E_INVALID_ACTION; + return IWineJSDispatchHost_DeleteMemberByName(&This->base.inner_window->event_target.dispex.IWineJSDispatchHost_iface, bstrName, grfdex); } static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IWineJSDispatchHost *iface, DISPID id) { HTMLOuterWindow *This = impl_from_IWineJSDispatchHost(iface); + compat_mode_t compat_mode = dispex_compat_mode(&This->base.inner_window->event_target.dispex); TRACE("(%p)->(%lx)\n", This, id); + if(compat_mode < COMPAT_MODE_IE8) { + /* Not implemented by IE */ + return E_NOTIMPL; + } + if(compat_mode == COMPAT_MODE_IE8) + return MSHTML_E_INVALID_ACTION; + return IWineJSDispatchHost_DeleteMemberByDispID(&This->base.inner_window->event_target.dispex.IWineJSDispatchHost_iface, id); } diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index ae5e68126dd..53372ac7752 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -1380,16 +1380,31 @@ sync_test("delete_prop", function() { /* test window object and its global scope handling */ obj = window; + ok("encodeURIComponent" in obj, "encodeURIComponent not in obj"); + try { + prop = window.encodeURIComponent; + 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) { + ok(v < 9, "expected exception deleting encodeURIComponent"); + ok(ex.number === 0xa01bd - 0x80000000, "deleting encodeURIComponent threw " + ex.number); + ok("encodeURIComponent" in obj, "encodeURIComponent is not in obj"); + } + obj.globalprop1 = true; ok(globalprop1, "globalprop1 = " + globalprop1); r = false; try { delete obj.globalprop1; }catch(ex) { + ok(ex.number === 0xa01bd - 0x80000000, "deleting globalprop1 threw " + ex.number); r = true; } if(v < 9) { - todo_wine. ok(r, "did not get an expected exception"); }else { ok(!r, "got an unexpected globalprop1 exception"); @@ -1402,10 +1417,10 @@ sync_test("delete_prop", function() { try { delete obj.globalprop2; }catch(ex) { + ok(ex.number === 0xa01bd - 0x80000000, "deleting globalprop2 threw " + ex.number); r = true; } if(v < 9) { - todo_wine. ok(r, "did not get an expected globalprop2 exception"); }else { ok(!r, "got an unexpected exception"); @@ -1419,12 +1434,11 @@ sync_test("delete_prop", function() { try { delete globalprop3; }catch(ex) { + ok(ex.number === 0xa01bd - 0x80000000, "deleting globalprop3 threw " + ex.number); r = true; } if(v < 9) { - todo_wine. ok(r, "did not get an expected exception"); - todo_wine. ok("globalprop3" in obj, "globalprop3 is not in obj"); }else { ok(!r, "got an unexpected globalprop3 exception");