Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/html/infrastructure/common-dom-interfaces/collections/htmlformcontrolscollection.html

Issue 2634323002: Import wpt@aae3e1b6ffb8b24acb777450933ceeafd97e3655 (Closed)
Patch Set: Modify TestExpectations or download new baselines for tests. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <meta charset="utf-8"> 2 <meta charset="utf-8">
3 <title>HTML Test: the HTMLFormControlsCollection interface</title> 3 <title>HTML Test: the HTMLFormControlsCollection interface</title>
4 <link rel="author" title="Intel" href="http://www.intel.com/"> 4 <link rel="author" title="Intel" href="http://www.intel.com/">
5 <link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/common-d om-interfaces.html#htmlformcontrolscollection"> 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/common-d om-interfaces.html#htmlformcontrolscollection">
6 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharness.js"></script>
7 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testharnessreport.js"></script>
8 <div id="log"></div> 8 <div id="log"></div>
9 <form id="f1"> 9 <form id="f1">
10 <input type="radio" id="r1"> 10 <input type="radio" id="r1" name="ra">
11 <keygen id="kg" name="key"></keygen> 11 <keygen id="kg" name="key"></keygen> <!-- we test that it does *not* appear in form.elements -->
12 </form> 12 </form>
13 <form id="f2"> 13 <form id="f2">
14 <table> 14 <table>
15 <tr> 15 <tr>
16 <td> 16 <td>
17 <input type="checkbox" id="cb"> 17 <input type="checkbox" id="cb">
18 <input type="checkbox" name="cb"> 18 <input type="checkbox" name="cb">
19 </td> 19 </td>
20 </tr> 20 </tr>
21 <tr> 21 <tr>
(...skipping 10 matching lines...) Expand all
32 var coll1, coll2, rdo; 32 var coll1, coll2, rdo;
33 33
34 setup(function () { 34 setup(function () {
35 rdo = document.getElementById("r1"); 35 rdo = document.getElementById("r1");
36 coll1 = document.forms[0].elements; 36 coll1 = document.forms[0].elements;
37 coll2 = document.forms[1].elements; 37 coll2 = document.forms[1].elements;
38 }); 38 });
39 39
40 //length 40 //length
41 test(function () { 41 test(function () {
42 assert_equals(coll1.length, 2, "The length attribute is incorrect."); 42 assert_equals(coll1.length, 1, "The length attribute is incorrect.");
43 assert_equals(coll2.length, 4, "The length attribute is incorrect."); 43 assert_equals(coll2.length, 4, "The length attribute is incorrect.");
44 }, "The length attribute must return the number of elements in the form"); 44 }, "The length attribute must return the number of elements in the form");
45 45
46 //getter - index 46 //getter - index
47 test(function () { 47 test(function () {
48 assert_equals(coll1.item(0), rdo, "HTMLFormControlsCollection.item(index) shou ld return the 'input' element in radio status."); 48 assert_equals(coll1.item(0), rdo, "HTMLFormControlsCollection.item(index) shou ld return the 'input' element in radio status.");
49 }, "HTMLFormControlsCollection.item(index) must return the indexed item"); 49 }, "HTMLFormControlsCollection.item(index) must return the indexed item");
50 50
51 test(function () { 51 test(function () {
52 assert_equals(coll1[0], rdo, "HTMLFormControlsCollection[index] should return the 'input' element in radio status."); 52 assert_equals(coll1[0], rdo, "HTMLFormControlsCollection[index] should return the 'input' element in radio status.");
(...skipping 23 matching lines...) Expand all
76 76
77 test(function () { 77 test(function () {
78 assert_equals(coll1.namedItem(""), null, "The return value of namedItem() shou ld be null."); 78 assert_equals(coll1.namedItem(""), null, "The return value of namedItem() shou ld be null.");
79 }, "The namedItem(name) must return null if the name is empty"); 79 }, "The namedItem(name) must return null if the name is empty");
80 80
81 test(function () { 81 test(function () {
82 assert_equals(coll1.namedItem("test"), null, "The return value of namedItem() should be null."); 82 assert_equals(coll1.namedItem("test"), null, "The return value of namedItem() should be null.");
83 }, "The namedItem(name) must return null if there is no matched element"); 83 }, "The namedItem(name) must return null if there is no matched element");
84 84
85 test(function () { 85 test(function () {
86 assert_equals(coll1.namedItem("kg"), document.getElementById("kg"), "Controls can be named by 'id' attribute."); 86 assert_equals(coll1.namedItem("r1"), document.getElementById("r1"), "Controls can be named by 'id' attribute.");
87 assert_equals(coll1.namedItem("key"), document.getElementById("kg"), "Controls can be named by 'name' attribute."); 87 assert_equals(coll1.namedItem("ra"), document.getElementById("r1"), "Controls can be named by 'name' attribute.");
88 }, "Controls can be indexed by id or name attribute"); 88 }, "Controls can be indexed by id or name attribute");
89 89
90 test(function () { 90 test(function () {
91 assert_equals(coll1.namedItem("kg"), null, "Keygen does not show up when queri ed by id.");
92 assert_equals(coll1.namedItem("key"), null, "Keygen does not show up when quer ied by name.");
93 }, "Keygen controls do not show up at all");
94
95 test(function () {
91 assert_equals(coll2.namedItem("btn").length, 2, "The length attribute should b e 2."); 96 assert_equals(coll2.namedItem("btn").length, 2, "The length attribute should b e 2.");
92 }, "The namedItem(name) must return the items with id or name attribute"); 97 }, "The namedItem(name) must return the items with id or name attribute");
93 98
94 //various controls in fieldset and form 99 //various controls in fieldset and form
95 var containers = ["form", "fieldset"], 100 var containers = ["form", "fieldset"],
96 controls = ["button", "fieldset", "input", "keygen", "object", "output", "se lect", "textarea"]; 101 controls = ["button", "fieldset", "input", "object", "output", "select", "te xtarea"];
97 for (var m = 0; m < containers.length; m++) { 102 for (var m = 0; m < containers.length; m++) {
98 test(function () { 103 test(function () {
99 var container = document.createElement(containers[m]); 104 var container = document.createElement(containers[m]);
100 var len = controls.length; 105 var len = controls.length;
101 for (var n = 0; n < len; n++) 106 for (var n = 0; n < len; n++)
102 container.appendChild(document.createElement(controls[n])); 107 container.appendChild(document.createElement(controls[n]));
103 document.body.appendChild(container); 108 document.body.appendChild(container);
104 assert_equals(container.elements.length, len, "The length should be " + len + "."); 109 assert_equals(container.elements.length, len, "The length should be " + len + ".");
105 }, "The HTMLFormControlsCollection interface is used for collections of listed elements in " + containers[m] + " element"); 110 }, "The HTMLFormControlsCollection interface is used for collections of listed elements in " + containers[m] + " element");
106 } 111 }
107 112
108 //Check the controls' order 113 //Check the controls' order
109 test(function () { 114 test(function () {
110 var opt = document.forms[1].insertBefore(document.createElement("output"), doc ument.forms[1].firstChild); 115 var opt = document.forms[1].insertBefore(document.createElement("output"), doc ument.forms[1].firstChild);
111 assert_array_equals(document.forms[1].elements, 116 assert_array_equals(document.forms[1].elements,
112 [opt, document.getElementsByTagName("input")[1], document. getElementsByTagName("input")[2], 117 [opt, document.getElementsByTagName("input")[1], document. getElementsByTagName("input")[2],
113 document.getElementsByTagName("button")[0], document.getEl ementsByTagName("button")[1]]); 118 document.getElementsByTagName("button")[0], document.getEl ementsByTagName("button")[1]]);
114 }, "The controls in the form element must be sorted in tree order"); 119 }, "The controls in the form element must be sorted in tree order");
115 120
116 </script> 121 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698