mshtml: Throw invalid action for IE8 window prop deletion.

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 <gabrielopcode@gmail.com>
This commit is contained in:
Gabriel Ivăncescu 2024-11-13 19:32:43 +02:00 committed by Alexandre Julliard
parent 12755eeb1c
commit 5947a66f4c
Notes: Alexandre Julliard 2024-11-14 23:12:21 +01:00
Approved-by: Jacek Caban (@jacek)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/wine/merge_requests/6721
2 changed files with 34 additions and 4 deletions

View file

@ -3364,18 +3364,34 @@ static HRESULT WINAPI WindowDispEx_InvokeEx(IWineJSDispatchHost *iface, DISPID i
static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IWineJSDispatchHost *iface, BSTR bstrName, DWORD grfdex) static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IWineJSDispatchHost *iface, BSTR bstrName, DWORD grfdex)
{ {
HTMLOuterWindow *This = impl_from_IWineJSDispatchHost(iface); 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); 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); return IWineJSDispatchHost_DeleteMemberByName(&This->base.inner_window->event_target.dispex.IWineJSDispatchHost_iface, bstrName, grfdex);
} }
static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IWineJSDispatchHost *iface, DISPID id) static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IWineJSDispatchHost *iface, DISPID id)
{ {
HTMLOuterWindow *This = impl_from_IWineJSDispatchHost(iface); 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); 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); return IWineJSDispatchHost_DeleteMemberByDispID(&This->base.inner_window->event_target.dispex.IWineJSDispatchHost_iface, id);
} }

View file

@ -1380,16 +1380,31 @@ sync_test("delete_prop", function() {
/* test window object and its global scope handling */ /* test window object and its global scope handling */
obj = window; 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; obj.globalprop1 = true;
ok(globalprop1, "globalprop1 = " + globalprop1); ok(globalprop1, "globalprop1 = " + globalprop1);
r = false; r = false;
try { try {
delete obj.globalprop1; delete obj.globalprop1;
}catch(ex) { }catch(ex) {
ok(ex.number === 0xa01bd - 0x80000000, "deleting globalprop1 threw " + ex.number);
r = true; r = true;
} }
if(v < 9) { if(v < 9) {
todo_wine.
ok(r, "did not get an expected exception"); ok(r, "did not get an expected exception");
}else { }else {
ok(!r, "got an unexpected globalprop1 exception"); ok(!r, "got an unexpected globalprop1 exception");
@ -1402,10 +1417,10 @@ sync_test("delete_prop", function() {
try { try {
delete obj.globalprop2; delete obj.globalprop2;
}catch(ex) { }catch(ex) {
ok(ex.number === 0xa01bd - 0x80000000, "deleting globalprop2 threw " + ex.number);
r = true; r = true;
} }
if(v < 9) { if(v < 9) {
todo_wine.
ok(r, "did not get an expected globalprop2 exception"); ok(r, "did not get an expected globalprop2 exception");
}else { }else {
ok(!r, "got an unexpected exception"); ok(!r, "got an unexpected exception");
@ -1419,12 +1434,11 @@ sync_test("delete_prop", function() {
try { try {
delete globalprop3; delete globalprop3;
}catch(ex) { }catch(ex) {
ok(ex.number === 0xa01bd - 0x80000000, "deleting globalprop3 threw " + ex.number);
r = true; r = true;
} }
if(v < 9) { if(v < 9) {
todo_wine.
ok(r, "did not get an expected exception"); ok(r, "did not get an expected exception");
todo_wine.
ok("globalprop3" in obj, "globalprop3 is not in obj"); ok("globalprop3" in obj, "globalprop3 is not in obj");
}else { }else {
ok(!r, "got an unexpected globalprop3 exception"); ok(!r, "got an unexpected globalprop3 exception");