Bug 681615 - Move a couple of tests from content/html/content/test to content/html/content/test/forms; r=mounir
authorMs2ger <ms2ger@gmail.com>
Thu, 25 Aug 2011 10:45:53 +0200
changeset 75846 80db03383c348e81468c0d914fd897c79cc573e6
parent 75845 e58e98a89827d0aa29ebf648312de26f2f98073d
child 75847 7dfa2501f1512452d4f1870de11e66e5bb06a1a7
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersmounir
bugs681615
milestone9.0a1
Bug 681615 - Move a couple of tests from content/html/content/test to content/html/content/test/forms; r=mounir
content/html/content/test/Makefile.in
content/html/content/test/forms/Makefile.in
content/html/content/test/forms/test_datalist_element.html
content/html/content/test/forms/test_input_list_attribute.html
content/html/content/test/forms/test_maxlength_attribute.html
content/html/content/test/forms/test_validation.html
content/html/content/test/test_bug345624-1.html
content/html/content/test/test_bug345624-2.html
content/html/content/test/test_bug555840.html
content/html/content/test/test_bug556007.html
content/html/content/test/test_bug595457.html
--- a/content/html/content/test/Makefile.in
+++ b/content/html/content/test/Makefile.in
@@ -192,54 +192,49 @@ include $(topsrcdir)/config/rules.mk
 		test_bug567938-1.html \
 		test_bug567938-2.html \
 		test_bug567938-3.html \
 		test_bug567938-4.html \
 		test_bug569955.html \
 		test_bug573969.html \
 		test_bug549475.html \
 		test_bug585508.html \
-		test_bug345624-1.html \
-		test_bug345624-2.html \
 		test_bug561640.html \
 		test_bug566064.html \
 		test_bug582412-1.html \
 		test_bug582412-2.html \
 		test_bug558788-1.html \
 		test_bug558788-2.html \
 		test_bug561634.html \
 		test_bug588683-1.html \
 		test_bug588683-2.html \
 		test_bug588683-3.html \
 		test_bug588683-4.html \
 		test_bug590353-1.html \
 		test_bug590353-2.html \
 		test_bug593689.html \
-		test_bug555840.html \
 		test_bug561636.html \
 		test_bug590363.html \
 		test_bug557628.html \
 		test_bug592802.html \
 		test_bug595429.html \
 		test_bug595447.html \
 		test_bug595449.html \
-		test_bug595457.html \
 		test_bug557087-1.html \
 		test_bug557087-2.html \
 		test_bug557087-3.html \
 		test_bug557087-4.html \
 		test_bug557087-5.html \
 		test_bug557087-6.html \
 		test_bug586763.html \
 		test_bug587469.html \
 		test_bug598643.html \
 		test_bug596350.html \
 		test_bug598833-1.html \
 		test_bug600155.html \
-		test_bug556007.html \
 		test_bug606817.html \
 		test_bug297761.html \
 		file_bug297761.html \
 		test_bug607145.html \
 		test_bug596511.html \
 		reflect.js \
 		test_bug611189.html \
 		test_bug613113.html \
--- a/content/html/content/test/forms/Makefile.in
+++ b/content/html/content/test/forms/Makefile.in
@@ -43,24 +43,28 @@ relativesrcdir = content/html/content/te
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = \
 		save_restore_radio_groups.sjs \
 		test_save_restore_radio_groups.html \
 		test_mozistextfield.html \
 		test_input_attributes_reflection.html \
+		test_input_list_attribute.html \
 		test_input_email.html \
 		test_input_url.html \
 		test_pattern_attribute.html \
 		test_required_attribute.html \
 		test_novalidate_attribute.html \
 		test_formaction_attribute.html \
 		test_formnovalidate_attribute.html \
 		test_label_control_attribute.html \
 		test_output_element.html \
 		test_button_attributes_reflection.html \
 		test_textarea_attributes_reflection.html \
+		test_validation.html \
+		test_maxlength_attribute.html \
+		test_datalist_element.html \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 
rename from content/html/content/test/test_bug555840.html
rename to content/html/content/test/forms/test_datalist_element.html
--- a/content/html/content/test/test_bug555840.html
+++ b/content/html/content/test/forms/test_datalist_element.html
@@ -1,20 +1,16 @@
 <!DOCTYPE HTML>
 <html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=555840
--->
 <head>
-  <title>Test for Bug 555840</title>
+  <title>Test for the datalist element</title>
   <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=555840">Mozilla Bug 555840</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <datalist>
   </datalist>
 </div>
 <pre id="test">
 <script type="application/javascript">
 
@@ -50,36 +46,72 @@ function checkOptions()
     /* Non-option elements are not recognized. */
     [['input'], null, 0],
     [['input', 'option'], null, 1],
     [['input', 'textarea'], null, 0],
     /* .value and .label are not needed to be valid options. */
     [['option', 'option'], function(d) { d.childNodes[0].value = 'value'; }, 2],
     [['option', 'option'], function(d) { d.childNodes[0].label = 'label'; }, 2],
     [['option', 'option'], function(d) { d.childNodes[0].value = 'value'; d.childNodes[0].label = 'label'; }, 2],
