From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmllocation.c | 25 +++++++++++++++++++++++-- dlls/mshtml/tests/documentmode.js | 12 ++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmllocation.c b/dlls/mshtml/htmllocation.c index 8f7800ff2a3..26365a7a5d0 100644 --- a/dlls/mshtml/htmllocation.c +++ b/dlls/mshtml/htmllocation.c @@ -524,8 +524,29 @@ static HRESULT WINAPI HTMLLocation_get_search(IHTMLLocation *iface, BSTR *p) static HRESULT WINAPI HTMLLocation_put_hash(IHTMLLocation *iface, BSTR v) { HTMLLocation *This = impl_from_IHTMLLocation(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(v)); - return E_NOTIMPL; + WCHAR *hash = v; + HRESULT hres; + + TRACE("(%p)->(%s)\n", This, debugstr_w(v)); + + if(!This->window || !This->window->base.outer_window) { + FIXME("No window available\n"); + return E_FAIL; + } + + if(hash[0] != '#') { + unsigned size = (1 /* # */ + wcslen(v) + 1) * sizeof(WCHAR); + if(!(hash = heap_alloc(size))) + return E_OUTOFMEMORY; + hash[0] = '#'; + memcpy(hash + 1, v, size - sizeof(WCHAR)); + } + + hres = navigate_url(This->window->base.outer_window, hash, This->window->base.outer_window->uri, BINDING_NAVIGATED); + + if(hash != v) + heap_free(hash); + return hres; }
static HRESULT WINAPI HTMLLocation_get_hash(IHTMLLocation *iface, BSTR *p) diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 92f30f8b7e9..5da89349d6d 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -895,6 +895,18 @@ async_test("script_load", function() { external.writeStream("simple", "ready_states += 'exec,';"); });
+sync_test("location", function() { + document.body.innerHTML = '<a name="testanchor">test</a>'; + + ok(location.hash === "", "initial location.hash = " + location.hash); + location.hash = "TestAnchor"; + ok(location.hash === "#TestAnchor", "location.hash after set to TestAnchor = " + location.hash); + location.hash = "##foo"; + ok(location.hash === "##foo", "location.hash after set to ##foo = " + location.hash); + location.hash = "#testanchor"; + ok(location.hash === "#testanchor", "location.hash after set to #testanchor = " + location.hash); +}); + sync_test("navigator", function() { var v = document.documentMode, re; var app = navigator.appVersion;