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