Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!doctype html>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<div id="one" tabindex="1">One</div>
<div id="two" tabindex="1">Two</div>
<script>
let one = document.getElementById("one");
let two = document.getElementById("two");
document.addEventListener("keydown", function(e) {
two.focus();
});
promise_test(async t => {
await test_driver.click(one);
assert_equals(document.activeElement, one, "#one should be focused by mouse");
assert_true(one.matches(":focus"), "#one should match :focus");
assert_true(!one.matches(":focus-visible"), "#one should not match :focus-visible");
await test_driver.send_keys(document.body, " ");
assert_equals(document.activeElement, two, "#two should be focused by our event listener");
assert_true(two.matches(":focus"), "#two should match :focus");
assert_true(two.matches(":focus-visible"), "#two should match :focus-visible");
});
</script>