focus-visible-016.html (1829B)
1 <!DOCTYPE html> 2 <meta charset="utf-8" /> 3 <title>CSS Selectors Test: :focus-visible always match on text inputs</title> 4 <link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com"> 5 <link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo" /> 6 <meta name="assert" content="This test checks that even if the active element does not match ':focus-visible' and a script causes focus to move into a text input, the text input should match ':focus-visible'."> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/resources/testdriver.js"></script> 10 <script src="/resources/testdriver-vendor.js"></script> 11 <style> 12 @supports not selector(:focus-visible) { 13 :focus { 14 outline: red solid 5px; 15 background-color: red; 16 } 17 } 18 19 div:focus-visible { 20 background: red; 21 } 22 23 div:focus:not(:focus-visible) { 24 background-color: lime; 25 } 26 27 input:focus-visible { 28 background: lime; 29 } 30 31 input:focus:not(:focus-visible) { 32 background-color: red; 33 } 34 </style> 35 36 <div id="initial" tabindex="0">Initial</div> 37 <input id="target" /> 38 39 <script> 40 setup({ explicit_done: true }); 41 42 async_test(function(t) { 43 initial.addEventListener("focus", t.step_func(function() { 44 assert_equals(getComputedStyle(initial).backgroundColor, "rgb(0, 255, 0)", `backgroundColor for ${initial.tagName}#${initial.id} should be lime`); 45 target.focus(); 46 })); 47 48 target.addEventListener("focus", t.step_func(function() { 49 assert_equals(getComputedStyle(target).backgroundColor, "rgb(0, 255, 0)", `backgroundColor for ${target.tagName}#${target.id} should be lime`); 50 t.done(); 51 })); 52 53 test_driver.click(initial).then(() => done()); 54 }, ":focus-visible always match on text inputs"); 55 </script>