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/");
Hi Hans,
On 11/2/21 3:27 PM, Hans Leidekker wrote:
- if(path[0] == '/') {
BSTR str = SysAllocString(path + 1);
SysFreeString(path);
if (!str)
return E_OUTOFMEMORY;
*p = str;
- }
We had problems with this in the past already, see e33ce7c5385 for example. Spec says that we should include leading slash in the result. IE does that in some cases, but doesn't in other cases. It's not clear to me what exactly triggers broken behaviour, but your tests happen to fall into this. I attached tests that check for proper results. I'd rather start with implement proper behaviour (which is more likely to be expected by scripts) and try to implement 'broken' behaviour only if we have a strong reason.
Also, if possible, using Gecko's GetPathname would be preferable (unless it doesn't do what we need for some reason).
Thanks,
Jacek
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=101177
Your paranoid android.
=== w8adm (32 bit report) ===
mshtml: events.c:1089: Test failed: unexpected call img_onerror events: Timeout
=== w10pro64_ja (64 bit report) ===
mshtml: htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS htmldoc.c:350: Test failed: expected Exec_SETTITLE htmldoc.c:2859: Test failed: unexpected call Exec_SETTITLE
=== w7u_adm (32 bit report) ===
mshtml: script.c:624: Test failed: L"/index.html?es5.js:date_now: unexpected Date.now() result 1635874086624 expected 1635874086687"
=== debiant2 (32 bit report) ===
mshtml: script.c:624: Test failed: L"/index.html?dom.js:anchor: Got exception "
=== debiant2 (32 bit Arabic:Morocco report) ===
mshtml: script.c:624: Test failed: L"/index.html?dom.js:anchor: Got exception "
=== debiant2 (32 bit German report) ===
mshtml: script.c:624: Test failed: L"/index.html?dom.js:anchor: Got exception "
=== debiant2 (32 bit French report) ===
mshtml: script.c:624: Test failed: L"/index.html?dom.js:anchor: Got exception "
=== debiant2 (32 bit Hebrew:Israel report) ===
mshtml: script.c:624: Test failed: L"/index.html?dom.js:anchor: Got exception "
=== debiant2 (32 bit Hindi:India report) ===
mshtml: script.c:624: Test failed: L"/index.html?dom.js:anchor: Got exception "
=== debiant2 (32 bit Japanese:Japan report) ===
mshtml: script.c:624: Test failed: L"/index.html?dom.js:anchor: Got exception "
=== debiant2 (32 bit Chinese:China report) ===
mshtml: script.c:624: Test failed: L"/index.html?dom.js:anchor: Got exception "
=== debiant2 (32 bit WoW report) ===
mshtml: script.c:624: Test failed: L"/index.html?dom.js:anchor: Got exception "
=== debiant2 (64 bit WoW report) ===
mshtml: script.c:624: Test failed: L"/index.html?dom.js:anchor: Got exception "