Commit 97b509ea authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Implement location props when there's no URI.

parent 9b38ae99
......@@ -1159,6 +1159,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) {
......
......@@ -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);
......
......@@ -40,6 +40,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",
"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);
}
......
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