<script>

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

function documentURLHash()
{
    var index = document.URL.lastIndexOf("#");
    if (index == -1)
        return "";
    return document.URL.substring(index);
}
    
function hashChanged()
{
    alert("hashChanged to " + documentURLHash() + " which is interesting because this particular test shouldn't generated a hashchange event");
}

function loaded()
{
    if (sessionStorage.in_document_with_fragment_url_2) {
        alert("First load complete.  URL's current hash is " + documentURLHash());
        var rect = document.getElementById("clickElement").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();">
<div id="foo"><a id="clickElement" href="">Click here to go to the top of the page</a></div><br>
This page should manually be loaded with "#foo" appended to the URL.  When you then click the link, the page should navigate to the url without #foo.
</body>
