4 https://bugzilla.mozilla.org/show_bug.cgi?id=570341
7 <title>Test for Bug
570341</title>
8 <script 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 (let 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
.firstChild
.remove();
37 for (var p
in moments
) {
40 sequence
.sort(function(a
, b
) {
41 return moments
[a
] - moments
[b
];
43 var table
= document
.createElement("table");
44 node
.appendChild(table
);
45 var row
= document
.createElement("tr");
46 table
.appendChild(row
);
47 var 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 // time constants here are arbitrary, chosen to allow the test to pass
112 var stopPolling
= (win
.performance
&& win
.performance
.loadEventEnd
) ||
113 (seenLoad
&& Date
.now() >= seenLoad
+ 3000) ||
114 Date
.now() >= start
+ 30000;
116 clearInterval(interval
);
118 } else if (win
._testing_evt_load
) {
119 seenLoad
= Date
.now();
126 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=570341">Mozilla Bug
570341</a>
128 <iframe name=
"child0" src=
"navigation/blank.html"></iframe>
130 <button type=
"button" onclick=
"showSequence(document.getElementById('display'))">
133 <div id=
"content" style=
"display: none">
137 <script type=
"application/javascript">
138 SimpleTest.waitForExplicitFinish();