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"
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();
19 // Execute the next test in the generator function.
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.
34 uri: getHttpUrl(
"bug303267.html"),
35 eventsToListenFor: [
"pageshow"],
36 expectedEvents: [ {type:
"pageshow", title:
"bug303267.html"} ],
37 onNavComplete: nextTest
39 doPageNavigation(navData);
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.
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",
57 onNavComplete: nextTest
59 doPageNavigation(navData);
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
67 eventsToListenFor: [
"pageshow",
"pagehide"],
68 expectedEvents: [ {type:
"pagehide",
71 title:
"bug303267.html",
73 onNavComplete: nextTest
75 doPageNavigation(navData);
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");
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.
92 // Return the innerHTML of a particular element in the content document.
94 function getInnerHTMLById(id) {
95 return TestWindow.getDocument().getElementById(id).innerHTML;
100 <browser type=
"content-primary" flex=
"1" id=
"content" src=
"about:blank"/>