checkable-active-onblur.html (2001B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org"> 4 <link rel="help" href="http://crbug.com/1157510"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testdriver.js"></script> 8 <script src="/resources/testdriver-actions.js"></script> 9 <script src="/resources/testdriver-vendor.js"></script> 10 11 <!-- This behavior is not explicitly specified. --> 12 13 <input type=checkbox id=checkbox checked> 14 <input type=radio id=radio checked> 15 16 <script> 17 promise_test(async t => { 18 checkbox.focus(); 19 20 // Hold spacebar down 21 await (new test_driver.Actions()).keyDown('\uE00D').send(); 22 t.add_cleanup(async () => { 23 // Release spacebar 24 await (new test_driver.Actions()).keyUp('\uE00D').send(); 25 }); 26 assert_equals(document.querySelector('input:active'), checkbox, 27 'Checkboxes should be :active while the spacebar is pressed down.'); 28 29 // Press tab 30 await (new test_driver.Actions()).keyDown('\uE004').keyUp('\uE004').send(); 31 assert_equals(document.querySelector(':active'), null, 32 'Checkboxes should not be :active after tab is used to change focus.'); 33 }, 'Checkboxes should clear :active when the user tabs away from them while holding spacebar.'); 34 35 promise_test(async t => { 36 radio.focus(); 37 38 // Hold spacebar down 39 await (new test_driver.Actions()).keyDown('\uE00D').send(); 40 t.add_cleanup(async () => { 41 // Release spacebar 42 await (new test_driver.Actions()).keyUp('\uE00D').send(); 43 }); 44 assert_equals(document.querySelector('input:active'), radio, 45 'Radios should be :active while the spacebar is pressed down.'); 46 47 // Press tab 48 await (new test_driver.Actions()).keyDown('\uE004').keyUp('\uE004').send(); 49 assert_equals(document.querySelector(':active'), null, 50 'Radios should not be :active after tab is used to change focus.'); 51 }, 'Radios should clear :active when the user tabs away from them while holding spacebar.'); 52 </script>