Bug 1545675 [wpt PR 16364] - WPT/BGPT: Add animation stop and set time tests, make...
[gecko.git] / testing / web-platform / tests / css / selectors / focus-visible-010.html
blobeb01204b29c8e30b651b083459c01983b99dd70d
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <title>CSS Test (Selectors): Keyboard focus enables :focus-visible</title>
6 <link rel="author" title="Alice Boxhall" href="aboxhall@chromium.org" />
7 <link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo" />
8 <script src="/resources/testharness.js"></script>
9 <script src="/resources/testharnessreport.js"></script>
10 <style>
11 :focus-visible {
12 outline: darkgreen auto 5px;
15 :focus:not(:focus-visible) {
16 background-color: tomato;
17 outline: 0;
19 </style>
20 </head>
21 <body>
22 This test checks that any element focused programmatically on page load will have <code>:focus-visible</code> matching enabled.
23 <ul id="instructions">
24 <li>If the element that says "I will be focused automatically" has a red background, then the test result is FAILURE. If the element has a green outline, then the test result is SUCCESS.</li>
25 </ul>
26 <br />
27 <div id="el" tabindex="-1">I will be focused automatically.</el>
28 <script>
29 window.addEventListener('load', () => {
30 el.focus();
31 });
33 async_test(function(t) {
34 el.addEventListener("focus", t.step_func(function() {
35 assert_equals(getComputedStyle(el).outlineColor, "rgb(0, 100, 0)");
36 t.done();
37 }));
38 }, "Programmatic focus on page load bshould match :focus-visible");
39 </script>
40 </body>
41 </html>