mshtml: Rewrite IHTMLLocation::get_pathname on top of IUri.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=37279
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-05-28 17:33:58 +02:00 committed by Alexandre Julliard
parent adeb76bd15
commit e33ce7c538
4 changed files with 39 additions and 10 deletions

View File

@ -459,7 +459,8 @@ static HRESULT WINAPI HTMLLocation_put_pathname(IHTMLLocation *iface, BSTR v)
static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p) static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p)
{ {
HTMLLocation *This = impl_from_IHTMLLocation(iface); HTMLLocation *This = impl_from_IHTMLLocation(iface);
URL_COMPONENTSW url = {sizeof(URL_COMPONENTSW)}; BSTR path;
IUri *uri;
HRESULT hres; HRESULT hres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
@ -467,19 +468,21 @@ static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p)
if(!p) if(!p)
return E_POINTER; return E_POINTER;
url.dwUrlPathLength = 1; if(!(uri = get_uri(This))) {
url.dwExtraInfoLength = 1; FIXME("No current URI\n");
hres = get_url_components(This, &url); return E_NOTIMPL;
}
hres = IUri_GetPath(uri, &path);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(url.dwUrlPathLength && url.lpszUrlPath[0] == '/') if(hres == S_FALSE) {
*p = SysAllocStringLen(url.lpszUrlPath + 1, url.dwUrlPathLength - 1); SysFreeString(path);
else path = NULL;
*p = SysAllocStringLen(url.lpszUrlPath, url.dwUrlPathLength); }
if(!*p) *p = path;
return E_OUTOFMEMORY;
return S_OK; return S_OK;
} }

View File

@ -126,6 +126,22 @@ function test_iframe() {
}); });
} }
function test_iframe_location() {
document.body.innerHTML = '<iframe src="emptyfile"></iframe>'
var iframe = document.body.firstChild;
iframe.onload = function() {
ok(iframe.contentWindow.location.pathname === "/emptyfile",
"path = " + iframe.contentWindow.location.pathname);
iframe.onload = function () {
ok(iframe.contentWindow.location.pathname === "/empty/file",
"path = " + iframe.contentWindow.location.pathname);
next_test();
}
iframe.src = "empty/file";
}
}
function test_anchor() { function test_anchor() {
var iframe = document.body.firstChild; var iframe = document.body.firstChild;
var anchor = document.createElement("a"); var anchor = document.createElement("a");
@ -420,6 +436,7 @@ var tests = [
test_createElementNS, test_createElementNS,
test_head, test_head,
test_iframe, test_iframe,
test_iframe_location,
test_anchor, test_anchor,
test_query_selector, test_query_selector,
test_compare_position, test_compare_position,

View File

@ -240,6 +240,9 @@ static void test_pathname(IHTMLLocation *loc, const struct location_test *test)
hres = IHTMLLocation_get_pathname(loc, &str); hres = IHTMLLocation_get_pathname(loc, &str);
ok(hres == S_OK, "%s: get_pathname failed: 0x%08x\n", test->name, hres); ok(hres == S_OK, "%s: get_pathname failed: 0x%08x\n", test->name, hres);
if(hres == S_OK) if(hres == S_OK)
/* FIXME: We seem to be testing location in a buggy state. Path names do not
* include leading slash, while other tests confirm that it should be there */
todo_wine_if(*test->pathname == '/')
ok(str_eq_wa(str, *test->pathname == '/' ? test->pathname + 1 : test->pathname), ok(str_eq_wa(str, *test->pathname == '/' ? test->pathname + 1 : test->pathname),
"%s: expected retrieved pathname to be L\"%s\", was: %s\n", "%s: expected retrieved pathname to be L\"%s\", was: %s\n",
test->name, test->pathname, wine_dbgstr_w(str)); test->name, test->pathname, wine_dbgstr_w(str));

View File

@ -3087,6 +3087,8 @@ static HRESULT WINAPI ProtocolEx_StartEx(IInternetProtocolEx *iface, IUri *uri,
HRSRC src; HRSRC src;
HRESULT hres; HRESULT hres;
static const WCHAR empty_prefixW[] = {'/','e','m','p','t','y'};
hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &This->bind_info); hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &This->bind_info);
ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres); ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
@ -3121,6 +3123,10 @@ static HRESULT WINAPI ProtocolEx_StartEx(IInternetProtocolEx *iface, IUri *uri,
register_stream(This, query+1); register_stream(This, query+1);
SysFreeString(query); SysFreeString(query);
block = TRUE; block = TRUE;
}else if(SysStringLen(path) >= ARRAY_SIZE(empty_prefixW) && !memcmp(path, empty_prefixW, sizeof(empty_prefixW))) {
static char empty_data[] = " ";
This->data = empty_data;
This->size = strlen(This->data);
}else { }else {
src = FindResourceW(NULL, *path == '/' ? path+1 : path, (const WCHAR*)RT_HTML); src = FindResourceW(NULL, *path == '/' ? path+1 : path, (const WCHAR*)RT_HTML);
ok(src != NULL, "Could not find resource for path %s\n", wine_dbgstr_w(path)); ok(src != NULL, "Could not find resource for path %s\n", wine_dbgstr_w(path));