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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/css/pseudo-default-dynamic.html

Issue 1768913002: Dynamic updation of checked and selected attributes should reflect correct :default status (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated as per review comments Created 4 years, 9 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLInputElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script> 2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script> 3 <script src="../../resources/testharnessreport.js"></script>
4 <div id="log"></div> 4 <div id="log"></div>
5 <div id="container"></div> 5 <div id="container"></div>
6 <style> 6 <style>
7 button, input { background: red; } 7 button, input, option { background: red; }
8 button:default, input:default { background: green; } 8 button:default, input:default, option:default { background: green; }
9 </style> 9 </style>
10 <script> 10 <script>
11 // TODO(tkent): This should be merged to web-platform-tests/html/semantics/selec tors/pseudo-classes/default.html. 11 // TODO(tkent): This should be merged to web-platform-tests/html/semantics/selec tors/pseudo-classes/default.html.
12 12
13 var container = document.querySelector('#container'); 13 var container = document.querySelector('#container');
14 const DEFAULT = 'rgb(0, 128, 0)'; 14 const DEFAULT = 'rgb(0, 128, 0)';
15 const NOT_DEFAULT = 'rgb(255, 0, 0)'; 15 const NOT_DEFAULT = 'rgb(255, 0, 0)';
16 16
17 function background(id) { 17 function background(id) {
18 return document.defaultView.getComputedStyle(document.getElementById(id), nu ll).getPropertyValue('background-color'); 18 return document.defaultView.getComputedStyle(document.getElementById(id), nu ll).getPropertyValue('background-color');
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 test(function() { 80 test(function() {
81 container.innerHTML = '<input type=submit id=added><form id=f1><input type=s ubmit id=second></form>'; 81 container.innerHTML = '<input type=submit id=added><form id=f1><input type=s ubmit id=second></form>';
82 assert_equals(background('added'), NOT_DEFAULT); 82 assert_equals(background('added'), NOT_DEFAULT);
83 assert_equals(background('second'), DEFAULT); 83 assert_equals(background('second'), DEFAULT);
84 document.querySelector('#added').setAttribute('form', 'f1'); 84 document.querySelector('#added').setAttribute('form', 'f1');
85 assert_equals(background('added'), DEFAULT, 'added button should be default. '); 85 assert_equals(background('added'), DEFAULT, 'added button should be default. ');
86 assert_equals(background('second'), NOT_DEFAULT); 86 assert_equals(background('second'), NOT_DEFAULT);
87 }, 'Adding a button by form content attribute should update the default button.' ); 87 }, 'Adding a button by form content attribute should update the default button.' );
88 88
89 test(function() {
90 container.innerHTML = '<form><input type=checkbox checked id=c1><input type= text checked id=t1></form>';
91 assert_equals(background('c1'), DEFAULT);
92 assert_equals(background('t1'), NOT_DEFAULT);
93 document.querySelector('#c1').type = 'text';
94 document.querySelector('#t1').type = 'checkbox';
95 assert_equals(background('c1'), NOT_DEFAULT);
96 assert_equals(background('t1'), DEFAULT);
97 }, 'Updating type attribute of :default checkbox should update default status');
98
99 test(function() {
100 container.innerHTML = '<form><input type=radio checked id=r1><input type=tex t checked id=t1></form>';
101 assert_equals(background('r1'), DEFAULT);
102 assert_equals(background('t1'), NOT_DEFAULT);
103 document.querySelector('#r1').type = 'text';
104 document.querySelector('#t1').type = 'radio';
105 assert_equals(background('r1'), NOT_DEFAULT);
106 assert_equals(background('t1'), DEFAULT);
107 }, 'Updating type attribute of :default radio should update default status');
108
109 test(function() {
110 container.innerHTML = '<form><input type=checkbox checked id=c1><input type= radio checked id=r1></form>';
111 assert_equals(background('c1'), DEFAULT);
112 assert_equals(background('r1'), DEFAULT);
113 document.querySelector('#c1').defaultChecked = false;
114 document.querySelector('#r1').defaultChecked = false;
115 assert_equals(background('c1'), NOT_DEFAULT);
116 assert_equals(background('r1'), NOT_DEFAULT);
117 }, 'Updating the checked attribute of :default checkbox or radio should update d efault status');
118
119 test(function() {
120 container.innerHTML = '<form><input type=checkbox id=c1><input type=radio id =r1></form>';
121 assert_equals(background('c1'), NOT_DEFAULT);
122 assert_equals(background('r1'), NOT_DEFAULT);
123 if (window.eventSender){
124 var checkbox = document.querySelector('#c1');
125 checkbox.focus();
126 eventSender.keyDown(' ');
127 assert_equals(checkbox.checked, true);
128 assert_equals(background('c1'), NOT_DEFAULT);
129
130 var radio = document.querySelector('#r1');
131 radio.focus();
132 eventSender.keyDown(' ');
133 assert_equals(radio.checked, true);
134 assert_equals(background('r1'), NOT_DEFAULT);
135 }
136 document.querySelector('#c1').setAttribute('checked', 'checked');
137 document.querySelector('#r1').setAttribute('checked', 'checked');
138 assert_equals(background('c1'), DEFAULT);
139 assert_equals(background('r1'), DEFAULT);
140
141 document.querySelector('#c1').removeAttribute('checked');
142 document.querySelector('#r1').removeAttribute('checked');
143 assert_equals(background('c1'), NOT_DEFAULT);
144 assert_equals(background('r1'), NOT_DEFAULT);
145 }, 'Dynamically updating checked status or setting checked attribute should refl ect correct default status');
146
147 test(function() {
148 container.innerHTML = '<form><select><option selected id=o1>1</option><optio n id=o2>2</option></select></form>';
149 assert_equals(background('o1'), DEFAULT);
150 assert_equals(background('o2'), NOT_DEFAULT);
151 document.querySelector('#o1').defaultSelected = false;
152 document.querySelector('#o2').defaultSelected = true;
153 assert_equals(background('o1'), NOT_DEFAULT);
154 assert_equals(background('o2'), DEFAULT);
155 }, 'Updating the selected attribute of :default option element should update def ault status');
156
157 test(function() {
158 container.innerHTML = '<form><select><option id=o1></option><option id=o2></ option</select></form>';
159 assert_equals(background('o1'), NOT_DEFAULT);
160 document.querySelector('#o1').selected = true;
161 assert_equals(background('o1'), NOT_DEFAULT);
162 document.querySelector('#o1').setAttribute('selected', 'selected');
163 assert_equals(background('o1'), DEFAULT);
164 document.querySelector('#o1').removeAttribute('selected');
165 assert_equals(background('o1'), NOT_DEFAULT);
166 }, 'Dynamically updating selected status or setting selected attribute should re flect correct default status');
167
89 </script> 168 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLInputElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698