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 44166246139..a3608abbeb1 100644 --- a/dlls/mshtml/htmlanchor.c +++ b/dlls/mshtml/htmlanchor.c @@ -490,8 +490,35 @@ static HRESULT WINAPI HTMLAnchorElement_put_port(IHTMLAnchorElement *iface, BSTR static HRESULT WINAPI HTMLAnchorElement_get_port(IHTMLAnchorElement *iface, BSTR *p) { HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + IUri *uri; + HRESULT hres; + DWORD port; + WCHAR buf[11]; + int len; + BSTR str; + + 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_GetPort(uri, &port); + IUri_Release(uri); + if(FAILED(hres)) + return hres; + + len = swprintf(buf, ARRAY_SIZE(buf), L"%u", port); + str = SysAllocStringLen(buf, len); + if (str) + *p = str; + else + hres = E_OUTOFMEMORY; + + return hres; }
static HRESULT WINAPI HTMLAnchorElement_put_protocol(IHTMLAnchorElement *iface, BSTR v) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 9daaf9de51d..03f5c0431ea 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -1673,6 +1673,22 @@ static void _test_anchor_hostname(unsigned line, IUnknown *unk, const WCHAR *hos SysFreeString(str); }
+#define test_anchor_port(a,p) _test_anchor_port(__LINE__,a,p) +static void _test_anchor_port(unsigned line, IUnknown *unk, const WCHAR *port) +{ + IHTMLAnchorElement *anchor = _get_anchor_iface(line, unk); + BSTR str; + HRESULT hres; + + hres = IHTMLAnchorElement_get_port(anchor, &str); + ok_(__FILE__,line)(hres == S_OK, "get_port failed: %08x\n", hres); + if(port) + ok_(__FILE__,line)(!lstrcmpW(str, port), "port = %s, expected %s\n", wine_dbgstr_w(str), wine_dbgstr_w(port)); + else + ok_(__FILE__,line)(str == NULL, "port = %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) { @@ -9203,11 +9219,13 @@ static void test_elems(IHTMLDocument2 *doc) elem = get_elem_by_id(doc, L"a", TRUE); if(elem) { test_anchor_href((IUnknown*)elem, L"http://test/"); + test_anchor_port((IUnknown*)elem, L"80");
/* Change the href */ - test_anchor_put_href((IUnknown*)elem, L"http://test1/"); - test_anchor_href((IUnknown*)elem, L"http://test1/"); + test_anchor_put_href((IUnknown*)elem, L"http://test1:8080/"); + test_anchor_href((IUnknown*)elem, L"http://test1:8080/"); test_anchor_hostname((IUnknown*)elem, L"test1"); + test_anchor_port((IUnknown*)elem, L"8080");
/* Restore the href */ test_anchor_put_href((IUnknown*)elem, L"http://test/");