docshell/test/chrome/bug690056_window.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3
michael@0 4 <window id="690056Test"
michael@0 5 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 6 width="600"
michael@0 7 height="600"
michael@0 8 onload="setTimeout(nextTest,0);"
michael@0 9 title="bug 6500056 test">
michael@0 10
michael@0 11 <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
michael@0 12 <script type="application/javascript" src="docshell_helpers.js" />
michael@0 13 <script type="application/javascript"><![CDATA[
michael@0 14 var tests = testIterator();
michael@0 15
michael@0 16 function nextTest() {
michael@0 17 tests.next();
michael@0 18 }
michael@0 19
michael@0 20 // Makes sure that we fire the visibilitychange events
michael@0 21 function testIterator() {
michael@0 22 // Enable bfcache
michael@0 23 enableBFCache(8);
michael@0 24
michael@0 25 // Load something for a start
michael@0 26 doPageNavigation({
michael@0 27 uri: 'data:text/html,<title>initial load</title>',
michael@0 28 onNavComplete: nextTest
michael@0 29 });
michael@0 30 yield undefined;
michael@0 31
michael@0 32 // Now load a new page
michael@0 33 doPageNavigation({
michael@0 34 uri: 'data:text/html,<title>new load</title>',
michael@0 35 eventsToListenFor: [ "pageshow", "pagehide", "visibilitychange" ],
michael@0 36 expectedEvents: [ { type: "pagehide",
michael@0 37 title: "initial load",
michael@0 38 persisted: true },
michael@0 39 { type: "visibilitychange",
michael@0 40 title: "initial load",
michael@0 41 visibilityState: "hidden",
michael@0 42 hidden: true },
michael@0 43 // No visibilitychange events fired for initial pageload
michael@0 44 { type: "pageshow",
michael@0 45 title: "new load",
michael@0 46 persisted: false }, // false on initial load
michael@0 47 ],
michael@0 48 onNavComplete: nextTest
michael@0 49 });
michael@0 50 yield undefined;
michael@0 51
michael@0 52 // Now go back
michael@0 53 doPageNavigation({
michael@0 54 back: true,
michael@0 55 eventsToListenFor: [ "pageshow", "pagehide", "visibilitychange" ],
michael@0 56 expectedEvents: [ { type: "pagehide",
michael@0 57 title: "new load",
michael@0 58 persisted: true },
michael@0 59 { type: "visibilitychange",
michael@0 60 title: "new load",
michael@0 61 visibilityState: "hidden",
michael@0 62 hidden: true },
michael@0 63 { type: "visibilitychange",
michael@0 64 title: "initial load",
michael@0 65 visibilityState: "visible",
michael@0 66 hidden: false },
michael@0 67 { type: "pageshow",
michael@0 68 title: "initial load",
michael@0 69 persisted: true },
michael@0 70 ],
michael@0 71 onNavComplete: nextTest
michael@0 72 });
michael@0 73 yield undefined;
michael@0 74
michael@0 75 // And forward
michael@0 76 doPageNavigation({
michael@0 77 forward: true,
michael@0 78 eventsToListenFor: [ "pageshow", "pagehide", "visibilitychange" ],
michael@0 79 expectedEvents: [ { type: "pagehide",
michael@0 80 title: "initial load",
michael@0 81 persisted: true },
michael@0 82 { type: "visibilitychange",
michael@0 83 title: "initial load",
michael@0 84 visibilityState: "hidden",
michael@0 85 hidden: true },
michael@0 86 { type: "visibilitychange",
michael@0 87 title: "new load",
michael@0 88 visibilityState: "visible",
michael@0 89 hidden: false },
michael@0 90 { type: "pageshow",
michael@0 91 title: "new load",
michael@0 92 persisted: true },
michael@0 93 ],
michael@0 94 onNavComplete: nextTest
michael@0 95 });
michael@0 96 yield undefined;
michael@0 97
michael@0 98 function generateDetector(state, hidden, title, name) {
michael@0 99 var detector = function (event) {
michael@0 100 is(event.target.hidden, hidden,
michael@0 101 name + " hidden value does not match");
michael@0 102 is(event.target.visibilityState, state,
michael@0 103 name + " state value does not match");
michael@0 104 is(event.target.title, title,
michael@0 105 name + " title value does not match");
michael@0 106 document.getElementById("content")
michael@0 107 .removeEventListener("visibilitychange",
michael@0 108 detector,
michael@0 109 true);
michael@0 110 nextTest();
michael@0 111 }
michael@0 112
michael@0 113 document.getElementById("content")
michael@0 114 .addEventListener("visibilitychange", detector, true);
michael@0 115 }
michael@0 116
michael@0 117 generateDetector("hidden", true, "new load", "Going hidden");
michael@0 118
michael@0 119 // Now flip our docshell to not active
michael@0 120 document.getElementById("content").docShellIsActive = false;
michael@0 121 yield undefined;
michael@0 122
michael@0 123 // And navigate back; there should be no visibility state transitions
michael@0 124 doPageNavigation({
michael@0 125 back: true,
michael@0 126 eventsToListenFor: [ "pageshow", "pagehide", "visibilitychange" ],
michael@0 127 expectedEvents: [ { type: "pagehide",
michael@0 128 title: "new load",
michael@0 129 persisted: true },
michael@0 130 { type: "pageshow",
michael@0 131 title: "initial load",
michael@0 132 persisted: true },
michael@0 133 ],
michael@0 134 unexpectedEvents: [ "visibilitychange" ],
michael@0 135 onNavComplete: nextTest
michael@0 136 });
michael@0 137 yield undefined;
michael@0 138
michael@0 139 generateDetector("visible", false, "initial load", "Going visible");
michael@0 140
michael@0 141 // Now set the docshell active again
michael@0 142 document.getElementById("content").docShellIsActive = true;
michael@0 143 yield undefined;
michael@0 144
michael@0 145 // And forward
michael@0 146 doPageNavigation({
michael@0 147 forward: true,
michael@0 148 eventsToListenFor: [ "pageshow", "pagehide", "visibilitychange" ],
michael@0 149 expectedEvents: [ { type: "pagehide",
michael@0 150 title: "initial load",
michael@0 151 persisted: true },
michael@0 152 { type: "visibilitychange",
michael@0 153 title: "initial load",
michael@0 154 visibilityState: "hidden",
michael@0 155 hidden: true },
michael@0 156 { type: "visibilitychange",
michael@0 157 title: "new load",
michael@0 158 visibilityState: "visible",
michael@0 159 hidden: false },
michael@0 160 { type: "pageshow",
michael@0 161 title: "new load",
michael@0 162 persisted: true },
michael@0 163 ],
michael@0 164 onNavComplete: nextTest
michael@0 165 });
michael@0 166 yield undefined;
michael@0 167
michael@0 168 // Tell the framework the test is finished. Include the final 'yield'
michael@0 169 // statement to prevent a StopIteration exception from being thrown.
michael@0 170 finish();
michael@0 171 yield undefined;
michael@0 172 }
michael@0 173 ]]></script>
michael@0 174
michael@0 175 <browser type="content-primary" flex="1" id="content" src="about:blank"/>
michael@0 176 </window>

mercurial