chromium/third_party/blink/web_tests/fast/loader/document-with-fragment-url-1.html

<script>

if (!sessionStorage.in_document_with_fragment_url_1)
    sessionStorage.in_document_with_fragment_url_1 = true;
else
    delete sessionStorage.in_document_with_fragment_url_1;

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function documentURLHash()
{
    var index = document.URL.lastIndexOf("#");
    if (index == -1)
        return "";
    return document.URL.substring(index);
}

function hashChanged()
{
    alert("Hash changed to " + documentURLHash());
    setTimeout("clickSecondAnchor();", 0);
}

function clickSecondAnchor()
{
    var rect = document.getElementById("secondanchor").getBoundingClientRect();
    eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height / 2);
    eventSender.mouseDown();
    eventSender.mouseUp();
}

function loaded()
{
    if (sessionStorage.in_document_with_fragment_url_1) {
        alert("First load complete.  URL's current hash is " + documentURLHash());
        var rect = document.getElementById("firstanchor").getBoundingClientRect();
        eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height / 2);
        eventSender.mouseDown();
        eventSender.mouseUp();
    } else {
        alert("Second load complete.  URL's current hash is " + documentURLHash());
        if (window.testRunner)
            testRunner.notifyDone();
    }
}

</script>
<body onhashchange="hashChanged();" onload="loaded();">
Click the following link to navigate to #foo on this page.  Then click the second link, which has an empty href and should take you back to the original URL without the #foo.<br>
<a id="firstanchor" href="#foo">Click here to go to #foo</a><br>
<div id="foo"><a id="secondanchor" href="">Click here to return to the original page with the original url</a></div>
</body>