From: Jacek Caban jacek@codeweavers.com
--- dlls/jscript/dispex.c | 15 +++++++++++++++ dlls/jscript/jsdisp.idl | 3 +++ dlls/mshtml/dispex.c | 8 ++++++++ dlls/mshtml/htmlwindow.c | 20 ++++++++++++++++++++ dlls/mshtml/mshtml_private.h | 2 ++ dlls/mshtml/omnavigator.c | 3 +-- dlls/mshtml/tests/documentmode.js | 2 +- 7 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index dbdc64659a8..517859433f2 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -2308,6 +2308,20 @@ static void WINAPI WineJSDispatch_Free(IWineJSDispatch *iface) jsdisp_free(This); }
+static HRESULT WINAPI WineJSDispatch_GetScriptGlobal(IWineJSDispatch *iface, IWineJSDispatchHost **ret) +{ + jsdisp_t *This = impl_from_IWineJSDispatch(iface); + IDispatch *disp; + + if(!This->ctx->site) + return E_UNEXPECTED; + + if(!(disp = lookup_global_host(This->ctx))) + return E_NOINTERFACE; + + return IDispatch_QueryInterface(disp, &IID_IWineJSDispatchHost, (void **)ret); +} + static IWineJSDispatchVtbl DispatchExVtbl = { DispatchEx_QueryInterface, DispatchEx_AddRef, @@ -2325,6 +2339,7 @@ static IWineJSDispatchVtbl DispatchExVtbl = { DispatchEx_GetNextDispID, DispatchEx_GetNameSpaceParent, WineJSDispatch_Free, + WineJSDispatch_GetScriptGlobal, };
jsdisp_t *as_jsdisp(IDispatch *disp) diff --git a/dlls/jscript/jsdisp.idl b/dlls/jscript/jsdisp.idl index 8ea53396f09..f01ea95ce48 100644 --- a/dlls/jscript/jsdisp.idl +++ b/dlls/jscript/jsdisp.idl @@ -34,6 +34,8 @@ const unsigned int PROPF_ENUMERABLE = 0x0400; const unsigned int PROPF_WRITABLE = 0x0800; const unsigned int PROPF_CONFIGURABLE = 0x1000;
+interface IWineJSDispatchHost; + [ object, uuid(d359f2fe-5531-741b-a41a-5cf92edc971c), @@ -42,6 +44,7 @@ const unsigned int PROPF_CONFIGURABLE = 0x1000; interface IWineJSDispatch : IDispatchEx { void Free(); + HRESULT GetScriptGlobal(IWineJSDispatchHost **ret); }
[ diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 7b334ac3001..72eb8db40a7 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -2573,3 +2573,11 @@ void init_dispatch(DispatchEx *dispex, dispex_static_data_t *data, HTMLInnerWind dispex->info = ensure_dispex_info(dispex, data, compat_mode, script_global); } } + +void init_dispatch_with_owner(DispatchEx *dispex, dispex_static_data_t *desc, DispatchEx *owner) +{ + HTMLInnerWindow *script_global = get_script_global(owner); + init_dispatch(dispex, desc, script_global, dispex_compat_mode(owner)); + if(script_global) + IHTMLWindow2_Release(&script_global->base.IHTMLWindow2_iface); +} diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 88c9879ac69..af2a0e83d66 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -4208,6 +4208,26 @@ void init_window_cc(void) ccp_init(&outer_window_ccp, &ccp_callback); }
+HTMLInnerWindow *get_script_global(DispatchEx *dispex) +{ + IWineJSDispatchHost *disp; + HTMLInnerWindow *ret; + HRESULT hres; + + if(!dispex->jsdisp) + return NULL; + hres = IWineJSDispatch_GetScriptGlobal(dispex->jsdisp, &disp); + if(FAILED(hres)) + return NULL; + + assert(disp->lpVtbl == &WindowDispExVtbl); + ret = impl_from_IWineJSDispatchHost(disp)->base.inner_window; + if(ret) + IHTMLWindow2_AddRef(&ret->base.IHTMLWindow2_iface); + IWineJSDispatchHost_Release(disp); + return ret; +} + static void *alloc_window(size_t size) { HTMLWindow *window; diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 2bd0887d735..080ad008cbe 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -492,6 +492,8 @@ extern void (__cdecl *describe_cc_node)(nsCycleCollectingAutoRefCnt*,const char* extern void (__cdecl *note_cc_edge)(nsISupports*,const char*,nsCycleCollectionTraversalCallback*);
void init_dispatch(DispatchEx*,dispex_static_data_t*,HTMLInnerWindow*,compat_mode_t); +void init_dispatch_with_owner(DispatchEx*,dispex_static_data_t*,DispatchEx*); +HTMLInnerWindow *get_script_global(DispatchEx*); void dispex_props_unlink(DispatchEx*); HRESULT change_type(VARIANT*,VARIANT*,VARTYPE,IServiceProvider*); HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**); diff --git a/dlls/mshtml/omnavigator.c b/dlls/mshtml/omnavigator.c index 6284858b763..2b2b54cc2df 100644 --- a/dlls/mshtml/omnavigator.c +++ b/dlls/mshtml/omnavigator.c @@ -685,8 +685,7 @@ static HRESULT create_plugins_collection(OmNavigator *navigator, HTMLPluginsColl col->IHTMLPluginsCollection_iface.lpVtbl = &HTMLPluginsCollectionVtbl; col->navigator = navigator;
- init_dispatch(&col->dispex, &HTMLPluginsCollection_dispex, NULL, - dispex_compat_mode(&navigator->dispex)); + init_dispatch_with_owner(&col->dispex, &HTMLPluginsCollection_dispex, &navigator->dispex);
*ret = col; return S_OK; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index a00647c5ddd..95652bd5b72 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -307,7 +307,7 @@ sync_test("builtin_toString", function() { test("performance", window.performance, "Performance"); test("performanceNavigation", window.performance.navigation, "PerformanceNavigation"); test("performanceTiming", window.performance.timing, "PerformanceTiming"); - if(v >= 11 /* todo_wine */) test("plugins", window.navigator.plugins, v < 11 ? "MSPluginsCollection" : "PluginArray", null, true); + if(v >= 11 /* todo_wine */) test("plugins", window.navigator.plugins, v < 11 ? "MSPluginsCollection" : "PluginArray"); test("screen", window.screen, "Screen"); test("sessionStorage", window.sessionStorage, "Storage", null, true); test("style", document.body.style, "MSStyleCSSProperties", null, true);