docshell/test/chrome/bug303267_window.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

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="303267Test"
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 303267 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
michael@0 15 // Define the generator-iterator for the tests.
michael@0 16 var tests = testIterator();
michael@0 17
michael@0 18 ////
michael@0 19 // Execute the next test in the generator function.
michael@0 20 //
michael@0 21 function nextTest() {
michael@0 22 tests.next();
michael@0 23 }
michael@0 24
michael@0 25 ////
michael@0 26 // Generator function for test steps for bug 303267: When a page is
michael@0 27 // displayed from the bfcache, the script globals should
michael@0 28 // remain intact from the page's initial load.
michael@0 29 //
michael@0 30 function testIterator()
michael@0 31 {
michael@0 32 // Load an initial test page which should be saved in the bfcache.
michael@0 33 var navData = {
michael@0 34 uri: getHttpUrl("bug303267.html"),
michael@0 35 eventsToListenFor: ["pageshow"],
michael@0 36 expectedEvents: [ {type: "pageshow", title: "bug303267.html"} ],
michael@0 37 onNavComplete: nextTest
michael@0 38 };
michael@0 39 doPageNavigation(navData);
michael@0 40 yield undefined;
michael@0 41
michael@0 42 // Save the HTML of the test page for later comparison.
michael@0 43 var originalHTML = getInnerHTMLById("div1");
michael@0 44
michael@0 45 // Load a second test page. The first test page's pagehide event should
michael@0 46 // have the .persisted property set to true, indicating that it was
michael@0 47 // stored in the bfcache.
michael@0 48 navData = {
michael@0 49 uri: "data:text/html,<html><head><title>page2</title></head>" +
michael@0 50 "<body>bug303267, page2</body></html>",
michael@0 51 eventsToListenFor: ["pageshow", "pagehide"],
michael@0 52 expectedEvents: [ {type: "pagehide",
michael@0 53 title: "bug303267.html",
michael@0 54 persisted: true},
michael@0 55 {type: "pageshow",
michael@0 56 title: "page2"} ],
michael@0 57 onNavComplete: nextTest
michael@0 58 };
michael@0 59 doPageNavigation(navData);
michael@0 60 yield undefined;
michael@0 61
michael@0 62 // Go back. Verify that the pageshow event for the original test page
michael@0 63 // had a .persisted property of true, indicating that it came from the
michael@0 64 // bfcache.
michael@0 65 navData = {
michael@0 66 back: true,
michael@0 67 eventsToListenFor: ["pageshow", "pagehide"],
michael@0 68 expectedEvents: [ {type: "pagehide",
michael@0 69 title: "page2"},
michael@0 70 {type: "pageshow",
michael@0 71 title: "bug303267.html",
michael@0 72 persisted: true} ],
michael@0 73 onNavComplete: nextTest
michael@0 74 };
michael@0 75 doPageNavigation(navData);
michael@0 76 yield undefined;
michael@0 77
michael@0 78 // After going back, if showpagecount() could access a global variable
michael@0 79 // and change the test div's innerHTML, then we pass. Otherwise, it
michael@0 80 // threw an exception and the following test will fail.
michael@0 81 var newHTML = getInnerHTMLById("div1");
michael@0 82 isnot(originalHTML,
michael@0 83 newHTML, "HTML not updated on pageshow; javascript broken?");
michael@0 84
michael@0 85 // Tell the framework the test is finished. Include the final 'yield'
michael@0 86 // statement to prevent a StopIteration exception from being thrown.
michael@0 87 finish();
michael@0 88 yield undefined;
michael@0 89 }
michael@0 90
michael@0 91 ////
michael@0 92 // Return the innerHTML of a particular element in the content document.
michael@0 93 //
michael@0 94 function getInnerHTMLById(id) {
michael@0 95 return TestWindow.getDocument().getElementById(id).innerHTML;
michael@0 96 }
michael@0 97
michael@0 98 ]]></script>
michael@0 99
michael@0 100 <browser type="content-primary" flex="1" id="content" src="about:blank"/>
michael@0 101 </window>

mercurial