From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com ---
Add a bunch of tests along the way which verify existing behavior is mostly correct. --- dlls/mshtml/htmlwindow.c | 5 ++ dlls/mshtml/tests/dom.c | 114 +++++++++++++++++++++++++++++- dlls/mshtml/tests/events.c | 139 +++++++++++++++++++++++++++++++++++++ 3 files changed, 257 insertions(+), 1 deletion(-)
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index f013ba20d1c..c4c6a99f5f3 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -2038,6 +2038,11 @@ static HRESULT WINAPI HTMLWindow5_get_XMLHttpRequest(IHTMLWindow5 *iface, VARIAN
TRACE("(%p)->(%p)\n", This, p);
+ if(This->outer_window->readystate == READYSTATE_UNINITIALIZED) { + V_VT(p) = VT_EMPTY; + return S_OK; + } + if(!window->xhr_factory) { HRESULT hres;
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index dc236a27f1c..2efbbbf513c 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -11800,12 +11800,23 @@ static void test_quirks_mode(void)
static void test_document_mode_lock(void) { + IHTMLOptionElementFactory *option, *option2; + IHTMLDocument2 *doc, *doc_node, *doc_node2; + IHTMLImageElementFactory *image, *image2; + IOmNavigator *navigator, *navigator2; + IHTMLLocation *location, *location2; + IHTMLPerformance *perf, *perf2; + IOmHistory *history, *history2; + IHTMLScreen *screen, *screen2; IEventTarget *event_target; IPersistStreamInit *init; - IHTMLDocument2 *doc; + IHTMLWindow7 *window7; + IHTMLWindow5 *window5; + IHTMLWindow2 *window; IStream *stream; HRESULT hres; HGLOBAL mem; + VARIANT var; SIZE_T len; MSG msg;
@@ -11818,6 +11829,49 @@ static void test_document_mode_lock(void) ok(hres == E_NOINTERFACE, "QueryInterface(IID_IEventTarget) returned %08lx.\n", hres); ok(event_target == NULL, "event_target != NULL\n");
+ hres = IHTMLDocument2_get_parentWindow(doc, &window); + ok(hres == S_OK, "get_parentWindow failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_document(window, &doc_node); + ok(hres == S_OK, "get_document failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_location(window, &location); + ok(hres == S_OK, "get_location failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_navigator(window, &navigator); + ok(hres == S_OK, "get_navigator failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_history(window, &history); + ok(hres == S_OK, "get_history failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_screen(window, &screen); + ok(hres == S_OK, "get_screen failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_Image(window, &image); + ok(hres == S_OK, "get_image failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_Option(window, &option); + ok(hres == S_OK, "get_option failed: %08lx\n", hres); + + V_VT(&var) = VT_NULL; + hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLWindow5, (void**)&window5); + ok(hres == S_OK, "Could not get IHTMLWindow5: %08lx\n", hres); + hres = IHTMLWindow5_get_XMLHttpRequest(window5, &var); + ok(hres == S_OK, "get_XMLHttpRequest failed: %08lx\n", hres); + ok(V_VT(&var) == VT_EMPTY, "V_VT(XMLHttpRequest) = %d\n", V_VT(&var)); + IHTMLWindow5_Release(window5); + + hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLWindow7, (void**)&window7); + ok(hres == S_OK, "Could not get IHTMLWindow7: %08lx\n", hres); + hres = IHTMLWindow7_get_performance(window7, &var); + ok(hres == S_OK, "get_performance failed: %08lx\n", hres); + ok(V_VT(&var) == VT_DISPATCH, "V_VT(performance) = %d\n", V_VT(&var)); + hres = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IHTMLPerformance, (void**)&perf); + ok(hres == S_OK, "Could not get IHTMLPerformance: %08lx\n", hres); + IHTMLWindow7_Release(window7); + IHTMLWindow2_Release(window); + VariantClear(&var); + len = strlen(doc_blank_ie9); mem = GlobalAlloc(0, len); memcpy(mem, doc_blank_ie9, len); @@ -11844,6 +11898,64 @@ static void test_document_mode_lock(void) ok(event_target != NULL, "event_target == NULL\n"); IEventTarget_Release(event_target);
+ hres = IHTMLDocument2_get_parentWindow(doc, &window); + ok(hres == S_OK, "get_parentWindow failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_document(window, &doc_node2); + ok(hres == S_OK, "get_document failed: %08lx\n", hres); + ok(doc_node != doc_node2, "doc_node == doc_node2\n"); + IHTMLDocument2_Release(doc_node2); + IHTMLDocument2_Release(doc_node); + + hres = IHTMLWindow2_get_location(window, &location2); + ok(hres == S_OK, "get_location failed: %08lx\n", hres); + todo_wine + ok(location == location2, "location != location2\n"); + IHTMLLocation_Release(location2); + IHTMLLocation_Release(location); + + hres = IHTMLWindow2_get_navigator(window, &navigator2); + ok(hres == S_OK, "get_navigator failed: %08lx\n", hres); + ok(navigator != navigator2, "navigator == navigator2\n"); + IOmNavigator_Release(navigator2); + IOmNavigator_Release(navigator); + + hres = IHTMLWindow2_get_history(window, &history2); + ok(hres == S_OK, "get_history failed: %08lx\n", hres); + ok(history != history2, "history == history2\n"); + IOmHistory_Release(history2); + IOmHistory_Release(history); + + hres = IHTMLWindow2_get_screen(window, &screen2); + ok(hres == S_OK, "get_screen failed: %08lx\n", hres); + ok(screen != screen2, "screen == screen2\n"); + IHTMLScreen_Release(screen2); + IHTMLScreen_Release(screen); + + hres = IHTMLWindow2_get_Image(window, &image2); + ok(hres == S_OK, "get_image failed: %08lx\n", hres); + ok(image != image2, "image == image2\n"); + IHTMLImageElementFactory_Release(image2); + IHTMLImageElementFactory_Release(image); + + hres = IHTMLWindow2_get_Option(window, &option2); + ok(hres == S_OK, "get_option failed: %08lx\n", hres); + ok(option != option2, "option == option2\n"); + IHTMLOptionElementFactory_Release(option2); + IHTMLOptionElementFactory_Release(option); + + hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLWindow7, (void**)&window7); + ok(hres == S_OK, "Could not get IHTMLWindow7: %08lx\n", hres); + hres = IHTMLWindow7_get_performance(window7, &var); + ok(hres == S_OK, "get_performance failed: %08lx\n", hres); + ok(V_VT(&var) == VT_DISPATCH, "V_VT(performance) = %d\n", V_VT(&var)); + hres = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IHTMLPerformance, (void**)&perf2); + ok(hres == S_OK, "Could not get IHTMLPerformance: %08lx\n", hres); + ok(perf != perf2, "perf == perf2\n"); + IHTMLWindow7_Release(window7); + IHTMLWindow2_Release(window); + VariantClear(&var); + set_client_site(doc, FALSE); IHTMLDocument2_Release(doc); } diff --git a/dlls/mshtml/tests/events.c b/dlls/mshtml/tests/events.c index 30b6d8799b6..196ab3160a7 100644 --- a/dlls/mshtml/tests/events.c +++ b/dlls/mshtml/tests/events.c @@ -3135,9 +3135,22 @@ static void test_iframe_connections(IHTMLDocument2 *doc) static void test_doc_obj(IHTMLDocument2 *doc) { DISPID dispid, import_node_id, has_own_prop_id; + IHTMLOptionElementFactory *option, *option2; + IHTMLImageElementFactory *image, *image2; + IHTMLXMLHttpRequestFactory *xhr, *xhr2; + IHTMLDocument2 *doc_node, *doc_node2; + IOmNavigator *navigator, *navigator2; + IHTMLLocation *location, *location2; int orig_doc_mode = document_mode; + IHTMLStorage *storage, *storage2; + IHTMLPerformance *perf, *perf2; + IOmHistory *history, *history2; + IHTMLScreen *screen, *screen2; IEventTarget *event_target; DISPPARAMS dp = { 0 }; + IHTMLWindow7 *window7; + IHTMLWindow6 *window6; + IHTMLWindow5 *window5; IDispatchEx *dispex; IHTMLElement *body; VARIANT res, arg; @@ -3246,6 +3259,54 @@ static void test_doc_obj(IHTMLDocument2 *doc) SysFreeString(V_BSTR(&arg)); }
+ /* test window props during navigation */ + hres = IHTMLWindow2_get_document(window, &doc_node); + ok(hres == S_OK, "get_document failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_location(window, &location); + ok(hres == S_OK, "get_location failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_navigator(window, &navigator); + ok(hres == S_OK, "get_navigator failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_history(window, &history); + ok(hres == S_OK, "get_history failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_screen(window, &screen); + ok(hres == S_OK, "get_screen failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_Image(window, &image); + ok(hres == S_OK, "get_image failed: %08lx\n", hres); + + hres = IHTMLWindow2_get_Option(window, &option); + ok(hres == S_OK, "get_option failed: %08lx\n", hres); + + hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLWindow5, (void**)&window5); + ok(hres == S_OK, "Could not get IHTMLWindow5: %08lx\n", hres); + hres = IHTMLWindow5_get_XMLHttpRequest(window5, &res); + ok(hres == S_OK, "get_XMLHttpRequest failed: %08lx\n", hres); + ok(V_VT(&res) == VT_DISPATCH, "V_VT(XMLHttpRequest) = %d\n", V_VT(&res)); + hres = IDispatch_QueryInterface(V_DISPATCH(&res), &IID_IHTMLXMLHttpRequestFactory, (void**)&xhr); + ok(hres == S_OK, "Could not get IHTMLXMLHttpRequestFactory: %08lx\n", hres); + IHTMLWindow5_Release(window5); + VariantClear(&res); + + hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLWindow6, (void**)&window6); + ok(hres == S_OK, "Could not get IHTMLWindow6: %08lx\n", hres); + hres = IHTMLWindow6_get_sessionStorage(window6, &storage); + ok(hres == S_OK, "get_sessionStorage failed: %08lx\n", hres); + IHTMLWindow6_Release(window6); + + hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLWindow7, (void**)&window7); + ok(hres == S_OK, "Could not get IHTMLWindow7: %08lx\n", hres); + hres = IHTMLWindow7_get_performance(window7, &res); + ok(hres == S_OK, "get_performance failed: %08lx\n", hres); + ok(V_VT(&res) == VT_DISPATCH, "V_VT(performance) = %d\n", V_VT(&res)); + hres = IDispatch_QueryInterface(V_DISPATCH(&res), &IID_IHTMLPerformance, (void**)&perf); + ok(hres == S_OK, "Could not get IHTMLPerformance: %08lx\n", hres); + IHTMLWindow7_Release(window7); + VariantClear(&res); + /* Navigate to a different document mode page, checking using the same doc obj. Test that it breaks COM rules, since IEventTarget is conditionally exposed. All the events registered on the old doc node are also removed. @@ -3286,6 +3347,84 @@ static void test_doc_obj(IHTMLDocument2 *doc) ok(hres == S_OK, "GetIDsOfNames(importNode) returned: %08lx\n", hres); ok(dispid != import_node_id, "importNode on new doc node == old created importNode\n"); } + + hres = IHTMLWindow2_get_document(window, &doc_node2); + ok(hres == S_OK, "get_document failed: %08lx\n", hres); + ok(doc_node != doc_node2, "doc_node == doc_node2\n"); + IHTMLDocument2_Release(doc_node2); + IHTMLDocument2_Release(doc_node); + + hres = IHTMLWindow2_get_location(window, &location2); + ok(hres == S_OK, "get_location failed: %08lx\n", hres); + todo_wine + ok(location == location2, "location != location2\n"); + IHTMLLocation_Release(location2); + IHTMLLocation_Release(location); + + hres = IHTMLWindow2_get_navigator(window, &navigator2); + ok(hres == S_OK, "get_navigator failed: %08lx\n", hres); + ok(navigator != navigator2, "navigator == navigator2\n"); + IOmNavigator_Release(navigator2); + IOmNavigator_Release(navigator); + + hres = IHTMLWindow2_get_history(window, &history2); + ok(hres == S_OK, "get_history failed: %08lx\n", hres); + ok(history != history2, "history == history2\n"); + IOmHistory_Release(history2); + IOmHistory_Release(history); + + hres = IHTMLWindow2_get_screen(window, &screen2); + ok(hres == S_OK, "get_screen failed: %08lx\n", hres); + ok(screen != screen2, "screen == screen2\n"); + IHTMLScreen_Release(screen2); + IHTMLScreen_Release(screen); + + hres = IHTMLWindow2_get_Image(window, &image2); + ok(hres == S_OK, "get_image failed: %08lx\n", hres); + ok(image != image2, "image == image2\n"); + IHTMLImageElementFactory_Release(image2); + IHTMLImageElementFactory_Release(image); + + hres = IHTMLWindow2_get_Option(window, &option2); + ok(hres == S_OK, "get_option failed: %08lx\n", hres); + ok(option != option2, "option == option2\n"); + IHTMLOptionElementFactory_Release(option2); + IHTMLOptionElementFactory_Release(option); + + hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLWindow5, (void**)&window5); + ok(hres == S_OK, "Could not get IHTMLWindow5: %08lx\n", hres); + hres = IHTMLWindow5_get_XMLHttpRequest(window5, &res); + ok(hres == S_OK, "get_XMLHttpRequest failed: %08lx\n", hres); + ok(V_VT(&res) == VT_DISPATCH, "V_VT(XMLHttpRequest) = %d\n", V_VT(&res)); + hres = IDispatch_QueryInterface(V_DISPATCH(&res), &IID_IHTMLXMLHttpRequestFactory, (void**)&xhr2); + ok(hres == S_OK, "Could not get IHTMLXMLHttpRequestFactory: %08lx\n", hres); + ok(xhr != xhr2, "xhr == xhr2\n"); + IHTMLXMLHttpRequestFactory_Release(xhr2); + IHTMLXMLHttpRequestFactory_Release(xhr); + IHTMLWindow5_Release(window5); + VariantClear(&res); + + hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLWindow6, (void**)&window6); + ok(hres == S_OK, "Could not get IHTMLWindow6: %08lx\n", hres); + hres = IHTMLWindow6_get_sessionStorage(window6, &storage2); + ok(hres == S_OK, "get_sessionStorage failed: %08lx\n", hres); + ok(storage != storage2, "storage == storage2\n"); + IHTMLStorage_Release(storage2); + IHTMLStorage_Release(storage); + IHTMLWindow6_Release(window6); + + hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLWindow7, (void**)&window7); + ok(hres == S_OK, "Could not get IHTMLWindow7: %08lx\n", hres); + hres = IHTMLWindow7_get_performance(window7, &res); + ok(hres == S_OK, "get_performance failed: %08lx\n", hres); + ok(V_VT(&res) == VT_DISPATCH, "V_VT(performance) = %d\n", V_VT(&res)); + hres = IDispatch_QueryInterface(V_DISPATCH(&res), &IID_IHTMLPerformance, (void**)&perf2); + ok(hres == S_OK, "Could not get IHTMLPerformance: %08lx\n", hres); + ok(perf != perf2, "perf == perf2\n"); + IHTMLPerformance_Release(perf2); + IHTMLPerformance_Release(perf); + IHTMLWindow7_Release(window7); + VariantClear(&res); }
static void test_create_event(IHTMLDocument2 *doc)