2011-02-04 Charlie Reis <creis@chromium.org>
[WebKit.git] / LayoutTests / fast / history / history-back-forward-within-subframe-hash.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <link rel="stylesheet" href="../js/resources/js-test-style.css">
5   <script src="../js/resources/js-test-pre.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <pre id="console"></pre>
10
11 <iframe src="resources/subframe.html" id="iframe1"></iframe>
12
13 <script>
14 description('Ensures that repeated back and forward work for frame hash navigations.');
15
16 var frame = document.getElementById("iframe1").contentWindow;
17 onload = function()
18 {
19     // Make sure that we can generate history entries
20     setTimeout(runTest, 0);
21 }
22
23 // 1. Navigate to hash "#foo".
24 // 2. Go back to hash "".
25 // 3. Go forward to hash "#foo".
26 function runTest()
27 {
28     frame.location.hash = "#foo";
29 }
30
31 frame.onhashchange = function()
32 {
33     if (frame.location.hash == "#foo") {
34         if (!window.localStorage.beenHere) {
35             window.localStorage.beenHere = true;
36             debug("First visit to foo.");
37             history.back();
38         } else {
39             delete window.localStorage.beenHere;
40             debug("Gone forward.");
41             finishJSTest();
42         }
43     }
44     if (frame.location.hash == "") {
45         debug("Gone back.");
46         history.forward();
47     }
48 }
49
50 var successfullyParsed = true;
51 var jsTestIsAsync = true;
52 </script>  
53 <script src="../js/resources/js-test-post.js"></script>
54 </body>
55 </html>