From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmldoc.c | 3 ++ dlls/mshtml/htmllocation.c | 38 +++++++--------- dlls/mshtml/tests/htmllocation.c | 75 +++++++++++++++++++------------- 3 files changed, 63 insertions(+), 53 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 90c4706abee..66b593920e2 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -1175,6 +1175,9 @@ static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p) return E_NOTIMPL; }
+ if(This->outer_window && !This->outer_window->uri) + return E_FAIL; + nsAString_Init(&nsstr, NULL); nsres = nsIDOMHTMLDocument_GetDomain(This->html_document, &nsstr); if(NS_SUCCEEDED(nsres) && This->outer_window && This->outer_window->uri) { diff --git a/dlls/mshtml/htmllocation.c b/dlls/mshtml/htmllocation.c index 5376b3b8329..066ebb4f5e6 100644 --- a/dlls/mshtml/htmllocation.c +++ b/dlls/mshtml/htmllocation.c @@ -38,12 +38,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
static HRESULT get_url(HTMLLocation *This, const WCHAR **ret) { - if(!This->window || !This->window->base.outer_window || !This->window->base.outer_window->url) { - FIXME("No current URL\n"); - return E_NOTIMPL; - } - - *ret = This->window->base.outer_window->url; + if(!This->window || !This->window->base.outer_window || !This->window->base.outer_window->url) + *ret = L"about:blank"; + else + *ret = This->window->base.outer_window->url; return S_OK; }
@@ -295,10 +293,8 @@ static HRESULT WINAPI HTMLLocation_get_protocol(IHTMLLocation *iface, BSTR *p) if(!p) return E_POINTER;
- if(!(uri = get_uri(This))) { - FIXME("No current URI\n"); - return E_NOTIMPL; - } + if(!(uri = get_uri(This))) + return (*p = SysAllocString(L"about:")) ? S_OK : E_OUTOFMEMORY;
hres = IUri_GetSchemeName(uri, &protocol); if(FAILED(hres)) @@ -388,8 +384,8 @@ static HRESULT WINAPI HTMLLocation_get_hostname(IHTMLLocation *iface, BSTR *p) return E_POINTER;
if(!(uri = get_uri(This))) { - FIXME("No current URI\n"); - return E_NOTIMPL; + *p = NULL; + return S_OK; }
hres = IUri_GetHost(uri, &hostname); @@ -425,8 +421,8 @@ static HRESULT WINAPI HTMLLocation_get_port(IHTMLLocation *iface, BSTR *p) return E_POINTER;
if(!(uri = get_uri(This))) { - FIXME("No current URI\n"); - return E_NOTIMPL; + *p = NULL; + return S_OK; }
hres = IUri_GetPort(uri, &port); @@ -466,10 +462,8 @@ static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p) if(!p) return E_POINTER;
- if(!(uri = get_uri(This))) { - FIXME("No current URI\n"); - return E_NOTIMPL; - } + if(!(uri = get_uri(This))) + return (*p = SysAllocString(L"blank")) ? S_OK : E_OUTOFMEMORY;
hres = IUri_GetPath(uri, &path); if(FAILED(hres)) @@ -504,8 +498,8 @@ static HRESULT WINAPI HTMLLocation_get_search(IHTMLLocation *iface, BSTR *p) return E_POINTER;
if(!(uri = get_uri(This))) { - FIXME("No current URI\n"); - return E_NOTIMPL; + *p = NULL; + return S_OK; }
hres = IUri_GetQuery(uri, &query); @@ -562,8 +556,8 @@ static HRESULT WINAPI HTMLLocation_get_hash(IHTMLLocation *iface, BSTR *p) return E_POINTER;
if(!(uri = get_uri(This))) { - FIXME("No current URI\n"); - return E_NOTIMPL; + *p = NULL; + return S_OK; }
hres = IUri_GetFragment(uri, &hash); diff --git a/dlls/mshtml/tests/htmllocation.c b/dlls/mshtml/tests/htmllocation.c index 0b241085af2..222b9553816 100644 --- a/dlls/mshtml/tests/htmllocation.c +++ b/dlls/mshtml/tests/htmllocation.c @@ -39,6 +39,18 @@ struct location_test { };
static const struct location_test location_tests[] = { + { + "Empty", + NULL, + "about:blank", + "about:", + NULL, + NULL, + NULL, + "blank", + NULL, + NULL + }, { "HTTP", "http://www.winehq.org?search#hash", @@ -187,7 +199,7 @@ static void test_hostname(IHTMLLocation *loc, IHTMLDocument2 *doc, const struct SysFreeString(str);
hres = IHTMLDocument2_get_domain(doc, &str); - ok(hres == S_OK, "%s: get_domain failed: 0x%08lx\n", test->name, hres); + ok(hres == (test->url ? S_OK : E_FAIL), "%s: get_domain failed: 0x%08lx\n", test->name, hres); if(hres == S_OK) ok(str_eq_wa(str, test->hostname ? test->hostname : ""), "%s: expected retrieved domain to be L"%s", was: %s\n", @@ -280,7 +292,7 @@ static void perform_test(const struct location_test* test) WCHAR url[INTERNET_MAX_URL_LENGTH]; HRESULT hres; IBindCtx *bc; - IMoniker *url_mon; + IMoniker *url_mon = NULL; IPersistMoniker *persist_mon; IHTMLDocument2 *doc; IHTMLDocument6 *doc6; @@ -291,12 +303,14 @@ static void perform_test(const struct location_test* test) if(FAILED(hres)) return;
- MultiByteToWideChar(CP_ACP, 0, test->url, -1, url, ARRAY_SIZE(url)); - hres = CreateURLMoniker(NULL, url, &url_mon); - ok(hres == S_OK, "%s: CreateURLMoniker failed: 0x%08lx\n", test->name, hres); - if(FAILED(hres)){ - IBindCtx_Release(bc); - return; + if(test->url) { + MultiByteToWideChar(CP_ACP, 0, test->url, -1, url, ARRAY_SIZE(url)); + hres = CreateURLMoniker(NULL, url, &url_mon); + ok(hres == S_OK, "%s: CreateURLMoniker failed: 0x%08lx\n", test->name, hres); + if(FAILED(hres)){ + IBindCtx_Release(bc); + return; + } }
hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, @@ -307,7 +321,7 @@ static void perform_test(const struct location_test* test) #endif ok(hres == S_OK, "%s: CoCreateInstance failed: 0x%08lx\n", test->name, hres); if(FAILED(hres)){ - IMoniker_Release(url_mon); + if(url_mon) IMoniker_Release(url_mon); IBindCtx_Release(bc); return; } @@ -317,38 +331,39 @@ static void perform_test(const struct location_test* test) IHTMLDocument6_Release(doc6); }else{ win_skip("%s: Could not get IHTMLDocument6, probably too old IE. Requires IE 8+\n", test->name); - IMoniker_Release(url_mon); + if(url_mon) IMoniker_Release(url_mon); IBindCtx_Release(bc); return; }
- hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistMoniker, - (void**)&persist_mon); - ok(hres == S_OK, "%s: IHTMlDocument2_QueryInterface failed: 0x%08lx\n", test->name, hres); - if(FAILED(hres)){ - IHTMLDocument2_Release(doc); - IMoniker_Release(url_mon); - IBindCtx_Release(bc); - return; - } - - hres = IPersistMoniker_Load(persist_mon, FALSE, url_mon, bc, - STGM_SHARE_EXCLUSIVE | STGM_READWRITE); - ok(hres == S_OK, "%s: IPersistMoniker_Load failed: 0x%08lx\n", test->name, hres); - if(FAILED(hres)){ + if(url_mon) { + hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistMoniker, + (void**)&persist_mon); + ok(hres == S_OK, "%s: IHTMlDocument2_QueryInterface failed: 0x%08lx\n", test->name, hres); + if(FAILED(hres)){ + IHTMLDocument2_Release(doc); + IMoniker_Release(url_mon); + IBindCtx_Release(bc); + return; + } + + hres = IPersistMoniker_Load(persist_mon, FALSE, url_mon, bc, + STGM_SHARE_EXCLUSIVE | STGM_READWRITE); + ok(hres == S_OK, "%s: IPersistMoniker_Load failed: 0x%08lx\n", test->name, hres); IPersistMoniker_Release(persist_mon); - IHTMLDocument2_Release(doc); IMoniker_Release(url_mon); - IBindCtx_Release(bc); - return; + + if(FAILED(hres)){ + IHTMLDocument2_Release(doc); + IBindCtx_Release(bc); + return; + } }
hres = IHTMLDocument2_get_location(doc, &location); ok(hres == S_OK, "%s: IHTMLDocument2_get_location failed: 0x%08lx\n", test->name, hres); if(FAILED(hres)){ - IPersistMoniker_Release(persist_mon); IHTMLDocument2_Release(doc); - IMoniker_Release(url_mon); IBindCtx_Release(bc); return; } @@ -363,9 +378,7 @@ static void perform_test(const struct location_test* test) test_hash(location, test);
IHTMLLocation_Release(location); - IPersistMoniker_Release(persist_mon); IHTMLDocument2_Release(doc); - IMoniker_Release(url_mon); IBindCtx_Release(bc); }