|
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; |
|
9 |
|
10 function finish() { |
|
11 SimpleTest.finish(); |
|
12 close(); |
|
13 } |
|
14 |
|
15 function onload_test() |
|
16 { |
|
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) |
|
22 { |
|
23 // avoid script errors |
|
24 finish(); |
|
25 return; |
|
26 } |
|
27 |
|
28 // do this with a timeout to see the visuals of the navigations. |
|
29 setTimeout("nav_frame();", 100); |
|
30 } |
|
31 |
|
32 var step = 1; |
|
33 function nav_frame() |
|
34 { |
|
35 var navigation_frame = frames[0]; |
|
36 var navigation = navigation_frame.performance.navigation; |
|
37 switch (step) |
|
38 { |
|
39 case 1: |
|
40 { |
|
41 navigation_frame.location.href = 'bug570341_recordevents.html'; |
|
42 step++; |
|
43 break; |
|
44 } |
|
45 case 2: |
|
46 { |
|
47 is(navigation.type, navigation.TYPE_NAVIGATE, |
|
48 'Expected window.performance.navigation.type == TYPE_NAVIGATE'); |
|
49 navigation_frame.history.back(); |
|
50 step++; |
|
51 break; |
|
52 } |
|
53 case 3: |
|
54 { |
|
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; |
|
60 } |
|
61 case 4: |
|
62 { |
|
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; |
|
68 } |
|
69 case 5: |
|
70 { |
|
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'); |
|
75 |
|
76 var timing = navigation_frame.performance && navigation_frame.performance.timing; |
|
77 if (timing === undefined) |
|
78 { |
|
79 // avoid script errors |
|
80 finish(); |
|
81 break; |
|
82 } |
|
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('')); |
|
92 } |
|
93 step++; |
|
94 finish(); |
|
95 } |
|
96 default: |
|
97 break; |
|
98 } |
|
99 } |
|
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> |