Bug 894150 - Test.
[gecko.git] / docshell / test / test_bug668513.html
blobca23c0c4fc87f80cfd5c5ede49425a73ff741704
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=668513
5 -->
6 <head>
7 <title>Test for Bug 668513</title>
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 <script>
11 if (navigator.platform.startsWith("Linux")) {
12 SimpleTest.expectAssertions(0, 1);
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 SimpleTest.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 SimpleTest.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 SimpleTest.finish();
96 default:
97 break;
100 </script>
101 </head>
102 <body>
103 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=668513">Mozilla Bug 668513</a>
104 <div id="frames">
105 <iframe name="child0" onload="onload_test();" src="navigation/blank.html"></iframe>
106 </div>
107 <p id="display"></p>
108 <div id="content" style="display: none">
110 </div>
111 <pre id="test">
112 <script type="application/javascript">
113 SimpleTest.waitForExplicitFinish();
114 </script>
115 </pre>
116 </body>
117 </html>