Commit e33ce7c5 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

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

parent adeb76bd
......@@ -459,7 +459,8 @@ static HRESULT WINAPI HTMLLocation_put_pathname(IHTMLLocation *iface, BSTR v)
static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p)
{
HTMLLocation *This = impl_from_IHTMLLocation(iface);
URL_COMPONENTSW url = {sizeof(URL_COMPONENTSW)};
BSTR path;
IUri *uri;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
......@@ -467,19 +468,21 @@ static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p)
if(!p)
return E_POINTER;
url.dwUrlPathLength = 1;
url.dwExtraInfoLength = 1;
hres = get_url_components(This, &url);
if(!(uri = get_uri(This))) {
FIXME("No current URI\n");
return E_NOTIMPL;
}
hres = IUri_GetPath(uri, &path);
if(FAILED(hres))
return hres;
if(url.dwUrlPathLength && url.lpszUrlPath[0] == '/')
*p = SysAllocStringLen(url.lpszUrlPath + 1, url.dwUrlPathLength - 1);
else
*p = SysAllocStringLen(url.lpszUrlPath, url.dwUrlPathLength);
if(hres == S_FALSE) {
SysFreeString(path);
path = NULL;
}
if(!*p)
return E_OUTOFMEMORY;
*p = path;
return S_OK;
}
......
......@@ -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() {
var iframe = document.body.firstChild;
var anchor = document.createElement("a");
......@@ -420,6 +436,7 @@ var tests = [
test_createElementNS,
test_head,
test_iframe,
test_iframe_location,
test_anchor,
test_query_selector,
test_compare_position,
......
......@@ -240,6 +240,9 @@ static void test_pathname(IHTMLLocation *loc, const struct location_test *test)
hres = IHTMLLocation_get_pathname(loc, &str);
ok(hres == S_OK, "%s: get_pathname failed: 0x%08x\n", test->name, hres);
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),
"%s: expected retrieved pathname to be L\"%s\", was: %s\n",
test->name, test->pathname, wine_dbgstr_w(str));
......
......@@ -3087,6 +3087,8 @@ static HRESULT WINAPI ProtocolEx_StartEx(IInternetProtocolEx *iface, IUri *uri,
HRSRC src;
HRESULT hres;
static const WCHAR empty_prefixW[] = {'/','e','m','p','t','y'};
hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &This->bind_info);
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);
SysFreeString(query);
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 {
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));
......
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