зеркало из https://github.com/mozilla/gecko-dev.git
Adding test for bug 303267. r=mrbkap
This commit is contained in:
Родитель
ba3f1bc538
Коммит
d9ffebffea
|
@ -64,6 +64,9 @@ _TEST_FILES = \
|
|||
bug113934_window.xul \
|
||||
test_bug215405.xul \
|
||||
bug215405_window.xul \
|
||||
test_bug303267.xul \
|
||||
bug303267.html \
|
||||
bug303267_window.xul \
|
||||
test_bug364461.xul \
|
||||
bug364461_window.xul \
|
||||
test_bug396519.xul \
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>
|
||||
bug303267.html
|
||||
</title>
|
||||
</head>
|
||||
<body onpageshow="showpageshowcount()">
|
||||
<script>
|
||||
var pageshowcount = 0;
|
||||
function showpageshowcount()
|
||||
{
|
||||
pageshowcount++;
|
||||
var div1 = document.getElementById("div1");
|
||||
while (div1.firstChild)
|
||||
{
|
||||
div1.removeChild(div1.firstChild);
|
||||
}
|
||||
div1.appendChild(document.createTextNode(
|
||||
"pageshowcount: " + pageshowcount));
|
||||
}
|
||||
</script>
|
||||
<div id="div1">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
|
||||
<window id="303267Test"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
width="600"
|
||||
height="600"
|
||||
onload="setTimeout(nextTest,0);"
|
||||
title="bug 303267 test">
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/chrome/docshell/test/chrome/docshell_helpers.js">
|
||||
</script>
|
||||
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
// Define the generator-iterator for the tests.
|
||||
var tests = testIterator();
|
||||
|
||||
////
|
||||
// Execute the next test in the generator function.
|
||||
//
|
||||
function nextTest() {
|
||||
tests.next();
|
||||
}
|
||||
|
||||
////
|
||||
// Generator function for test steps for bug 303267: When a page is
|
||||
// displayed from the bfcache, the script globals should
|
||||
// remain intact from the page's initial load.
|
||||
//
|
||||
function testIterator()
|
||||
{
|
||||
// Load an initial test page which should be saved in the bfcache.
|
||||
var navData = {
|
||||
uri: getHttpUrl("bug303267.html"),
|
||||
eventsToListenFor: ["pageshow"],
|
||||
expectedEvents: [ {type: "pageshow", title: "bug303267.html"} ],
|
||||
onNavComplete: nextTest
|
||||
};
|
||||
doPageNavigation(navData);
|
||||
yield;
|
||||
|
||||
// Save the HTML of the test page for later comparison.
|
||||
var originalHTML = getInnerHTMLById("div1");
|
||||
|
||||
// Load a second test page. The first test page's pagehide event should
|
||||
// have the .persisted property set to true, indicating that it was
|
||||
// stored in the bfcache.
|
||||
navData = {
|
||||
uri: "data:text/html,<html><head><title>page2</title></head>" +
|
||||
"<body>bug303267, page2</body></html>",
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ {type: "pagehide",
|
||||
title: "bug303267.html",
|
||||
persisted: true},
|
||||
{type: "pageshow",
|
||||
title: "page2"} ],
|
||||
onNavComplete: nextTest
|
||||
};
|
||||
doPageNavigation(navData);
|
||||
yield;
|
||||
|
||||
// Go back. Verify that the pageshow event for the original test page
|
||||
// had a .persisted property of true, indicating that it came from the
|
||||
// bfcache.
|
||||
navData = {
|
||||
back: true,
|
||||
eventsToListenFor: ["pageshow", "pagehide"],
|
||||
expectedEvents: [ {type: "pagehide",
|
||||
title: "page2"},
|
||||
{type: "pageshow",
|
||||
title: "bug303267.html",
|
||||
persisted: true} ],
|
||||
onNavComplete: nextTest
|
||||
};
|
||||
doPageNavigation(navData);
|
||||
yield;
|
||||
|
||||
// After going back, if showpagecount() could access a global variable
|
||||
// and change the test div's innerHTML, then we pass. Otherwise, it
|
||||
// threw an exception and the following test will fail.
|
||||
var newHTML = getInnerHTMLById("div1");
|
||||
isnot(originalHTML,
|
||||
newHTML, "HTML not updated on pageshow; javascript broken?");
|
||||
|
||||
// Tell the framework the test is finished. Include the final 'yield'
|
||||
// statement to prevent a StopIteration exception from being thrown.
|
||||
finish();
|
||||
yield;
|
||||
}
|
||||
|
||||
////
|
||||
// Return the innerHTML of a particular element in the content document.
|
||||
//
|
||||
function getInnerHTMLById(id) {
|
||||
return TestWindow.getDocument().getElementById(id).innerHTML;
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
||||
<browser type="content-primary" flex="1" id="content" src="about:blank"/>
|
||||
</window>
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=303267.xul
|
||||
-->
|
||||
<window title="Mozilla Bug 303267"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<title>Test for Bug 303267</title>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=303267">Mozilla Bug 303267</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
<script class="testbody" type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/** Test for Bug 303267 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
window.open("bug303267_window.xul", "bug303267",
|
||||
"chrome,width=600,height=600");
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
</window>
|
Загрузка…
Ссылка в новой задаче