docshell/test/test_bug570341.html

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=570341
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 570341</title>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 10 <script>
michael@0 11 var start = Date.now();
michael@0 12 var moments = {};
michael@0 13
michael@0 14 var unload = 0;
michael@0 15 var wasEnabled = true;
michael@0 16
michael@0 17 function collectMoments() {
michael@0 18 var win = frames[0];
michael@0 19 var timing = (win.performance && win.performance.timing) || {};
michael@0 20 for (var p in timing) {
michael@0 21 moments[p] = timing[p];
michael@0 22 }
michael@0 23 for (var p in win) {
michael@0 24 if (p.substring(0,9) == '_testing_') {
michael@0 25 moments[p.substring(9)] = win[p];
michael@0 26 }
michael@0 27 }
michael@0 28 moments['evt_unload'] = unload;
michael@0 29 return moments;
michael@0 30 }
michael@0 31
michael@0 32 function showSequence(node){
michael@0 33 while(node.firstChild) {
michael@0 34 node.removeChild(node.firstChild);
michael@0 35 }
michael@0 36 var sequence = [];
michael@0 37 for (var p in moments) {
michael@0 38 sequence.push(p);
michael@0 39 }
michael@0 40 sequence.sort(function(a, b){
michael@0 41 return moments[a] - moments[b];
michael@0 42 });
michael@0 43 table = document.createElement('table');
michael@0 44 node.appendChild(table);
michael@0 45 row = document.createElement('tr');
michael@0 46 table.appendChild(row);
michael@0 47 cell = document.createElement('td');
michael@0 48 row.appendChild(cell);
michael@0 49 cell.appendChild(document.createTextNode('start'));
michael@0 50 cell = document.createElement('td');
michael@0 51 row.appendChild(cell);
michael@0 52 cell.appendChild(document.createTextNode(start));
michael@0 53 for (var i = 0; i < sequence.length; ++i) {
michael@0 54 var prop = sequence[i];
michael@0 55 row = document.createElement('tr');
michael@0 56 table.appendChild(row);
michael@0 57 cell = document.createElement('td');
michael@0 58 row.appendChild(cell);
michael@0 59 cell.appendChild(document.createTextNode(prop));
michael@0 60 cell = document.createElement('td');
michael@0 61 row.appendChild(cell);
michael@0 62 cell.appendChild(document.createTextNode(moments[prop]));
michael@0 63 }
michael@0 64 }
michael@0 65
michael@0 66 function checkValues(){
michael@0 67 var win = frames[0];
michael@0 68 ok(win.performance,
michael@0 69 'window.performance is missing or not accessible for frame');
michael@0 70 ok(!win.performance || win.performance.timing,
michael@0 71 'window.performance.timing is missing or not accessible for frame');
michael@0 72 collectMoments();
michael@0 73
michael@0 74 var sequences = [
michael@0 75 ['navigationStart', 'unloadEventStart', 'unloadEventEnd'],
michael@0 76 ['navigationStart', 'fetchStart', 'domainLookupStart', 'domainLookupEnd',
michael@0 77 'connectStart', 'connectEnd', 'requestStart', 'responseStart', 'responseEnd'],
michael@0 78 ['responseStart', 'domLoading', 'domInteractive', 'domComplete'],
michael@0 79 ['domContentLoadedEventStart', 'domContentLoadedEventEnd',
michael@0 80 'loadEventStart', 'loadEventEnd']
michael@0 81 ]
michael@0 82
michael@0 83 for (var i = 0; i < sequences.length; ++i) {
michael@0 84 var seq = sequences[i];
michael@0 85 for (var j = 0; j < seq.length; ++j) {
michael@0 86 var prop = seq[j];
michael@0 87 if (j > 0) {
michael@0 88 var prevProp = seq[j-1];
michael@0 89 ok(moments[prevProp] <= moments[prop],
michael@0 90 ['Expected ', prevProp, ' to happen before ', prop,
michael@0 91 ', got ', prevProp, ' = ', moments[prevProp],
michael@0 92 ', ', prop, ' = ', moments[prop]].join(''));
michael@0 93 }
michael@0 94 }
michael@0 95 }
michael@0 96
michael@0 97 SimpleTest.finish()
michael@0 98 }
michael@0 99
michael@0 100 window.onload = function() {
michael@0 101 var win = frames[0];
michael@0 102 win.addEventListener('unload', function(){
michael@0 103 unload = Date.now();
michael@0 104 }, true);
michael@0 105 var seenLoad = 0;
michael@0 106 win.addEventListener('load', function (){
michael@0 107 seenLoad = Date.now();
michael@0 108 }, true);
michael@0 109 frames[0].location = 'bug570341_recordevents.html'
michael@0 110 var interval = setInterval(function () {
michael@0 111 var stopPolling = (win.performance && win.performance.loadEventEnd) ||
michael@0 112 (seenLoad && Date.now() >= seenLoad + 200) ||
michael@0 113 Date.now() >= start + 5000;
michael@0 114 if (stopPolling) {
michael@0 115 clearInterval(interval);
michael@0 116 checkValues();
michael@0 117 } else if (win._testing_evt_load) {
michael@0 118 seenLoad = Date.now();
michael@0 119 }
michael@0 120 }, 100);
michael@0 121 }
michael@0 122 </script>
michael@0 123 </head>
michael@0 124 <body>
michael@0 125 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=570341">Mozilla Bug 570341</a>
michael@0 126 <div id="frames">
michael@0 127 <iframe name="child0" src="navigation/blank.html"></iframe>
michael@0 128 </div>
michael@0 129 <button type="button" onclick="showSequence(document.getElementById('display'))">
michael@0 130 Show Events</button>
michael@0 131 <p id="display"></p>
michael@0 132 <div id="content" style="display: none">
michael@0 133
michael@0 134 </div>
michael@0 135 <pre id="test">
michael@0 136 <script type="application/javascript">
michael@0 137 SimpleTest.waitForExplicitFinish();
michael@0 138 </script>
michael@0 139 </pre>
michael@0 140 </body>
michael@0 141 </html>

mercurial