[PATCH v2] mshtml: Implement HTMLAnchorElement_get_pathname().
Hans Leidekker
hans at codeweavers.com
Thu Nov 4 07:08:59 CDT 2021
v2: Keep leading slash and use GetPathname().
I added some more tests which show that for some protocols
IE will prepend a slash if it's not there in the URL. I left
those as todo.
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
dlls/mshtml/htmlanchor.c | 11 +++++++++--
dlls/mshtml/tests/dom.js | 37 ++++++++++++++++++++++++++-----------
2 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/dlls/mshtml/htmlanchor.c b/dlls/mshtml/htmlanchor.c
index a3608abbeb1..b11d39ae07f 100644
--- a/dlls/mshtml/htmlanchor.c
+++ b/dlls/mshtml/htmlanchor.c
@@ -476,8 +476,15 @@ 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;
+ nsAString pathname_str;
+ nsresult nsres;
+
+ TRACE("(%p)->(%p)\n", This, p);
+
+ /* FIXME: IE prepends a slash for some protocols */
+ nsAString_Init(&pathname_str, NULL);
+ nsres = nsIDOMHTMLAnchorElement_GetPathname(This->nsanchor, &pathname_str);
+ return return_nsstr(nsres, &pathname_str, p);
}
static HRESULT WINAPI HTMLAnchorElement_put_port(IHTMLAnchorElement *iface, BSTR v)
diff --git a/dlls/mshtml/tests/dom.js b/dlls/mshtml/tests/dom.js
index 3a2b96a7958..e2be69782fc 100644
--- a/dlls/mshtml/tests/dom.js
+++ b/dlls/mshtml/tests/dom.js
@@ -137,24 +137,39 @@ async_test("iframe_location", function() {
});
sync_test("anchor", function() {
- 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 },
+ { href: "http://www.winehq.org:123/about",
+ protocol: "http:", host: "www.winehq.org:123", path: "/about" },
+ { href: "https://www.winehq.org:123/about",
+ protocol: "https:", host: "www.winehq.org:123", path: "/about" },
+ { href: "about:blank",
+ protocol: "about:", host: "", path: "/blank", todo_pathname: 1 },
+ { href: "unknown:path",
+ protocol: "unknown:", host: "", path: "path" },
+ { href: "ftp:path",
+ protocol: "ftp:", host: "", path: "path" },
+ { href: "mailto:path",
+ protocol: "mailto:", host: "", path: "path" },
+ { href: "ws:path",
+ protocol: "ws:", host: "", path: "path" },
+ { href: "file:path",
+ protocol: "file:", host: "", path: "/path", todo_pathname: 1 },
+ { href: "file:///c:/dir/file.html",
+ protocol: "file:", host: "", path: "/c:/dir/file.html" },
+ { href: "http://www.winehq.org/about",
+ protocol: "http:", host: "www.winehq.org", path: "/about" },
+ { href: "https://www.winehq.org/about",
+ protocol: "https:", host: "www.winehq.org", path: "/about" },
];
for(var i in anchor_tests) {
var t = anchor_tests[i];
- anchor.href = t.href;
+ document.body.innerHTML = '<a href="' + t.href + '">';
+ var anchor = document.body.firstChild;
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);
+ todo_wine_if("todo_pathname" in t).
+ ok(anchor.pathname === t.path, "anchor(" + t.href + ").pathname = " + anchor.pathname);
}
});
--
2.30.2
More information about the wine-devel
mailing list