focus-visible-018.html (1858B)
1 <!DOCTYPE html> 2 <meta charset="utf-8" /> 3 <title>CSS Test (Selectors): Mouse focus does not show a focus ring by default</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 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/resources/testdriver.js"></script> 9 <script src="/resources/testdriver-actions.js"></script> 10 <script src="/resources/testdriver-vendor.js"></script> 11 <script src="/css/support/parsing-testcommon.js"></script> 12 <style> 13 #warning { 14 display: none; 15 background: red; 16 } 17 18 @supports not selector(:focus-visible) { 19 #instructions { 20 display: none; 21 } 22 23 #warning { 24 display: block; 25 } 26 } 27 </style> 28 29 <p>This test checks that by default, using the mouse to focus a generic element does not show a focus ring (because it does not trigger <code>:focus-visible</code> matching).</p> 30 <ol id="instructions"> 31 <li>Click on the element below that says "Click me."</li> 32 <li>If the element does not have a focus ring, then the test result is SUCCESS.</li> 33 </ol> 34 <p id="warning">Your user-agent does not support <code>:focus-visible</code> pseudo-class, please SKIP this test.</p> 35 <div id="target" tabindex="0">Click me.</div> 36 <script> 37 setup({ explicit_done: true }); 38 39 // Check that :focus-visible is supported. 40 test_valid_selector(':focus-visible'); 41 42 async_test(function(t) { 43 target.addEventListener("focus", t.step_func(function() { 44 assert_equals(getComputedStyle(target).outlineStyle, "none", `outline-style for ${target.tagName}#${target.id} should be none`); 45 t.done(); 46 })); 47 test_driver.click(target).then(() => done()); 48 }, "Mouse focus does not show a focus ring by default"); 49 </script>