Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / docshell / test / file_bug668513.html
blob1e43a51e006676114203327968dfa0d5b3689a7c
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Test file for Bug 668513</title>
5 <script>
6 var SimpleTest = opener.SimpleTest;
7 var ok = opener.ok;
8 var is = opener.is;
10 function finish() {
11 SimpleTest.finish();
12 close();
15 function onload_test()
17 var win = frames[0];
18 ok(win.performance, 'Window.performance should be defined');
19 ok(win.performance.navigation, 'Window.performance.navigation should be defined');
20 var navigation = win.performance && win.performance.navigation;
21 if (navigation === undefined)
23 // avoid script errors
24 finish();
25 return;
28 // do this with a timeout to see the visuals of the navigations.
29 setTimeout("nav_frame();", 100);
32 var step = 1;
33 function nav_frame()
35 var navigation_frame = frames[0];
36 var navigation = navigation_frame.performance.navigation;
37 switch (step)
39 case 1:
41 navigation_frame.location.href = 'bug570341_recordevents.html';
42 step++;
43 break;
45 case 2:
47 is(navigation.type, navigation.TYPE_NAVIGATE,
48 'Expected window.performance.navigation.type == TYPE_NAVIGATE');
49 navigation_frame.history.back();
50 step++;
51 break;
53 case 3:
55 is(navigation.type, navigation.TYPE_BACK_FORWARD,
56 'Expected window.performance.navigation.type == TYPE_BACK_FORWARD');
57 step++;
58 navigation_frame.history.forward();
59 break;
61 case 4:
63 is(navigation.type, navigation.TYPE_BACK_FORWARD,
64 'Expected window.performance.navigation.type == TYPE_BACK_FORWARD');
65 navigation_frame.location.href = 'bug668513_redirect.html';
66 step++;
67 break;
69 case 5:
71 is(navigation.type, navigation.TYPE_NAVIGATE,
72 'Expected timing.navigation.type as TYPE_NAVIGATE');
73 is(navigation.redirectCount, 1,
74 'Expected navigation.redirectCount == 1 on an server redirected navigation');
76 var timing = navigation_frame.performance && navigation_frame.performance.timing;
77 if (timing === undefined)
79 // avoid script errors
80 finish();
81 break;
83 ok(timing.navigationStart > 0, 'navigationStart should be > 0');
84 sequence = ['navigationStart', 'redirectStart', 'redirectEnd', 'fetchStart'];
85 for (var j = 1; j < sequence.length; ++j) {
86 var prop = sequence[j];
87 var prevProp = sequence[j-1];
88 ok(timing[prevProp] <= timing[prop],
89 ['Expected ', prevProp, ' to happen before ', prop,
90 ', got ', prevProp, ' = ', timing[prevProp],
91 ', ', prop, ' = ', timing[prop]].join(''));
93 step++;
94 finish();
96 default:
97 break;
100 </script>
101 </head>
102 <body>
103 <div id="frames">
104 <iframe name="child0" onload="onload_test();" src="navigation/blank.html"></iframe>
105 </div>
106 </body>
107 </html>