3 if (!sessionStorage.in_document_with_fragment_url_1)
4 sessionStorage.in_document_with_fragment_url_1 = true;
6 delete sessionStorage.in_document_with_fragment_url_1;
8 if (window.layoutTestController) {
9 layoutTestController.dumpAsText();
10 layoutTestController.waitUntilDone();
13 function documentURLHash()
15 var index = document.URL.lastIndexOf("#");
18 return document.URL.substring(index);
21 function hashChanged()
23 alert("Hash changed to " + documentURLHash());
24 setTimeout("clickSecondAnchor();", 0);
27 function clickSecondAnchor()
29 var rect = document.getElementById("secondanchor").getBoundingClientRect();
30 eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height / 2);
31 eventSender.mouseDown();
32 eventSender.mouseUp();
37 if (sessionStorage.in_document_with_fragment_url_1) {
38 alert("First load complete. URL's current hash is " + documentURLHash());
39 var rect = document.getElementById("firstanchor").getBoundingClientRect();
40 eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height / 2);
41 eventSender.mouseDown();
42 eventSender.mouseUp();
44 alert("Second load complete. URL's current hash is " + documentURLHash());
45 if (window.layoutTestController)
46 layoutTestController.notifyDone();
51 <body onhashchange="hashChanged();" onload="loaded();">
52 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>
53 <a id="firstanchor" href="#foo">Click here to go to #foo</a><br>
54 <div id="foo"><a id="secondanchor" href="">Click here to return to the original page with the original url</a></div>