4 https://bugzilla.mozilla.org/show_bug.cgi?id=570341
7 <title>Test for Bug
570341</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 var start
= Date
.now();
15 var wasEnabled
= true;
17 function collectMoments() {
19 var timing
= (win
.performance
&& win
.performance
.timing
) || {};
20 for (var p
in timing
) {
21 moments
[p
] = timing
[p
];
24 if (p
.substring(0,9) == '_testing_') {
25 moments
[p
.substring(9)] = win
[p
];
28 moments
['evt_unload'] = unload
;
32 function showSequence(node
){
33 while(node
.firstChild
) {
34 node
.removeChild(node
.firstChild
);
37 for (var p
in moments
) {
40 sequence
.sort(function(a
, b
){
41 return moments
[a
] - moments
[b
];
43 table
= document
.createElement('table');
44 node
.appendChild(table
);
45 row
= document
.createElement('tr');
46 table
.appendChild(row
);
47 cell
= document
.createElement('td');
48 row
.appendChild(cell
);
49 cell
.appendChild(document
.createTextNode('start'));
50 cell
= document
.createElement('td');
51 row
.appendChild(cell
);
52 cell
.appendChild(document
.createTextNode(start
));
53 for (var i
= 0; i
< sequence
.length
; ++i
) {
54 var prop
= sequence
[i
];
55 row
= document
.createElement('tr');
56 table
.appendChild(row
);
57 cell
= document
.createElement('td');
58 row
.appendChild(cell
);
59 cell
.appendChild(document
.createTextNode(prop
));
60 cell
= document
.createElement('td');
61 row
.appendChild(cell
);
62 cell
.appendChild(document
.createTextNode(moments
[prop
]));
66 function checkValues(){
69 'window.performance is missing or not accessible for frame');
70 ok(!win
.performance
|| win
.performance
.timing
,
71 'window.performance.timing is missing or not accessible for frame');
75 ['navigationStart', 'unloadEventStart', 'unloadEventEnd'],
76 ['navigationStart', 'fetchStart', 'domainLookupStart', 'domainLookupEnd',
77 'connectStart', 'connectEnd', 'requestStart', 'responseStart', 'responseEnd'],
78 ['responseStart', 'domLoading', 'domInteractive', 'domComplete'],
79 ['domContentLoadedEventStart', 'domContentLoadedEventEnd',
80 'loadEventStart', 'loadEventEnd']
83 for (var i
= 0; i
< sequences
.length
; ++i
) {
84 var seq
= sequences
[i
];
85 for (var j
= 0; j
< seq
.length
; ++j
) {
88 var prevProp
= seq
[j
-1];
89 ok(moments
[prevProp
] <= moments
[prop
],
90 ['Expected ', prevProp
, ' to happen before ', prop
,
91 ', got ', prevProp
, ' = ', moments
[prevProp
],
92 ', ', prop
, ' = ', moments
[prop
]].join(''));
100 window
.onload = function() {
102 win
.addEventListener('unload', function(){
106 win
.addEventListener('load', function (){
107 seenLoad
= Date
.now();
109 frames
[0].location
= 'bug570341_recordevents.html'
110 var interval
= setInterval(function () {
111 var stopPolling
= (win
.performance
&& win
.performance
.loadEventEnd
) ||
112 (seenLoad
&& Date
.now() >= seenLoad
+ 200) ||
113 Date
.now() >= start
+ 5000;
115 clearInterval(interval
);
117 } else if (win
._testing_evt_load
) {
118 seenLoad
= Date
.now();
125 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=570341">Mozilla Bug
570341</a>
127 <iframe name=
"child0" src=
"navigation/blank.html"></iframe>
129 <button type=
"button" onclick=
"showSequence(document.getElementById('display'))">
132 <div id=
"content" style=
"display: none">
136 <script type=
"application/javascript">
137 SimpleTest.waitForExplicitFinish();