Skip to content

Commit

Permalink
[selectors] Add new test for :focus-visible
Browse files Browse the repository at this point in the history
This test checks that when you click an element to focus it,
it doesn't show any kind of focus ring. See issue #4278.

Currently Firefox passes this test, by Chromium fails it
because Chromium is using `:focus` on the default UA stylesheet
and is adding an outline on the element, despite it doesn't match
:focus-visible (see https://crbug.com/1162070).
  • Loading branch information
mrego committed Dec 28, 2020
1 parent ccaf459 commit 30c6ca0
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions css/selectors/focus-visible-001.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,13 @@
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<style>
@supports not (selector(:focus-visible)) {
:focus {
background-color: tomato;
}
}

:focus-visible {
outline: darkgreen solid 5px;
outline: green solid 5px;
}

:focus:not(:focus-visible) {
outline: 0;
background-color: tomato;
background-color: red;
}
</style>
</head>
Expand All @@ -39,7 +33,8 @@
<script>
async_test(function(t) {
el.addEventListener("focus", t.step_func(function() {
assert_equals(getComputedStyle(el).outlineColor, "rgb(0, 100, 0)");
assert_equals(getComputedStyle(el).outlineColor, "rgb(0, 128, 0)", `outlineColor for ${el.tagName}#${el.id} should be green`);
assert_not_equals(getComputedStyle(el).backgroundColor, "rgb(255, 0, 0)", `backgroundColor for ${el.tagName}#${el.id} should NOT be red`);
t.done();
}));
const tab_key = '\ue004';
Expand Down

0 comments on commit 30c6ca0

Please sign in to comment.