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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/html/semantics/forms/the-option-element/option-element-constructor.html

Issue 2891723002: Do not create child node for Option constructor with no arguments/undefined text (Closed)
Patch Set: Rebased and added IsEmpty check Created 3 years, 7 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>Option element constructor</title> 3 <title>Option element constructor</title>
4 <link rel="author" title="Alex Pearson" href="mailto:alex@alexpear.com"> 4 <link rel="author" title="Alex Pearson" href="mailto:alex@alexpear.com">
5 <link rel="help" href="https://html.spec.whatwg.org/#the-option-element"> 5 <link rel="help" href="https://html.spec.whatwg.org/#the-option-element">
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 8
9 <div id="parent"> 9 <div id="parent">
10 <div id="child" tabindex="0"></div> 10 <div id="child" tabindex="0"></div>
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 const option = new Option(undefined, undefined); 84 const option = new Option(undefined, undefined);
85 85
86 assert_false(option.hasChildNodes()); 86 assert_false(option.hasChildNodes());
87 assert_false(option.hasAttribute("value")); 87 assert_false(option.hasAttribute("value"));
88 88
89 assert_equals(option.textContent, ""); 89 assert_equals(option.textContent, "");
90 assert_equals(option.value, ""); 90 assert_equals(option.value, "");
91 }, "Option constructor treats undefined text and value correctly"); 91 }, "Option constructor treats undefined text and value correctly");
92 92
93 test(() => { 93 test(() => {
94 const option = new Option("", "");
95
96 assert_false(option.hasChildNodes());
97 assert_true(option.hasAttribute("value"));
98
99 assert_equals(option.textContent, "");
100 assert_equals(option.value, "");
101 }, "Option constructor treats empty text and value correctly");
102
103 test(() => {
94 const option = new Option("text", "value", 0, ""); 104 const option = new Option("text", "value", 0, "");
95 105
96 assert_false(option.hasAttribute("selected")); 106 assert_false(option.hasAttribute("selected"));
97 assert_false(option.selected); 107 assert_false(option.selected);
98 }, "Option constructor treats falsy selected and defaultSelected correctly"); 108 }, "Option constructor treats falsy selected and defaultSelected correctly");
99 109
100 test(() => { 110 test(() => {
101 const option = new Option("text", "value", {}, 1); 111 const option = new Option("text", "value", {}, 1);
102 112
103 assert_true(option.hasAttribute("selected")); 113 assert_true(option.hasAttribute("selected"));
104 assert_true(option.selected); 114 assert_true(option.selected);
105 }, "Option constructor treats truthy selected and defaultSelected correctly"); 115 }, "Option constructor treats truthy selected and defaultSelected correctly");
106 116
107 test(() => { 117 test(() => {
108 const option = new Option("text", "value", false, true); 118 const option = new Option("text", "value", false, true);
109 119
110 assert_false(option.hasAttribute("selected")); 120 assert_false(option.hasAttribute("selected"));
111 assert_true(option.selected); 121 assert_true(option.selected);
112 122
113 option.setAttribute("selected", ""); 123 option.setAttribute("selected", "");
114 assert_true(option.selected); 124 assert_true(option.selected);
115 125
116 option.removeAttribute("selected"); 126 option.removeAttribute("selected");
117 assert_false(option.selected); 127 assert_false(option.selected);
118 }, "Option constructor does not set dirtiness (so, manipulating the selected c ontent attribute still updates the " + 128 }, "Option constructor does not set dirtiness (so, manipulating the selected c ontent attribute still updates the " +
119 "selected IDL attribute)"); 129 "selected IDL attribute)");
120 </script> 130 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/html/semantics/forms/the-option-element/option-element-constructor-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698