From: Jacek Caban Subject: mshtml: Return self as a parent of global top window Message-Id: <4F8548EF.2010608@codeweavers.com> Date: Wed, 11 Apr 2012 11:03:43 +0200 --- dlls/mshtml/htmlwindow.c | 10 +++++----- dlls/mshtml/tests/dom.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 4242a77..5f68e6d 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -779,14 +779,14 @@ static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p) static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p) { HTMLWindow *This = impl_from_IHTMLWindow2(iface); + TRACE("(%p)->(%p)\n", This, p); - if(This->parent) { - *p = &This->parent->IHTMLWindow2_iface; - IHTMLWindow2_AddRef(*p); - }else - *p = NULL; + if(!This->parent) + return IHTMLWindow2_get_self(&This->IHTMLWindow2_iface, p); + *p = &This->parent->IHTMLWindow2_iface; + IHTMLWindow2_AddRef(*p); return S_OK; } diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index b951724..4176394 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -4479,7 +4479,7 @@ static void test_body_funs(IHTMLBodyElement *body) static void test_window(IHTMLDocument2 *doc) { - IHTMLWindow2 *window, *window2, *self; + IHTMLWindow2 *window, *window2, *self, *parent; IHTMLDocument2 *doc2 = NULL; IDispatch *disp; IUnknown *unk; @@ -4528,7 +4528,6 @@ static void test_window(IHTMLDocument2 *doc) ok(self == window2, "self != window2\n"); IHTMLWindow2_Release(window2); - IHTMLWindow2_Release(self); disp = NULL; hres = IHTMLDocument2_get_Script(doc, &disp); @@ -4551,6 +4550,14 @@ static void test_window(IHTMLDocument2 *doc) ok(hres == S_OK, "get_opener failed: %08x\n", hres); ok(V_VT(&v) == VT_EMPTY, "V_VT(opener) = %d\n", V_VT(&v)); + parent = NULL; + hres = IHTMLWindow2_get_parent(window, &parent); + ok(hres == S_OK, "get_parent failed: %08x\n", hres); + ok(parent != NULL, "parent == NULL\n"); + ok(parent == self, "parent != window\n"); + IHTMLWindow2_Release(parent); + IHTMLWindow2_Release(self); + test_window_name(window, NULL); set_window_name(window, "test"); test_window_length(window, 0);