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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/html/semantics/forms/the-label-element/labelable-elements.html

Issue 2695813009: Import wpt@503f5b5f78ec4e87d144f78609f363f0ed0ea8db (Closed)
Patch Set: Skip some tests Created 3 years, 10 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: labelable elements</title> 3 <title>HTML Test: labelable elements</title>
4 <link rel="author" title="Intel" href="http://www.intel.com/"> 4 <link rel="author" title="Intel" href="http://www.intel.com/">
5 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/testharnessreport.js"></script>
7 <div id="log"></div> 7 <div id="log"></div>
8 <form style="display:none"> 8 <form style="display:none">
9 <output id="testoutput"></output> 9 <output id="testoutput"></output>
10 <label id="lbl0" for="testoutput"></label> 10 <label id="lbl0" for="testoutput"></label>
(...skipping 18 matching lines...) Expand all
29 <label id="lbl9" for="testfieldset"></label> 29 <label id="lbl9" for="testfieldset"></label>
30 <label id="testlabel"></label> 30 <label id="testlabel"></label>
31 <label id="lbl10" for="testlabel"></label> 31 <label id="lbl10" for="testlabel"></label>
32 <object id="testobject"></object> 32 <object id="testobject"></object>
33 <label id="lbl11" for="testobject"></label> 33 <label id="lbl11" for="testobject"></label>
34 <img id="testimg"> 34 <img id="testimg">
35 <label id="lbl12" for="testimg"></label> 35 <label id="lbl12" for="testimg"></label>
36 </form> 36 </form>
37 37
38 <script> 38 <script>
39 function testLabelsAttr(formElementId, labelElementId, hasLabels) { 39 function testLabelsAttr(formElementId, labelElementId) {
40 var elem = document.getElementById(formElementId); 40 var elem = document.getElementById(formElementId);
41 if (labelElementId) { 41 if (labelElementId) {
42 assert_equals(elem.labels.length, 1); 42 assert_equals(elem.labels.length, 1);
43 assert_equals(elem.labels[0].id, labelElementId); 43 assert_equals(elem.labels[0].id, labelElementId);
44 } else { 44 } else {
45 assert_equals(elem.labels.length, 0); 45 assert_equals(elem.labels.length, 0);
46 } 46 }
47 } 47 }
48 48
49 test(function() { 49 test(function() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 test(function() { 85 test(function() {
86 testLabelsAttr("testButton", "lbl4"); 86 testLabelsAttr("testButton", "lbl4");
87 }, "Check if the button element can access 'labels'"); 87 }, "Check if the button element can access 'labels'");
88 88
89 test(function() { 89 test(function() {
90 assert_equals(document.getElementById("lbl5").control, null, "An input element in hidden state should not be labelable."); 90 assert_equals(document.getElementById("lbl5").control, null, "An input element in hidden state should not be labelable.");
91 }, "Check if the hidden input element is not a labelable element."); 91 }, "Check if the hidden input element is not a labelable element.");
92 92
93 test(function() { 93 test(function() {
94 testLabelsAttr("testHidden", null); 94 var hiddenInput = document.getElementById("testHidden");
95 }, "Check if the hidden input element can access 'labels'"); 95 assert_equals(hiddenInput.labels, null, "input[type=hidden] must have null .la bels");
96
97 this.add_cleanup(function () {
98 hiddenInput.type = "hidden";
99 });
100
101 hiddenInput.type = "text";
102 testLabelsAttr("testHidden", "lbl5");
103 var labels = hiddenInput.labels;
104
105 hiddenInput.type = "hidden";
106 assert_equals(labels.length, 0, "Retained .labels NodeList should be empty aft er input type changed to hidden");
107
108 hiddenInput.type = "checkbox";
109 assert_true(labels === hiddenInput.labels, ".labels property must return the [ SameObject] after input type is toggled back from 'hidden'");
110 assert_equals(hiddenInput.labels.length, 1, ".labels NodeList should contain t he input after the input type is changed from 'hidden' to 'checkbox'");
111 }, "Check if the hidden input element has null 'labels'");
96 112
97 test(function() { 113 test(function() {
98 assert_equals(document.getElementById("lbl6").control.id, "testRadio", "An inp ut element in radio state should be labelable."); 114 assert_equals(document.getElementById("lbl6").control.id, "testRadio", "An inp ut element in radio state should be labelable.");
99 }, "Check if the input element in radio state is a labelable element"); 115 }, "Check if the input element in radio state is a labelable element");
100 116
101 test(function() { 117 test(function() {
102 testLabelsAttr("testRadio", "lbl6"); 118 testLabelsAttr("testRadio", "lbl6");
103 }, "Check if the input element in radio state can access 'labels'"); 119 }, "Check if the input element in radio state can access 'labels'");
104 120
105 test(function() { 121 test(function() {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 164
149 test(function() { 165 test(function() {
150 assert_not_equals(document.getElementById("lbl9").control, document.getElement ById("testimg")); 166 assert_not_equals(document.getElementById("lbl9").control, document.getElement ById("testimg"));
151 assert_equals(document.getElementById("lbl12").control, null, "An img element should not be labelable."); 167 assert_equals(document.getElementById("lbl12").control, null, "An img element should not be labelable.");
152 }, "Check if the img element is not a labelable element"); 168 }, "Check if the img element is not a labelable element");
153 169
154 test(function() { 170 test(function() {
155 assert_equals(document.getElementById("lbl9").labels, undefined); 171 assert_equals(document.getElementById("lbl9").labels, undefined);
156 }, "Check if the img element can access 'labels'"); 172 }, "Check if the img element can access 'labels'");
157 </script> 173 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698