2 <script src="../js/resources/js-test-pre.js"></script>
5 <p id="description"></p>
6 <pre id="console"></pre>
8 description('Tests that using location.replace to update the hash of a page preserves it when navigating back to it.');
16 if (window.layoutTestController) {
17 layoutTestController.setCanOpenWindows();
18 layoutTestController.dumpAsText();
19 layoutTestController.waitUntilDone();
22 testWindow = window.open('resources/location-replace-hash-1.html');
24 testFailed('Could not open test window');
30 function onTestWindowNavigation(pageId)
32 // The page ID is put in a global so that the eval() inside of shouldBe can
34 currentPageId = pageId;
37 switch (currentState) {
39 shouldBe('currentPageId', '1');
40 testWindow.location.replace('#foo');
43 shouldBe('currentPageId', '1');
44 shouldBe('testWindow.location.hash', '"#foo"');
45 testWindow.location = 'location-replace-hash-2.html';
48 shouldBe('currentPageId', '2');
49 testWindow.history.back();
52 shouldBe('currentPageId', '1');
53 shouldBe('testWindow.location.hash', '"#foo"');
56 testFailed('Should not be in state ' + currentState);
60 if (currentState == 4) {
61 testPassed('Complete: navigated through all the states');
66 <script src="../js/resources/js-test-post.js"></script>