tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / history / location-replace-hash.html
1 <head>
2 <script src="../js/resources/js-test-pre.js"></script>
3 </head>
4 <body>
5 <p id="description"></p>
6 <pre id="console"></pre>
7 <script>
8 description('Tests that using location.replace to update the hash of a page preserves it when navigating back to it.');
9
10 jsTestIsAsync = true;
11
12 var testWindow;
13
14 onload = function()
15 {
16     if (window.layoutTestController) {
17         layoutTestController.setCanOpenWindows();
18         layoutTestController.dumpAsText();
19         layoutTestController.waitUntilDone();
20     }
21
22     testWindow = window.open('resources/location-replace-hash-1.html');
23     if (!testWindow)
24         testFailed('Could not open test window');
25 }
26
27 var currentState = 0;
28 var currentPageId;
29
30 function onTestWindowNavigation(pageId)
31 {
32     // The page ID is put in a global so that the eval() inside of shouldBe can
33     // see it
34     currentPageId = pageId;
35     currentState++;
36
37     switch (currentState) {
38       case 1:
39           shouldBe('currentPageId', '1');
40           testWindow.location.replace('#foo');
41           break;
42       case 2:
43           shouldBe('currentPageId', '1');
44           shouldBe('testWindow.location.hash', '"#foo"');
45           testWindow.location = 'location-replace-hash-2.html';
46           break;
47       case 3:
48           shouldBe('currentPageId', '2');
49           testWindow.history.back();
50           break;
51       case 4:
52           shouldBe('currentPageId', '1');
53           shouldBe('testWindow.location.hash', '"#foo"');
54           break;
55       default:
56           testFailed('Should not be in state ' + currentState);
57           break;
58     }
59
60     if (currentState == 4) {
61         testPassed('Complete: navigated through all the states');
62         finishJSTest();
63     }
64 }
65 </script>
66 <script src="../js/resources/js-test-post.js"></script>
67 </body>