tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / history / history-subframe-with-name.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('Verifies that we can go back and forward from the top level of a frame set where a window changes its name after the initial load.');
9
10 var testWindow;
11
12 onload = function()
13 {
14     if (window.layoutTestController) {
15         layoutTestController.setCanOpenWindows();
16         layoutTestController.dumpAsText();
17         layoutTestController.waitUntilDone();
18     }
19     
20     testWindow = window.open('resources/history-subframe-with-name-container.html');
21     if (!testWindow)
22         testFailed('Could not open test window');    
23 }
24
25 var State = {
26   0: 'INITIAL',
27   1: 'FRAME_LOADED_INITIAL',
28   2: 'FRAME_LOADED_NAV',
29   3: 'FRAME_LOADED_BACK',
30   4: 'FRAME_LOADED_FORWARD'
31 };
32
33 var currentState = 0;
34 var currentPageId;
35
36 function onFrameLoaded(pageId)
37 {
38     // The page ID is put in a global so that the eval() inside of shouldBe can
39     // see it
40     currentPageId = pageId;    
41     currentState++;
42     
43     switch (currentState) {
44       case 1:
45           shouldBe('2', 'currentPageId');
46           break;
47       case 2:
48           shouldBe('3', 'currentPageId');
49           testWindow.history.back();
50           break;
51       case 3:
52           shouldBe('2', 'currentPageId');
53           testWindow.history.forward();
54           break;
55       case 4:
56           shouldBe('3', 'currentPageId');
57           break;
58       default:
59           testFailed('Should not be in state ' + currentState);
60           break;
61     }
62     
63     if (currentState == 4) {
64         testPassed('Complete: navigated through all the states');
65         if (window.layoutTestController)
66             layoutTestController.notifyDone();
67     }
68 }
69 </script>
70 </body>