Commit 51e6cbdb authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Return NULL for document not attached to window in IHTMLDocument7::get_defaultView.

parent a124117f
......@@ -1627,10 +1627,12 @@ static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG
static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
{
HTMLDocument *This = impl_from_IHTMLDocument2(iface);
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
return IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
hres = IHTMLDocument7_get_defaultView(&This->IHTMLDocument7_iface, p);
return hres == S_OK && !*p ? E_FAIL : hres;
}
static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
......@@ -3248,12 +3250,16 @@ static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdM
static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
{
HTMLDocument *This = impl_from_IHTMLDocument7(iface);
HTMLDocumentNode *This = impl_from_IHTMLDocument7(iface)->doc_node;
TRACE("(%p)->(%p)\n", This, p);
*p = &This->window->base.IHTMLWindow2_iface;
IHTMLWindow2_AddRef(*p);
if(This->window && This->window->base.outer_window) {
*p = &This->window->base.outer_window->base.IHTMLWindow2_iface;
IHTMLWindow2_AddRef(*p);
}else {
*p = NULL;
}
return S_OK;
}
......
......@@ -6924,6 +6924,7 @@ static void test_dom_implementation(IHTMLDocument2 *doc)
IHTMLDocument2 *new_document2;
IHTMLDocument7 *new_document;
IHTMLLocation *location;
IHTMLWindow2 *window;
str = a2bstr("test");
hres = IHTMLDOMImplementation2_createHTMLDocument(dom_implementation2, str, &new_document);
......@@ -6932,9 +6933,20 @@ static void test_dom_implementation(IHTMLDocument2 *doc)
test_disp((IUnknown*)new_document, &DIID_DispHTMLDocument, &CLSID_HTMLDocument, "[object]");
test_ifaces((IUnknown*)new_document, doc_node_iids);
hres = IHTMLDocument7_get_defaultView(new_document, &window);
ok(hres == S_OK, "get_defaultView returned: %08x\n", hres);
ok(!window, "window = %p\n", window);
hres = IHTMLDocument7_get_parentWindow(new_document, &window);
ok(hres == S_OK, "get_parentWindow returned: %08x\n", hres);
ok(!window, "window = %p\n", window);
hres = IHTMLDocument7_QueryInterface(new_document, &IID_IHTMLDocument2, (void**)&new_document2);
ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
hres = IHTMLDocument2_get_parentWindow(new_document2, &window);
ok(hres == E_FAIL, "get_parentWindow returned: %08x\n", hres);
hres = IHTMLDocument2_get_location(new_document2, &location);
ok(hres == E_UNEXPECTED, "get_location returned: %08x\n", hres);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment