4 https://bugzilla.mozilla.org/show_bug.cgi?id=668513
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"/>
11 if (navigator
.platform
.startsWith("Linux")) {
12 SimpleTest
.expectAssertions(0, 1);
15 function onload_test()
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
28 // do this with a timeout to see the visuals of the navigations.
29 setTimeout("nav_frame();", 100);
35 var navigation_frame
= frames
[0];
36 var navigation
= navigation_frame
.performance
.navigation
;
41 navigation_frame
.location
.href
= 'bug570341_recordevents.html';
47 is(navigation
.type
, navigation
.TYPE_NAVIGATE
,
48 'Expected window.performance.navigation.type == TYPE_NAVIGATE');
49 navigation_frame
.history
.back();
55 is(navigation
.type
, navigation
.TYPE_BACK_FORWARD
,
56 'Expected window.performance.navigation.type == TYPE_BACK_FORWARD');
58 navigation_frame
.history
.forward();
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';
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
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(''));
103 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=668513">Mozilla Bug
668513</a>
105 <iframe name=
"child0" onload=
"onload_test();" src=
"navigation/blank.html"></iframe>
108 <div id=
"content" style=
"display: none">
112 <script type=
"application/javascript">
113 SimpleTest.waitForExplicitFinish();