+    [['select'],
+     function(d) {
+       var s = d.childNodes[0];
+       s.appendChild(new Option("foo"));
+       s.appendChild(new Option("bar"));
+     },
+     2],
+    [['select'],
+     function(d) {
+       var s = d.childNodes[0];
+       s.appendChild(new Option("foo"));
+       s.appendChild(new Option("bar"));
+       var label = document.createElement("label");
+       d.appendChild(label);
+       label.appendChild(new Option("foobar"));
+     },
+     3],
+    [['select'],
+     function(d) {
+       var s = d.childNodes[0];
+       s.appendChild(new Option("foo"));
+       s.appendChild(new Option("bar"));
+       var label = document.createElement("label");
+       d.appendChild(label);
+       label.appendChild(new Option("foobar"));
+       s.appendChild(new Option())
+     },
+     4],
+     [[], function(d) { d.appendChild(document.createElementNS("foo", "option")); }, 0]
   ];
 
   var d = document.getElementsByTagName('datalist')[0];
+  var cachedOptions = d.options;
 
-  for each (data in testData) {
-    for each (e in data[0]) {
+  testData.forEach(function(data) {
+    data[0].forEach(function(e) {
       d.appendChild(document.createElement(e));
-    }
+    })
 
     /* Modify children. */
     if (data[1]) {
       data[1](d);
     }
 
+    is(d.options, cachedOptions, "Should get the same object")
     is(d.options.length, data[2],
        "The number of recognized options should be " + data[2])
 
+    for (var i = 0; i < d.options.length; ++i) {
+      is(d.options[i].localName, "option",
+         "Should get an option for d.options[" + i + "]")
+    }
+
     /* Cleaning-up. */
-    for (; d.firstChild; d.removeChild(d.firstChild));
-  }
+    d.textContent = "";
+  })
 }
 
 checkClassesAndAttributes();
 checkOptions();
 
 </script>
 </pre>
 </body>
rename from content/html/content/test/test_bug556007.html
rename to content/html/content/test/forms/test_input_list_attribute.html
rename from content/html/content/test/test_bug345624-2.html
rename to content/html/content/test/forms/test_maxlength_attribute.html
--- a/content/html/content/test/test_bug345624-2.html
+++ b/content/html/content/test/forms/test_maxlength_attribute.html
@@ -56,19 +56,19 @@ function checkTooLongValidity(element)
   todo(element.validity.tooLong,
        "Element should be too long when maxlength < value length");
   todo_is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
           "rgb(255, 0, 0)", ":invalid pseudo-class should apply");
 
   todo(!element.validity.valid,
        "Element should not be valid when it is too long");
 
-  todo(element.validationMessage,
-       "Please shorten this text to 2 characters or less (you are currently using 3 characters).",
-       "The validation message text is not correct");
+  todo_is(element.validationMessage,
+          "Please shorten this text to 2 characters or less (you are currently using 3 characters).",
+          "The validation message text is not correct");
   todo(!element.checkValidity(), "The element should not be valid");
   element.setCustomValidity("custom message");
   is(window.getComputedStyle(element, null).getPropertyValue('background-color'),
      "rgb(255, 0, 0)", ":invalid pseudo-class should apply");
   is(element.validationMessage, "custom message",
     "Custom message should be shown instead of too long one");
 }
 
rename from content/html/content/test/test_bug345624-1.html
rename to content/html/content/test/forms/test_validation.html
deleted file mode 100644
--- a/content/html/content/test/test_bug595457.html
+++ /dev/null
@@ -1,60 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=595457
--->
-<head>
-  <title>Test for Bug 595457</title>
-  <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=595457">Mozilla Bug 595457</a>
-<p id="display"></p>
-<pre id="test">
-<script type="application/javascript">
-
-/** Test for Bug 595457 **/
-
-function checkDatalistOptions(aDatalist, aOptions)
-{
-  var datalistOptions = datalist.options;
-  var length = datalistOptions.length;
-
-  is(length, options.length, "datalist should have " + options.length + " options");
-
-  for (var i=0; i<length; ++i) {
-    is(datalistOptions[i], options[i], options[i] +
-                                       "should be in the datalist options");
-  }
-}
-
-var datalist = document.createElement("datalist");
-var select = document.createElement("select");
-var options = [ new Option("foo"), new Option("bar") ];
-
-datalist.appendChild(select);
-
-for each(option in options) {
-  select.appendChild(option);
-}
-
-checkDatalistOptions(datalist, options);
-
-var label = document.createElement("label");
-datalist.appendChild(label);
-
-options[2] = new Option("foobar");
-label.appendChild(options[2]);
-
-checkDatalistOptions(datalist, options);
-
-options[3] = new Option();
-datalist.appendChild(options[3]);
-
-checkDatalistOptions(datalist, options);
-
-</script>
-</pre>
-</body>
-</html>