file_bug514732_window.xhtml (3336B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> 3 4 <window id="514732Test" 5 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 6 width="600" 7 height="600" 8 onload="startTests();" 9 title="bug 514732 test"> 10 11 <script type="application/javascript"><![CDATA[ 12 window.opener = window.arguments[0]; 13 ]]></script> 14 15 <script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js" /> 16 <script src="chrome://mochikit/content/tests/SimpleTest/docshell_helpers.js"> 17 </script> 18 19 <script type="application/javascript"><![CDATA[ 20 21 // Define the generator-iterator for the tests. 22 var tests = testIterator(); 23 24 //// 25 // Execute the next test in the generator function. 26 // 27 function nextTest() { 28 tests.next(); 29 } 30 31 //// 32 // Generator function for test steps for bug 514732. The MozScrolledAreaChanged 33 // should be fired when a page is restored from the bfcache as though it had 34 // reloaded. 35 // 36 function* testIterator() { 37 // Make sure bfcache is on. 38 enableBFCache(true); 39 40 41 // Load a wide and tall page, and then another. 42 for (var i = 0; i < 2; ++i) { 43 doPageNavigation( { 44 uri: "data:text/html,<!DOCTYPE html><html>" + 45 "<head><title>bug 514732 bfcache test page " + i + "</title></head>" + 46 "<body>" + 47 '<div style="position: absolute; left: 10000px; top: 10000px; width: 500px; height: 500px;">' + 48 "</body></html>", 49 eventsToListenFor: ["MozScrolledAreaChanged"], 50 expectedEvents: [ { type: "MozScrolledAreaChanged" } ], 51 onNavComplete: nextTest 52 } ); 53 yield; 54 } 55 56 // Navigate back to the first page. Don't test for width and height 57 // yet, just make sure we get an event. 58 doPageNavigation( { 59 back: true, 60 eventsToListenFor: ["MozScrolledAreaChanged"], 61 expectedEvents: [ { type: "MozScrolledAreaChanged" } ], 62 onNavComplete: nextTest 63 } ); 64 yield; 65 66 // Navigate forth to our wide and tall page, this time testing for 67 // width and height on the event. 68 doPageNavigation( { 69 forward: true, 70 eventsToListenFor: ["MozScrolledAreaChanged"], 71 expectedEvents: [ { type: "MozScrolledAreaChanged" } ], 72 onNavComplete: nextTest 73 } ); 74 yield; 75 76 finish(); 77 } 78 79 async function startTests() { 80 await new Promise(r => { 81 requestAnimationFrame(() => requestAnimationFrame(r)); 82 }); 83 84 // Flush layout in outer and inner documents (in that order), to be sure 85 // our TestWindow's initial about:blank document doesn't have any 86 // pending reflows. (If we leave these pending reflows un-flushed, then 87 // they might happen after we've set up our MozScrolledAreaChanged 88 // event-listener; and that would confuse our test logic and lead to 89 // timeouts and test-failures.) 90 document.documentElement.offsetHeight; 91 TestWindow.getDocument().documentElement.offsetHeight; 92 93 // Kick off the first test via the generator-iterator. 94 nextTest(); 95 } 96 ]]></script> 97 98 <browser type="content" primary="true" flex="1" id="content" src="about:blank"/> 99 </window>