From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlscript.h | 2 +- dlls/mshtml/htmlwindow.c | 6 ++++-- dlls/mshtml/script.c | 5 ++++- dlls/mshtml/tests/dom.c | 41 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmlscript.h b/dlls/mshtml/htmlscript.h index c1b1aa2c4bc..dab2c444d33 100644 --- a/dlls/mshtml/htmlscript.h +++ b/dlls/mshtml/htmlscript.h @@ -47,7 +47,7 @@ void doc_insert_script(HTMLInnerWindow*,HTMLScriptElement*,BOOL); IDispatch *script_parse_event(HTMLInnerWindow*,LPCWSTR); HRESULT exec_script(HTMLInnerWindow*,const WCHAR*,const WCHAR*,VARIANT*); void update_browser_script_mode(GeckoBrowser*,IUri*); -BOOL find_global_prop(HTMLInnerWindow*,const WCHAR*,DWORD,ScriptHost**,DISPID*); +BOOL find_global_prop(HTMLInnerWindow*,const WCHAR*,DWORD,ScriptHost**,DISPID*,BSTR*); HRESULT global_prop_still_exists(HTMLInnerWindow*,global_prop_t*); IDispatch *get_script_disp(ScriptHost*); IWineJSDispatch *get_script_jsdisp(ScriptHost*); diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index c608ab1c881..e5e2481299a 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -3307,6 +3307,7 @@ HRESULT search_window_props(HTMLInnerWindow *This, const WCHAR *name, DWORD grfd { DWORD i; ScriptHost *script_host; + BSTR prop_name; DISPID id;
for(i=0; i < This->global_prop_cnt; i++) { @@ -3319,10 +3320,11 @@ HRESULT search_window_props(HTMLInnerWindow *This, const WCHAR *name, DWORD grfd } }
- if(find_global_prop(This->base.inner_window, name, grfdex, &script_host, &id)) { + if(find_global_prop(This->base.inner_window, name, grfdex, &script_host, &id, &prop_name)) { global_prop_t *prop;
- prop = alloc_global_prop(This, GLOBAL_SCRIPTVAR, name); + prop = alloc_global_prop(This, GLOBAL_SCRIPTVAR, prop_name ? prop_name : name); + SysFreeString(prop_name); if(!prop) return E_OUTOFMEMORY;
diff --git a/dlls/mshtml/script.c b/dlls/mshtml/script.c index 5a2d19551dd..487fa148b5c 100644 --- a/dlls/mshtml/script.c +++ b/dlls/mshtml/script.c @@ -1819,7 +1819,7 @@ void bind_event_scripts(HTMLDocumentNode *doc) nsIDOMNodeList_Release(node_list); }
-BOOL find_global_prop(HTMLInnerWindow *window, const WCHAR *name, DWORD flags, ScriptHost **ret_host, DISPID *ret_id) +BOOL find_global_prop(HTMLInnerWindow *window, const WCHAR *name, DWORD flags, ScriptHost **ret_host, DISPID *ret_id, BSTR *ret_name) { IDispatchEx *dispex; IDispatch *disp; @@ -1837,7 +1837,10 @@ BOOL find_global_prop(HTMLInnerWindow *window, const WCHAR *name, DWORD flags, S
hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); if(SUCCEEDED(hres)) { + *ret_name = NULL; hres = IDispatchEx_GetDispID(dispex, str, flags & (~fdexNameEnsure), ret_id); + if(SUCCEEDED(hres) && (flags & fdexNameCaseInsensitive)) + hres = IDispatchEx_GetMemberName(dispex, *ret_id, ret_name); IDispatchEx_Release(dispex); }else { FIXME("No IDispatchEx\n"); diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 26b487b9175..17b4f63711d 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -117,6 +117,8 @@ static const char doctype_str[] = " <title>emptydiv test</title>" " </head>" "<body><div id="divid"></div></body></html>"; +static const char case_insens_str[] = + "<html><script type="text/javascript">window.wineProp = 42;</script></html>";
static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0}; static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0}; @@ -11562,6 +11564,44 @@ static void test_doctype(IHTMLDocument2 *doc) IHTMLDOMNode_Release(doctype); }
+static void test_case_insens(IHTMLDocument2 *doc) +{ + DISPID dispid, dispid2; + IHTMLWindow2 *window; + IDispatchEx *dispex; + HRESULT hres; + BSTR bstr; + + window = get_doc_window(doc); + hres = IHTMLWindow2_QueryInterface(window, &IID_IDispatchEx, (void**)&dispex); + ok(hres == S_OK, "Could not get IDispatchEx: %08lx\n", hres); + IHTMLWindow2_Release(window); + + bstr = SysAllocString(L"WINEprop"); + hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseInsensitive, &dispid); + ok(hres == S_OK, "GetDispID returned: %08lx\n", hres); + SysFreeString(bstr); + + hres = IDispatchEx_GetMemberName(dispex, dispid, &bstr); + ok(hres == S_OK, "GetMemberName returned: %08lx\n", hres); + ok(!wcscmp(bstr, L"wineProp"), "got %s\n", wine_dbgstr_w(bstr)); + SysFreeString(bstr); + + /* For some reason GetMemberName on native here returns DISP_E_MEMBERNOTFOUND even though DISPID is found, so compare dispids instead */ + bstr = SysAllocString(L"coLLecTgarbAGE"); + hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseInsensitive, &dispid); + ok(hres == S_OK, "GetDispID returned: %08lx\n", hres); + SysFreeString(bstr); + + bstr = SysAllocString(L"CollectGarbage"); + hres = IDispatchEx_GetDispID(dispex, bstr, 0, &dispid2); + ok(hres == S_OK, "GetDispID returned: %08lx\n", hres); + ok(dispid == dispid2, "dispid != dispid2\n"); + SysFreeString(bstr); + + IDispatchEx_Release(dispex); +} + static void test_null_write(IHTMLDocument2 *doc) { HRESULT hres; @@ -13599,6 +13639,7 @@ START_TEST(dom) run_domtest(emptydiv_str, test_docfrag); run_domtest(doc_blank, test_replacechild_elems); run_domtest(doctype_str, test_doctype); + run_domtest(case_insens_str, test_case_insens); if(is_ie9plus) { compat_mode = COMPAT_IE9; run_domtest(emptydiv_ie9_str, test_docfrag);