diff --git a/dlls/mshtml/htmlanchor.c b/dlls/mshtml/htmlanchor.c index a4f8606fce9..2fa059ce86d 100644 --- a/dlls/mshtml/htmlanchor.c +++ b/dlls/mshtml/htmlanchor.c @@ -440,8 +440,15 @@ static HRESULT WINAPI HTMLAnchorElement_put_host(IHTMLAnchorElement *iface, BSTR static HRESULT WINAPI HTMLAnchorElement_get_host(IHTMLAnchorElement *iface, BSTR *p) { HTMLAnchorElement *This = impl_from_IHTMLAnchorElement(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsAString str; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + /* FIXME: IE always appends port number, even if it's implicit default number */ + nsAString_InitDepend(&str, NULL); + nsres = nsIDOMHTMLAnchorElement_GetHost(This->nsanchor, &str); + return return_nsstr(nsres, &str, p); } static HRESULT WINAPI HTMLAnchorElement_put_hostname(IHTMLAnchorElement *iface, BSTR v) diff --git a/dlls/mshtml/tests/elements.js b/dlls/mshtml/tests/elements.js index 2652c6b412a..7213388e54c 100644 --- a/dlls/mshtml/tests/elements.js +++ b/dlls/mshtml/tests/elements.js @@ -119,6 +119,30 @@ function test_iframe() { }); } +function test_anchor() { + var iframe = document.body.firstChild; + var anchor = document.createElement("a"); + + var anchor_tests = [ + { href: "http://www.winehq.org:123/about", protocol: "http:", host: "www.winehq.org:123" }, + { href: "https://www.winehq.org:123/about", protocol: "https:", host: "www.winehq.org:123" }, + { href: "about:blank", protocol: "about:", host: "" }, + { href: "file:///c:/dir/file.html", protocol: "file:", host: "" }, + { href: "http://www.winehq.org/about", protocol: "http:", host: "www.winehq.org:80", todo_host: true }, + { href: "https://www.winehq.org/about", protocol: "https:", host: "www.winehq.org:443", todo_host: true }, + ]; + + for(var i in anchor_tests) { + var t = anchor_tests[i]; + anchor.href = t.href; + ok(anchor.protocol === t.protocol, "anchor(" + t.href + ").protocol = " + anchor.protocol); + todo_wine_if("todo_host" in t). + ok(anchor.host === t.host, "anchor(" + t.href + ").host = " + anchor.host); + } + + next_test(); +} + function test_getElementsByClassName() { var elems; @@ -273,6 +297,7 @@ var tests = [ test_getElementsByClassName, test_head, test_iframe, + test_anchor, test_query_selector, test_compare_position, test_document_owner,