1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/docshell/test/chrome/bug396649_window.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,122 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 + 1.7 +<window id="396649Test" 1.8 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.9 + width="600" 1.10 + height="600" 1.11 + onload="setTimeout(nextTest,0);" 1.12 + title="bug 396649 test"> 1.13 + 1.14 + <script type="text/javascript" 1.15 + src="chrome://mochikit/content/tests/SimpleTest/specialpowersAPI.js"/> 1.16 + <script type="text/javascript" 1.17 + src="chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/> 1.18 + <script type="text/javascript" 1.19 + src="chrome://mochikit/content/tests/SimpleTest/ChromePowers.js"/> 1.20 + <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" /> 1.21 + <script type="application/javascript" src="docshell_helpers.js" /> 1.22 + <script type="application/javascript"><![CDATA[ 1.23 + 1.24 + // Define the generator-iterator for the tests. 1.25 + var tests = testIterator(); 1.26 + 1.27 + // Maximum number of entries in the bfcache for this session history. 1.28 + // This number is hardcoded in docshell code. In the test, we'll 1.29 + // navigate through enough pages so that we hit one that's been 1.30 + // evicted from the bfcache because it's farther from the current 1.31 + // page than this number. 1.32 + const MAX_BFCACHE_PAGES = 3; 1.33 + 1.34 + //// 1.35 + // Execute the next test in the generator function. 1.36 + // 1.37 + function nextTest() { 1.38 + tests.next(); 1.39 + } 1.40 + 1.41 + //// 1.42 + // Generator function for test steps for bug 396649: Content 1.43 + // viewers should be evicted from bfcache when going back if more 1.44 + // than MAX_BFCACHE_PAGES from the current index. 1.45 + // 1.46 + function testIterator() 1.47 + { 1.48 + // Make sure bfcache is on. 1.49 + enableBFCache(true); 1.50 + 1.51 + // Load enough pages so that the first loaded is eviced from 1.52 + // the bfcache, since it is greater the MAX_BFCACHE_PAGES from 1.53 + // the current position in the session history. Verify all 1.54 + // of the pages are initially stored in the bfcache when 1.55 + // they're unloaded. 1.56 + for (var i = 0; i <= MAX_BFCACHE_PAGES + 1; i++) { 1.57 + doPageNavigation( { 1.58 + uri: "data:text/html,<!DOCTYPE html><html>" + 1.59 + "<head><title>bug396649 page" + i + 1.60 + "</title></head>" + 1.61 + "<body>" + 1.62 + "test page " + i + 1.63 + "</body></html>", 1.64 + eventsToListenFor: ["pageshow", "pagehide"], 1.65 + expectedEvents: [ { type: "pagehide", 1.66 + title: i == 0 ? 1.67 + undefined : "bug396649 page" + (i-1), 1.68 + persisted: true }, 1.69 + { type: "pageshow", 1.70 + title: "bug396649 page" + i } ], 1.71 + onNavComplete: nextTest 1.72 + } ); 1.73 + yield undefined; 1.74 + } 1.75 + 1.76 + // Go back to the first page, one page at a time. The first 1.77 + // MAX_BFCACHE_PAGES pages loaded via back should come from the bfcache, 1.78 + // the last should not, since it should have been evicted during the 1.79 + // previous navigation sequence. Verify all pages are initially stored 1.80 + // in the bfcache when they're unloaded. 1.81 + for (i = MAX_BFCACHE_PAGES + 1; i > 0; i--) { 1.82 + doPageNavigation( { 1.83 + back: true, 1.84 + eventsToListenFor: ["pageshow", "pagehide"], 1.85 + expectedEvents: [ { type: "pagehide", 1.86 + title: "bug396649 page" + i, 1.87 + persisted: true }, 1.88 + { type: "pageshow", 1.89 + title: "bug396649 page" + (i - 1), 1.90 + persisted: i > 1 } ], 1.91 + onNavComplete: nextTest 1.92 + } ); 1.93 + yield undefined; 1.94 + } 1.95 + 1.96 + // Traverse history forward now. Again, the first MAX_BFCACHE_PAGES 1.97 + // pages should come from the bfcache, the last should not, 1.98 + // since it should have been evicted during the backwards 1.99 + // traversal above. Verify all pages are initially stored 1.100 + // in the bfcache when they're unloaded. 1.101 + for (i = 1; i <= MAX_BFCACHE_PAGES + 1; i++) { 1.102 + doPageNavigation( { 1.103 + forward: true, 1.104 + eventsToListenFor: ["pageshow", "pagehide"], 1.105 + expectedEvents: [ { type: "pagehide", 1.106 + title: "bug396649 page" + (i-1), 1.107 + persisted: true }, 1.108 + { type: "pageshow", 1.109 + title: "bug396649 page" + i, 1.110 + persisted: i < MAX_BFCACHE_PAGES + 1 } ], 1.111 + onNavComplete: nextTest 1.112 + } ); 1.113 + yield undefined; 1.114 + } 1.115 + 1.116 + // Tell the framework the test is finished. Include the final 'yield' 1.117 + // statement to prevent a StopIteration exception from being thrown. 1.118 + finish(); 1.119 + yield undefined; 1.120 + } 1.121 + 1.122 + ]]></script> 1.123 + 1.124 + <browser type="content-primary" flex="1" id="content" src="about:blank"/> 1.125 +</window>