mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Add test for bug 294258. r=bzbarsky
This commit is contained in:
parent
d9ffebffea
commit
08d19aa0b3
@ -64,6 +64,9 @@ _TEST_FILES = \
|
||||
bug113934_window.xul \
|
||||
test_bug215405.xul \
|
||||
bug215405_window.xul \
|
||||
test_bug294258.xul \
|
||||
bug294258_window.xul \
|
||||
bug294258_testcase.html \
|
||||
test_bug303267.xul \
|
||||
bug303267.html \
|
||||
bug303267_window.xul \
|
||||
|
43
docshell/test/chrome/bug294258_testcase.html
Normal file
43
docshell/test/chrome/bug294258_testcase.html
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Bug 294258 Testcase</title>
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml"/>
|
||||
<style type="text/css">
|
||||
* {
|
||||
font-family: monospace;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<p>
|
||||
input type="text": <input id="text" type="text"/>
|
||||
</p>
|
||||
<p>
|
||||
input type="checkbox": <input id="checkbox" type="checkbox"/>
|
||||
</p>
|
||||
<p>
|
||||
input type="file": <input id="file" type="file"/>
|
||||
</p>
|
||||
<p>
|
||||
input type="radio":
|
||||
<input type="radio" id="radio1" name="radio" value="radio1"/>
|
||||
<input id="radio2" type="radio" name="radio" value="radio2"/>
|
||||
</p>
|
||||
<p>
|
||||
textarea: <textarea id="textarea" rows="4" cols="80"></textarea>
|
||||
</p>
|
||||
<p>
|
||||
select -> option: <select id="select">
|
||||
<option>1</option>
|
||||
<option>2</option>
|
||||
<option>3</option>
|
||||
<option>4</option>
|
||||
</select>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
73
docshell/test/chrome/bug294258_window.xul
Normal file
73
docshell/test/chrome/bug294258_window.xul
Normal file
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
|
||||
<window id="294258Test"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
width="600"
|
||||
height="600"
|
||||
onload="setTimeout(nextTest,0);"
|
||||
title="bug 294258 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();
|
||||
}
|
||||
|
||||
function $(id) { return TestWindow.getDocument().getElementById(id); }
|
||||
|
||||
////
|
||||
// Generator function for test steps for bug 294258:
|
||||
// Form values should be preserved on reload.
|
||||
//
|
||||
function testIterator()
|
||||
{
|
||||
// Load a page containing a form.
|
||||
doPageNavigation( {
|
||||
uri: getHttpUrl("bug294258_testcase.html"),
|
||||
onNavComplete: nextTest
|
||||
} );
|
||||
yield;
|
||||
|
||||
// Change the data for each of the form fields, and reload.
|
||||
$("text").value = "text value";
|
||||
$("checkbox").checked = true;
|
||||
$("file").value = "file value";
|
||||
$("textarea").value = "textarea value";
|
||||
$("radio1").checked = true;
|
||||
$("select").selectedIndex = 2;
|
||||
doPageNavigation( {
|
||||
reload: true,
|
||||
onNavComplete: nextTest
|
||||
} );
|
||||
yield;
|
||||
|
||||
// Verify that none of the form data has changed.
|
||||
is($("text").value, "text value", "Text value changed");
|
||||
is($("checkbox").checked, true, "Checkbox value changed");
|
||||
is($("file").value, "file value", "File value changed");
|
||||
is($("textarea").value, "textarea value", "Textarea value changed");
|
||||
is($("radio1").checked, true, "Radio value changed");
|
||||
is($("select").selectedIndex, 2, "Select value changed");
|
||||
|
||||
// Tell the framework the test is finished. Include the final 'yield'
|
||||
// statement to prevent a StopIteration exception from being thrown.
|
||||
finish();
|
||||
yield;
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
||||
<browser type="content-primary" flex="1" id="content" src="about:blank"/>
|
||||
</window>
|
@ -14,6 +14,7 @@ const NAV_NONE = 0;
|
||||
const NAV_BACK = 1;
|
||||
const NAV_FORWARD = 2;
|
||||
const NAV_URI = 3;
|
||||
const NAV_RELOAD = 4;
|
||||
|
||||
var gExpectedEvents; // an array of events which are expected to be
|
||||
// triggered by this navigation
|
||||
@ -83,6 +84,7 @@ function doPageNavigation(params) {
|
||||
// Parse the parameters.
|
||||
let back = params.back ? params.back : false;
|
||||
let forward = params.forward ? params.forward : false;
|
||||
let reload = params.reload ? params.reload : false;
|
||||
let uri = params.uri ? params.uri : false;
|
||||
let eventsToListenFor = typeof(params.eventsToListenFor) != "undefined" ?
|
||||
params.eventsToListenFor : ["pageshow"];
|
||||
@ -98,8 +100,10 @@ function doPageNavigation(params) {
|
||||
throw "Can't specify both back and a uri";
|
||||
if (forward && uri)
|
||||
throw "Can't specify both forward and a uri";
|
||||
if (!back && !forward && !uri)
|
||||
throw "Must specify back or foward or uri";
|
||||
if (reload && (forward || back || uri))
|
||||
throw "Can't specify reload and another navigation type";
|
||||
if (!back && !forward && !uri && !reload)
|
||||
throw "Must specify back or foward or reload or uri";
|
||||
if (params.onNavComplete && eventsToListenFor.length == 0)
|
||||
throw "Can't use onNavComplete when eventsToListenFor == []";
|
||||
if (params.preventBFCache && eventsToListenFor.length == 0)
|
||||
@ -142,6 +146,10 @@ function doPageNavigation(params) {
|
||||
gNavType = NAV_URI;
|
||||
TestWindow.getBrowser().loadURI(uri);
|
||||
}
|
||||
else if (reload) {
|
||||
gNavType = NAV_RELOAD;
|
||||
TestWindow.getBrowser().reload();
|
||||
}
|
||||
else {
|
||||
throw "No valid navigation type passed to doPageNavigation!";
|
||||
}
|
||||
|
43
docshell/test/chrome/test_bug294258.xul
Normal file
43
docshell/test/chrome/test_bug294258.xul
Normal file
@ -0,0 +1,43 @@
|
||||
<?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=294258.xul
|
||||
-->
|
||||
<window title="Mozilla Bug 294258"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<title>Test for Bug 294258</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=294258">
|
||||
Mozilla Bug 294258</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 294258 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
window.open("bug294258_window.xul", "bug294258",
|
||||
"chrome,width=600,height=600");
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
</window>
|
Loading…
Reference in New Issue
Block a user