Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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="396649Test" |
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 396649 test"> |
michael@0 | 10 | |
michael@0 | 11 | <script type="text/javascript" |
michael@0 | 12 | src="chrome://mochikit/content/tests/SimpleTest/specialpowersAPI.js"/> |
michael@0 | 13 | <script type="text/javascript" |
michael@0 | 14 | src="chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/> |
michael@0 | 15 | <script type="text/javascript" |
michael@0 | 16 | src="chrome://mochikit/content/tests/SimpleTest/ChromePowers.js"/> |
michael@0 | 17 | <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" /> |
michael@0 | 18 | <script type="application/javascript" src="docshell_helpers.js" /> |
michael@0 | 19 | <script type="application/javascript"><![CDATA[ |
michael@0 | 20 | |
michael@0 | 21 | // Define the generator-iterator for the tests. |
michael@0 | 22 | var tests = testIterator(); |
michael@0 | 23 | |
michael@0 | 24 | // Maximum number of entries in the bfcache for this session history. |
michael@0 | 25 | // This number is hardcoded in docshell code. In the test, we'll |
michael@0 | 26 | // navigate through enough pages so that we hit one that's been |
michael@0 | 27 | // evicted from the bfcache because it's farther from the current |
michael@0 | 28 | // page than this number. |
michael@0 | 29 | const MAX_BFCACHE_PAGES = 3; |
michael@0 | 30 | |
michael@0 | 31 | //// |
michael@0 | 32 | // Execute the next test in the generator function. |
michael@0 | 33 | // |
michael@0 | 34 | function nextTest() { |
michael@0 | 35 | tests.next(); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | //// |
michael@0 | 39 | // Generator function for test steps for bug 396649: Content |
michael@0 | 40 | // viewers should be evicted from bfcache when going back if more |
michael@0 | 41 | // than MAX_BFCACHE_PAGES from the current index. |
michael@0 | 42 | // |
michael@0 | 43 | function testIterator() |
michael@0 | 44 | { |
michael@0 | 45 | // Make sure bfcache is on. |
michael@0 | 46 | enableBFCache(true); |
michael@0 | 47 | |
michael@0 | 48 | // Load enough pages so that the first loaded is eviced from |
michael@0 | 49 | // the bfcache, since it is greater the MAX_BFCACHE_PAGES from |
michael@0 | 50 | // the current position in the session history. Verify all |
michael@0 | 51 | // of the pages are initially stored in the bfcache when |
michael@0 | 52 | // they're unloaded. |
michael@0 | 53 | for (var i = 0; i <= MAX_BFCACHE_PAGES + 1; i++) { |
michael@0 | 54 | doPageNavigation( { |
michael@0 | 55 | uri: "data:text/html,<!DOCTYPE html><html>" + |
michael@0 | 56 | "<head><title>bug396649 page" + i + |
michael@0 | 57 | "</title></head>" + |
michael@0 | 58 | "<body>" + |
michael@0 | 59 | "test page " + i + |
michael@0 | 60 | "</body></html>", |
michael@0 | 61 | eventsToListenFor: ["pageshow", "pagehide"], |
michael@0 | 62 | expectedEvents: [ { type: "pagehide", |
michael@0 | 63 | title: i == 0 ? |
michael@0 | 64 | undefined : "bug396649 page" + (i-1), |
michael@0 | 65 | persisted: true }, |
michael@0 | 66 | { type: "pageshow", |
michael@0 | 67 | title: "bug396649 page" + i } ], |
michael@0 | 68 | onNavComplete: nextTest |
michael@0 | 69 | } ); |
michael@0 | 70 | yield undefined; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | // Go back to the first page, one page at a time. The first |
michael@0 | 74 | // MAX_BFCACHE_PAGES pages loaded via back should come from the bfcache, |
michael@0 | 75 | // the last should not, since it should have been evicted during the |
michael@0 | 76 | // previous navigation sequence. Verify all pages are initially stored |
michael@0 | 77 | // in the bfcache when they're unloaded. |
michael@0 | 78 | for (i = MAX_BFCACHE_PAGES + 1; i > 0; i--) { |
michael@0 | 79 | doPageNavigation( { |
michael@0 | 80 | back: true, |
michael@0 | 81 | eventsToListenFor: ["pageshow", "pagehide"], |
michael@0 | 82 | expectedEvents: [ { type: "pagehide", |
michael@0 | 83 | title: "bug396649 page" + i, |
michael@0 | 84 | persisted: true }, |
michael@0 | 85 | { type: "pageshow", |
michael@0 | 86 | title: "bug396649 page" + (i - 1), |
michael@0 | 87 | persisted: i > 1 } ], |
michael@0 | 88 | onNavComplete: nextTest |
michael@0 | 89 | } ); |
michael@0 | 90 | yield undefined; |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | // Traverse history forward now. Again, the first MAX_BFCACHE_PAGES |
michael@0 | 94 | // pages should come from the bfcache, the last should not, |
michael@0 | 95 | // since it should have been evicted during the backwards |
michael@0 | 96 | // traversal above. Verify all pages are initially stored |
michael@0 | 97 | // in the bfcache when they're unloaded. |
michael@0 | 98 | for (i = 1; i <= MAX_BFCACHE_PAGES + 1; i++) { |
michael@0 | 99 | doPageNavigation( { |
michael@0 | 100 | forward: true, |
michael@0 | 101 | eventsToListenFor: ["pageshow", "pagehide"], |
michael@0 | 102 | expectedEvents: [ { type: "pagehide", |
michael@0 | 103 | title: "bug396649 page" + (i-1), |
michael@0 | 104 | persisted: true }, |
michael@0 | 105 | { type: "pageshow", |
michael@0 | 106 | title: "bug396649 page" + i, |
michael@0 | 107 | persisted: i < MAX_BFCACHE_PAGES + 1 } ], |
michael@0 | 108 | onNavComplete: nextTest |
michael@0 | 109 | } ); |
michael@0 | 110 | yield undefined; |
michael@0 | 111 | } |
michael@0 | 112 | |
michael@0 | 113 | // Tell the framework the test is finished. Include the final 'yield' |
michael@0 | 114 | // statement to prevent a StopIteration exception from being thrown. |
michael@0 | 115 | finish(); |
michael@0 | 116 | yield undefined; |
michael@0 | 117 | } |
michael@0 | 118 | |
michael@0 | 119 | ]]></script> |
michael@0 | 120 | |
michael@0 | 121 | <browser type="content-primary" flex="1" id="content" src="about:blank"/> |
michael@0 | 122 | </window> |