mirror of
https://github.com/servo/servo.git
synced 2025-07-02 21:13:39 +01:00
38 lines
1.6 KiB
HTML
38 lines
1.6 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 { background-color: rgb(128, 196, 128); }
|
|
:focus:not(:focus-visible) { background-color: rgb(196, 128, 128); }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<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>Click the button below that says "Click me."</li>
|
|
<li>If the element that says "I will be focused programmatically." does not have a <strong>green</strong> background, then the test result is FAILURE. If the element <em>has</em> a <strong>green</strong> background, then the test result is SUCCESS.</li>
|
|
</ol>
|
|
<br />
|
|
<button id="button">Click me.</button>
|
|
<div id="el" tabindex="-1">I will be focused programmatically.</el>
|
|
<script>
|
|
button.addEventListener("click", () => {
|
|
el.focus();
|
|
});
|
|
async_test(function(t) {
|
|
el.addEventListener("focus", t.step_func(() => {
|
|
assert_equals(getComputedStyle(el).backgroundColor,
|
|
"rgb(128, 196, 128)");
|
|
t.done();
|
|
}));
|
|
el.focus();
|
|
}, "Programmatic focus should always match :focus-visible");
|
|
</script>
|
|
</body>
|
|
</html>
|