mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-12 09:01:16 +00:00
Bug 350022 (2/2) - Tests. r=bz
This patch also creates a forms/ directory inside content/html/content/tests/ to host the forms test suite.
This commit is contained in:
parent
79eec85022
commit
6c16669f4c
@ -51,6 +51,9 @@ ifdef ENABLE_TESTS
|
||||
# We can't have index.html in this directory because it would prevent
|
||||
# running the tests here.
|
||||
DIRS += bug649134
|
||||
|
||||
# For form-related test suite.
|
||||
DIRS += forms
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
53
content/html/content/test/forms/Makefile.in
Normal file
53
content/html/content/test/forms/Makefile.in
Normal file
@ -0,0 +1,53 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2011
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Mounir Lamouri <mounir.lamouri@mozilla.com> (original author)
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = content/html/content/test/forms
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES = \
|
||||
save_restore_radio_groups.sjs \
|
||||
test_save_restore_radio_groups.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
|
||||
|
@ -0,0 +1,44 @@
|
||||
var pages = [
|
||||
"<!DOCTYPE html>" +
|
||||
"<html><body>" +
|
||||
"<form>" +
|
||||
"<input name='a' type='radio' checked><input name='a' type='radio'><input name='a' type='radio'>" +
|
||||
"</form>" +
|
||||
"</body></html>",
|
||||
"<!DOCTYPE html>" +
|
||||
"<html><body>" +
|
||||
"<form>" +
|
||||
"<input name='a' type='radio'><input name='a' type='radio' checked><input name='a' type='radio'>" +
|
||||
"</form>" +
|
||||
"</body></html>",
|
||||
];
|
||||
|
||||
/**
|
||||
* This SJS is going to send the same page the two first times it will be called
|
||||
* and another page the two following times. After that, the response will have
|
||||
* no content.
|
||||
* The use case is to have two iframes using this SJS and both being reloaded
|
||||
* once.
|
||||
*/
|
||||
|
||||
function handleRequest(request, response)
|
||||
{
|
||||
var counter = +getState("counter"); // convert to number; +"" === 0
|
||||
|
||||
response.setStatusLine(request.httpVersion, 200, "Ok");
|
||||
response.setHeader("Content-Type", "text/html");
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
|
||||
switch (counter) {
|
||||
case 0:
|
||||
case 1:
|
||||
response.write(pages[0]);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
response.write(pages[1]);
|
||||
break;
|
||||
}
|
||||
setState("counter", "" + ++counter);
|
||||
}
|
||||
|
@ -0,0 +1,74 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=350022
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 350022</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=350022">Mozilla Bug 350022</a>
|
||||
<p id="display"></p>
|
||||
<div id="content"><!-- style="display: none">-->
|
||||
<iframe src="save_restore_radio_groups.sjs"></iframe>
|
||||
<iframe src="save_restore_radio_groups.sjs"></iframe>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 350022 **/
|
||||
|
||||
function checkRadioGroup(aFrame, aResults)
|
||||
{
|
||||
var radios = frames[aFrame].document.getElementsByTagName('input');
|
||||
|
||||
is(radios.length, aResults.length,
|
||||
"Radio group should have " + aResults.length + "elements");
|
||||
|
||||
for (var i=0; i<aResults.length; ++i) {
|
||||
is(radios[i].checked, aResults[i],
|
||||
"Radio checked state should be " + aResults[i]);
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(function() {
|
||||
/**
|
||||
* We have two iframes each containing one radio button group.
|
||||
* We are going to change the selected radio button in one group.
|
||||
* Then, both iframes will be reloaded and the new groups will have another
|
||||
* radio checked by default.
|
||||
* For the first group (which had a selection change), nothing should change.
|
||||
* For the second, the selected radio button should change.
|
||||
*/
|
||||
checkRadioGroup(0, [true, false, false]);
|
||||
checkRadioGroup(1, [true, false, false]);
|
||||
|
||||
frames[0].document.getElementsByTagName('input')[2].checked = true;
|
||||
checkRadioGroup(0, [false, false, true]);
|
||||
|
||||
framesElts = document.getElementsByTagName('iframe');
|
||||
framesElts[0].addEventListener("load", function() {
|
||||
framesElts[0].removeEventListener("load", arguments.callee, false);
|
||||
checkRadioGroup(0, [false, false, true]);
|
||||
|
||||
framesElts[1].addEventListener("load", function() {
|
||||
framesElts[1].removeEventListener("load", arguments.callee, false);
|
||||
|
||||
checkRadioGroup(1, [false, true, false]);
|
||||
SimpleTest.finish();
|
||||
}, false);
|
||||
|
||||
frames[1].location.reload();
|
||||
}, false);
|
||||
|
||||
frames[0].location.reload();
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user