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