Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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=second></form>'; | |
| 121 assert_equals(background('second'), NOT_DEFAULT); | |
| 122 var input = document.createElement('input'); | |
| 123 input.id='added'; | |
| 124 input.type = 'checkbox'; | |
| 125 input.defaultChecked = true; | |
| 126 document.querySelector('form').insertBefore(input, document.querySelector('# second')); | |
| 127 assert_equals(background('added'), DEFAULT); | |
| 128 }, 'Adding a checkbox with checked attribute dynamically to a DOM tree should re flect the default checkbox.'); | |
|
tkent
2016/03/07 05:22:34
Plese remove this test.
This test isn't helpful be
ramya.v
2016/03/07 10:03:02
Done.
| |
| 129 | |
| 130 test(function() { | |
| 131 container.innerHTML = '<form><input type=radio id=second></form>'; | |
| 132 assert_equals(background('second'), NOT_DEFAULT); | |
| 133 var input = document.createElement('input'); | |
| 134 input.id='added'; | |
| 135 input.type = 'radio'; | |
| 136 input.defaultChecked = true; | |
| 137 document.querySelector('form').insertBefore(input, document.querySelector('# second')); | |
| 138 assert_equals(background('added'), DEFAULT); | |
| 139 }, 'Adding a radio element with checked attribute dynamically to a DOM tree shou ld reflect the default radio element.'); | |
|
tkent
2016/03/07 05:22:33
Ditto.
ramya.v
2016/03/07 10:03:02
Done.
| |
| 140 | |
| 141 test(function() { | |
| 142 container.innerHTML = '<form><select><option selected id=o1>1</option><optio n id=o2>2</option></select></form>'; | |
| 143 assert_equals(background('o1'), DEFAULT); | |
| 144 assert_equals(background('o2'), NOT_DEFAULT); | |
| 145 document.querySelector('#o1').defaultSelected = false; | |
| 146 document.querySelector('#o2').defaultSelected = true; | |
| 147 assert_equals(background('o1'), NOT_DEFAULT); | |
| 148 assert_equals(background('o2'), DEFAULT); | |
| 149 | |
| 150 }, 'Updating the selected attribute of :default option element should update def ault status'); | |
| 151 | |
| 152 test(function() { | |
| 153 container.innerHTML = '<form><select><option id=first>1</option></select></f orm>'; | |
| 154 assert_equals(background('first'), NOT_DEFAULT); | |
| 155 var option = document.createElement('option'); | |
| 156 option.id='added'; | |
| 157 option.value = '2'; | |
| 158 option.defaultSelected = true; | |
| 159 document.querySelector('select').appendChild(option); | |
| 160 assert_equals(background('added'), DEFAULT); | |
| 161 | |
| 162 }, 'Adding an option element dynamically to a DOM tree should reflect default op tion element.'); | |
|
tkent
2016/03/07 05:22:33
Ditto.
ramya.v
2016/03/07 10:03:02
Done.
| |
| 163 | |
| 89 </script> | 164 </script> |
|
tkent
2016/03/07 05:22:34
Please add the following tests:
* A radio/checkbo
ramya.v
2016/03/07 10:03:02
Done.
| |
| OLD | NEW |