From: Gabriel Ivăncescu gabrielopcode@gmail.com
It was confusing before since it made it seem like it might use the outer window, while in fact the document is unchanged on native. Now the "new" doc is used for navigating, since it's already checked to be the same as the iframes_doc (but that test fails in wine and is todo_wine). --- dlls/mshtml/tests/events.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/dlls/mshtml/tests/events.c b/dlls/mshtml/tests/events.c index b76e7982638..0f0246bfe5c 100644 --- a/dlls/mshtml/tests/events.c +++ b/dlls/mshtml/tests/events.c @@ -173,16 +173,16 @@ static const char iframe_doc_str[] =
static void navigate(IHTMLDocument2*,const WCHAR*);
-static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2) +static BOOL iface_cmp(void *iface1, void *iface2) { IUnknown *unk1, *unk2;
if(iface1 == iface2) return TRUE;
- IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1); + IUnknown_QueryInterface((IUnknown *)iface1, &IID_IUnknown, (void**)&unk1); IUnknown_Release(unk1); - IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2); + IUnknown_QueryInterface((IUnknown *)iface2, &IID_IUnknown, (void**)&unk2); IUnknown_Release(unk2);
return unk1 == unk2; @@ -3170,8 +3170,8 @@ static IHTMLDocument2 *get_iframe_doc(IHTMLIFrameElement *iframe)
static void test_iframe_connections(IHTMLDocument2 *doc) { + IHTMLDocument2 *iframes_doc, *new_doc; IHTMLIFrameElement *iframe; - IHTMLDocument2 *iframes_doc; DWORD cookie; IConnectionPoint *cp; IHTMLElement *element; @@ -3185,7 +3185,6 @@ static void test_iframe_connections(IHTMLDocument2 *doc) IHTMLElement_Release(element);
iframes_doc = get_iframe_doc(iframe); - IHTMLIFrameElement_Release(iframe);
cookie = register_cp((IUnknown*)iframes_doc, &IID_IDispatch, (IUnknown*)&div_onclick_disp);
@@ -3215,23 +3214,38 @@ static void test_iframe_connections(IHTMLDocument2 *doc) ok(hres == S_OK, "put_URL failed: %08lx\n", hres); SysFreeString(str);
+ new_doc = get_iframe_doc(iframe); + ok(iface_cmp(new_doc, iframes_doc), "new_doc != iframes_doc\n"); + IHTMLDocument2_Release(new_doc); + SET_EXPECT(iframe_onload); pump_msgs(&called_iframe_onload); CHECK_CALLED(iframe_onload);
+ new_doc = get_iframe_doc(iframe); + todo_wine + ok(iface_cmp(new_doc, iframes_doc), "new_doc != iframes_doc\n"); + str = SysAllocString(L"about:test"); - hres = IHTMLDocument2_put_URL(iframes_doc, str); + hres = IHTMLDocument2_put_URL(new_doc, str); ok(hres == S_OK, "put_URL failed: %08lx\n", hres); + IHTMLDocument2_Release(new_doc); SysFreeString(str);
SET_EXPECT(iframe_onload); pump_msgs(&called_iframe_onload); CHECK_CALLED(iframe_onload); + + new_doc = get_iframe_doc(iframe); + todo_wine + ok(iface_cmp(new_doc, iframes_doc), "new_doc != iframes_doc\n"); + IHTMLDocument2_Release(new_doc); }else { win_skip("Skipping iframe onload tests on IE older than 9.\n"); }
IHTMLDocument2_Release(iframes_doc); + IHTMLIFrameElement_Release(iframe); }
static void test_window_refs(IHTMLDocument2 *doc)
From: Gabriel Ivăncescu gabrielopcode@gmail.com
--- dlls/mshtml/htmldoc.c | 14 +++++++------- dlls/mshtml/tests/events.c | 7 +++++++ 2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 540bbbd1626..9f9791c3b1e 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -5707,12 +5707,6 @@ void detach_document_node(HTMLDocumentNode *doc) { unsigned i;
- if(doc->window) { - HTMLInnerWindow *window = doc->window; - doc->window = NULL; - IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface); - } - while(!list_empty(&doc->plugin_hosts)) detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry));
@@ -5884,14 +5878,20 @@ static void HTMLDocumentNode_traverse(DispatchEx *dispex, nsCycleCollectionTrave static void HTMLDocumentNode_unlink(DispatchEx *dispex) { HTMLDocumentNode *This = impl_from_DispatchEx(dispex); + HTMLInnerWindow *window = This->window; HTMLDOMNode_unlink(dispex);
+ if(window) { + This->window = NULL; + IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface); + } + if(This->dom_document) { release_document_mutation(This); detach_document_node(This); This->dom_document = NULL; This->html_document = NULL; - }else if(This->window) { + }else if(window) { detach_document_node(This); } } diff --git a/dlls/mshtml/tests/events.c b/dlls/mshtml/tests/events.c index 0f0246bfe5c..4b775ceb8b8 100644 --- a/dlls/mshtml/tests/events.c +++ b/dlls/mshtml/tests/events.c @@ -3589,7 +3589,14 @@ static void test_doc_obj(IHTMLDocument2 *doc) ok(hres == S_OK, "get_document failed: %08lx\n", hres); ok(doc_node != doc_node2, "doc_node == doc_node2\n"); IHTMLDocument2_Release(doc_node2); + + hres = IHTMLDocument2_get_parentWindow(doc_node, &window2); + todo_wine + ok(hres == S_OK, "get_parentWindow failed: %08lx\n", hres); + todo_wine + ok(window == window2, "window != window2\n"); IHTMLDocument2_Release(doc_node); + if(hres == S_OK) IHTMLWindow2_Release(window2);
hres = IHTMLWindow2_get_location(window, &location2); ok(hres == S_OK, "get_location failed: %08lx\n", hres);
From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/tests/navigation.js | 48 ++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-)
diff --git a/dlls/mshtml/tests/navigation.js b/dlls/mshtml/tests/navigation.js index ea91a56f1b0..668ee78245b 100644 --- a/dlls/mshtml/tests/navigation.js +++ b/dlls/mshtml/tests/navigation.js @@ -85,6 +85,51 @@ function detached_src_test() { ok(onload_called === false, "called onload too early?"); }
+function detached_iframe_doc() { + document.body.innerHTML = ""; + + var iframe = document.createElement("iframe"); + var origDoc; + + function expect_exception(f, is_todo) { + try { + f(); + todo_wine_if(is_todo).ok(false, "expected exception"); + } catch(e) {} + } + + iframe.onload = guard(function() { + origDoc = iframe.contentWindow.document; + iframe.onload = guard(function () { + var doc = iframe.contentWindow.document; + + ok(/.*blank2.html/.test(doc.URL), "Unexpected iframe doc URL " + doc.URL); + + if (doc.documentMode >= 9) { + try { + origDoc != null; // it's not allowed to even compare detached document + todo_wine. + ok(false, "expected exception"); + } catch(e) {} + } else { + todo_wine. + ok(doc === origDoc, "doc != origDoc"); + } + + expect_exception(function() { origDoc.onclick; }, true); + expect_exception(function() { origDoc.toString; }, true); + expect_exception(function() { origDoc.toString(); }, true); + expect_exception(function() { origDoc.URL; }, true); + + next_test(); + }); + iframe.src = "blank2.html"; + }); + + iframe.src = "blank.html"; + document.body.appendChild(iframe); +} + function init_test_iframe() { var iframe = document.createElement("iframe");
@@ -99,5 +144,6 @@ var tests = [ nav_parent_test, window_navigate_test, window_open_self_test, - detached_src_test + detached_src_test, + detached_iframe_doc ];
From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/htmldoc.c | 10 +++++++++- dlls/mshtml/tests/navigation.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 9f9791c3b1e..504e0b9fc10 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -1108,7 +1108,15 @@ static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
TRACE("(%p)->(%p)\n", iface, p);
- *p = SysAllocString(This->outer_window && This->outer_window->url ? This->outer_window->url : L"about:blank"); + if(This->window && !This->window->base.outer_window) { + WARN("detached document\n"); + return E_FAIL; + } + + if(This->window && This->window->base.outer_window->url) + *p = SysAllocString(This->window->base.outer_window->url); + else + *p = SysAllocString(L"about:blank"); return *p ? S_OK : E_OUTOFMEMORY; }
diff --git a/dlls/mshtml/tests/navigation.js b/dlls/mshtml/tests/navigation.js index 668ee78245b..71bda9ea2a5 100644 --- a/dlls/mshtml/tests/navigation.js +++ b/dlls/mshtml/tests/navigation.js @@ -119,7 +119,7 @@ function detached_iframe_doc() { expect_exception(function() { origDoc.onclick; }, true); expect_exception(function() { origDoc.toString; }, true); expect_exception(function() { origDoc.toString(); }, true); - expect_exception(function() { origDoc.URL; }, true); + expect_exception(function() { origDoc.URL; });
next_test(); });
From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/htmldoc.c | 5 +++-- dlls/mshtml/tests/navigation.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 504e0b9fc10..002d2553e4f 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -1094,12 +1094,13 @@ static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
- if(!This->outer_window) { + if(!This->window || !This->window->base.outer_window) { FIXME("No window available\n"); return E_FAIL; }
- return navigate_url(This->outer_window, v, This->outer_window->uri, BINDING_NAVIGATED); + return navigate_url(This->window->base.outer_window, v, + This->window->base.outer_window->uri, BINDING_NAVIGATED); }
static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p) diff --git a/dlls/mshtml/tests/navigation.js b/dlls/mshtml/tests/navigation.js index 71bda9ea2a5..402d933a54a 100644 --- a/dlls/mshtml/tests/navigation.js +++ b/dlls/mshtml/tests/navigation.js @@ -120,6 +120,7 @@ function detached_iframe_doc() { expect_exception(function() { origDoc.toString; }, true); expect_exception(function() { origDoc.toString(); }, true); expect_exception(function() { origDoc.URL; }); + expect_exception(function() { origDoc.URL = "blank.html"; });
next_test(); });
This merge request was approved by Jacek Caban.