Bug 566046. Tests. r=sicking
authorMounir Lamouri <mounir.lamouri@gmail.com>
Tue, 01 Jun 2010 11:44:33 +1200
changeset 42964 15ea57ef5d0018ff90a7ddf49623e1635ab20091
parent 42963 3a94d43c6543be04fa38bbc0695ce84ce2a62791
child 42965 25c7d2e71e57da86816181f69335418f2a8d150c
push id13548
push userrocallahan@mozilla.com
push dateTue, 01 Jun 2010 00:00:11 +0000
treeherdermozilla-central@7493eb9e9cbc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs566046
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 566046. Tests. r=sicking
content/html/content/test/Makefile.in
content/html/content/test/test_bug566046.html
--- a/content/html/content/test/Makefile.in
+++ b/content/html/content/test/Makefile.in
@@ -173,12 +173,13 @@ include $(topsrcdir)/config/rules.mk
 		test_bug546995-2.html \
 		test_bug546995-3.html \
 		test_bug546995-4.html \
 		test_bug546995-5.html \
 		file_bug546995.html \
 		test_bug377624.html \
 		test_bug562932.html \
 		test_bug551846.html \
+		test_bug566046.html \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/content/html/content/test/test_bug566046.html
@@ -0,0 +1,82 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=566046
+-->
+<head>
+  <title>Test for Bug 566046</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"/>
+  <base target='frame2'>
+</head>
+<body onload="runTests();">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=566046">Mozilla Bug 566046</a>
+<p id="display"></p>
+<iframe name='frame1' id='frame1'></iframe>
+<iframe name='frame2' id='frame2'></iframe>
+<div id="content" style="display: none">
+  <form target='frame1' action="data:text/html," method="GET">
+    <input name='foo' value='foo'>
+  </form>
+  <form action="data:text/html," method="GET">
+    <input name='bar' value='bar'>
+  </form>
+  <form target="">
+  </form>
+  <form target="tulip">
+  </form>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 566046 **/
+
+SimpleTest.waitForExplicitFinish();
+
+var gTestResults = {
+  frame1: "data:text/html,?foo=foo",
+  frame2: "data:text/html,?bar=bar",
+};
+
+var gPendingLoad = 0; // Has to be set after depending on the frames number.
+
+function runTests()
+{
+  // Check the target IDL attribute.
+  for (var i=0; i<document.forms.length; ++i) {
+    var testValue = document.forms[i].getAttribute('target');
+    is(document.forms[i].target, testValue ? testValue : "",
+       "target IDL attribute should reflect the target content attribute");
+  }
+
+  // We add a load event for the frames which will be called when the forms
+  // will be submitted.
+  var frames = [ document.getElementById('frame1'),
+                 document.getElementById('frame2') ];
+  gPendingLoad = frames.length;
+
+  for (var i=0; i<frames.length; i++) {
+    frames[i].setAttribute('onload', "frameLoaded(this);");
+  }
+
+  // Submitting only the forms with a valid target.
+  document.forms[0].submit();
+  document.forms[1].submit();
+}
+
+function frameLoaded(aFrame) {
+  // Check if when target is unspecified, it fallback correctly to the base
+  // element target attribute.
+  is(aFrame.contentWindow.location.href, gTestResults[aFrame.name],
+     "the target attribute doesn't have the correct behavior");
+
+  if (--gPendingLoad == 0) {
+    SimpleTest.finish();
+  }
+}
+
+</script>
+</pre>
+</body>
+</html>