Automatic update from web-platform-tests Fix focus ring for anchor elements (#57845) Anchor elements have special behavior to prevent a focus ring from being rendered when the last user focus was done via keyboard and it was then focused via script, which was (probably) added here: https://issues.chromium.org/issues/40383506 This inconsistency with other keyboard focusable elements is not a good thing, and I don't agree with the justification from the bug report which added the inconsistency, so this patch removes the special behavior by removing HTMLAnchorElementBase::ShouldHaveFocusAppearance. Fixed: 40848191 Bug: 40383506, 40911863 Change-Id: Ifa80ca5596c4eec4a4ddd31338525668a77137d1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6354078 Reviewed-by: David Baron <dbaron@chromium.org> Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1586082} Co-authored-by: Joey Arhar <jarhar@chromium.org> -- wpt-commits: 49a71206e378301e89b73178509296df26ee5283 wpt-pr: 57845
35 lines
1.0 KiB
HTML
35 lines
1.0 KiB
HTML
<!DOCTYPE html>
|
|
<html class=reftest-wait>
|
|
<link rel=author href="mailto:jarhar@chromium.org">
|
|
<link rel=help href="https://issues.chromium.org/issues/40848191">
|
|
<link rel=mismatch href="anchor-element-focus-ring-ref.html">
|
|
<script src="/resources/testdriver.js"></script>
|
|
<script src="/resources/testdriver-vendor.js"></script>
|
|
|
|
<!--
|
|
This test verifies that focusing via script after using the keyboard shows a
|
|
focus ring on the <a> element. Since using testdriver doesn't seem to be
|
|
working in the ref file, we mismatch with a ref which doesn't have a focus
|
|
ring.
|
|
-->
|
|
|
|
<div tabindex=0>button</div>
|
|
<a href="#">anchor</a>
|
|
|
|
<script>
|
|
const anchor = document.querySelector('a');
|
|
const button = document.querySelector('div');
|
|
const tabKey = '\uE004';
|
|
document.body.addEventListener('keydown', event => {
|
|
if (event.key == 'Tab') {
|
|
event.preventDefault();
|
|
anchor.focus();
|
|
}
|
|
});
|
|
(async () => {
|
|
await test_driver.click(button);
|
|
await test_driver.send_keys(document.body, tabKey);
|
|
document.documentElement.classList.remove('reftest-wait');
|
|
})();
|
|
</script>
|