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