Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/mshtml/htmlanchor.c | 31 +++++++++++++++++++++++++++++-- dlls/mshtml/tests/dom.c | 22 ++++++++++++++++++++-- 2 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmlanchor.c b/dlls/mshtml/htmlanchor.c index a3608abbeb1..a9c5844d440 100644 --- a/dlls/mshtml/htmlanchor.c +++ b/dlls/mshtml/htmlanchor.c @@ -476,8 +476,35 @@ static HRESULT WINAPI HTMLAnchorElement_put_pathname(IHTMLAnchorElement *iface, static HRESULT WINAPI HTMLAnchorElement_get_pathname(IHTMLAnchorElement *iface, BSTR *p) { HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + IUri *uri; + HRESULT hres; + BSTR path; + + TRACE("(%p)->(%p)\n", This, p); + + uri = get_anchor_uri(This); + if(!uri) { + WARN("Could not create IUri\n"); + *p = NULL; + return S_OK; + } + + hres = IUri_GetPath(uri, &path); + IUri_Release(uri); + if(FAILED(hres)) + return hres; + + if(path[0] == '/') { + BSTR str = SysAllocString(path + 1); + SysFreeString(path); + if (!str) + return E_OUTOFMEMORY; + *p = str; + } + else + *p = path; + + return S_OK; }
static HRESULT WINAPI HTMLAnchorElement_put_port(IHTMLAnchorElement *iface, BSTR v) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 03f5c0431ea..2e5fd58cdfb 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -1689,6 +1689,22 @@ static void _test_anchor_port(unsigned line, IUnknown *unk, const WCHAR *port) SysFreeString(str); }
+#define test_anchor_pathname(a,p) _test_anchor_pathname(__LINE__,a,p) +static void _test_anchor_pathname(unsigned line, IUnknown *unk, const WCHAR *pathname) +{ + IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk); + BSTR str; + HRESULT hres; + + hres = IHTMLAnchorElement_get_pathname(anchor, &str); + ok_(__FILE__,line)(hres == S_OK, "get_pathname failed: %08x\n", hres); + if(pathname) + ok_(__FILE__,line)(!lstrcmpW(str, pathname), "pathname = %s, expected %s\n", wine_dbgstr_w(str), wine_dbgstr_w(pathname)); + else + ok_(__FILE__,line)(str == NULL, "pathname = %s, expected NULL\n", wine_dbgstr_w(str)); + SysFreeString(str); +} + #define test_anchor_search(a,h,n) _test_anchor_search(__LINE__,a,h,n) static void _test_anchor_search(unsigned line, IUnknown *elem, const WCHAR *search, BOOL allowbroken) { @@ -9220,12 +9236,14 @@ static void test_elems(IHTMLDocument2 *doc) if(elem) { test_anchor_href((IUnknown*)elem, L"http://test/"); test_anchor_port((IUnknown*)elem, L"80"); + test_anchor_pathname((IUnknown*)elem, L"");
/* Change the href */ - test_anchor_put_href((IUnknown*)elem, L"http://test1:8080/"); - test_anchor_href((IUnknown*)elem, L"http://test1:8080/"); + test_anchor_put_href((IUnknown*)elem, L"http://test1:8080/path"); + test_anchor_href((IUnknown*)elem, L"http://test1:8080/path"); test_anchor_hostname((IUnknown*)elem, L"test1"); test_anchor_port((IUnknown*)elem, L"8080"); + test_anchor_pathname((IUnknown*)elem, L"path");
/* Restore the href */ test_anchor_put_href((IUnknown*)elem, L"http://test/");