mirror of
https://github.com/servo/servo.git
synced 2025-07-12 18:03:49 +01:00
40 lines
1.5 KiB
HTML
40 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>CSS Test (Selectors): Keyboard focus enables :focus-visible</title>
|
|
<link rel="author" title="Rob Dodson" href="robdodson@chromium.org" />
|
|
<link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo" />
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<style>
|
|
:focus-visible {
|
|
outline: darkgreen dotted 1px; /* fallback for Edge */
|
|
outline: darkgreen auto 5px;
|
|
}
|
|
|
|
:focus:not(:focus-visible) {
|
|
outline: 0;
|
|
background-color: tomato;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
This test checks that using the Tab key to navigate focus to an element triggers <code>:focus-visible</code> matching.
|
|
<ol id="instructions">
|
|
<li>If the user-agent does not claim to support the <code>:focus-visible</code> pseudo-class then SKIP this test.</li>
|
|
<li>Use the TAB key on the keyboard to focus the element below that says "Focus me."</li>
|
|
<li>If the element has a red background, then the test result is FAILURE. If the element has a green outline, then the test result is SUCCESS.</li>
|
|
</ol>
|
|
<br>
|
|
<div id="el" tabindex="0">Focus me.</div>
|
|
<script>
|
|
async_test(function(t) {
|
|
el.addEventListener("focus", t.step_func(function() {
|
|
assert_equals(getComputedStyle(el).outlineColor, "rgb(0, 100, 0)");
|
|
t.done();
|
|
}));
|
|
}, "Keyboard focus should match :focus-visible");
|
|
</script>
|
|
</body>
|
|
</html>
|