Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebKit export of https://bugs.webkit.org/show_bug.cgi?id=285811 #50235

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions html/semantics/popovers/popover-focus-2.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,35 @@
assert_equals(document.activeElement,otherElement,'focus does not move because it was not inside the popover');
}, "Popover focus only returns to invoker when focus is within the popover");
</script>

<div id=no-focus-candidate>
<button popovertarget=no-focus-candidate-p tabindex="0">Toggle popover</button>
<div popover id=no-focus-candidate-p>
Popover with <button tabindex="0" popovertarget=no-focus-candidate-p2>focusable element</button>
<div popover id=no-focus-candidate-p2>Nested popover with <button tabindex="0">focusable element</button></div>
</div>
</div>
<script>
promise_test(async t => {
const invoker = document.querySelector('#no-focus-candidate>button');
const popover = document.querySelector('#no-focus-candidate>[popover]');
const nestedPopover = document.querySelector('#no-focus-candidate>[popover]>[popover]');
invoker.focus(); // Make sure button is focused.
assert_equals(document.activeElement,invoker);
invoker.click(); // Activate the invoker
assert_true(popover.matches(':popover-open'), 'popover should be invoked by invoker');
assert_equals(document.activeElement,invoker, 'invoker should still be focused');
await sendTab();
assert_equals(document.activeElement,popover.querySelector('button'),'next up is the popover');
await sendEnter(); // Show nested popover
assert_true(nestedPopover.matches(':popover-open'), 'nested popover should be invoked by invoker');
await sendTab();
assert_equals(document.activeElement, nestedPopover.querySelector('button'), 'focus on the nested popover button');
popover.querySelector('button').disabled = true; // Make the invoker no longer a focus candidate.
await sendShiftTab();
assert_equals(document.activeElement, invoker, 'initial invoker should be focused, nested popover invoker is skipped since it is disabled');
nestedPopover.querySelector('button').focus();
await sendTab();
assert_equals(document.activeElement, document.body, 'no more focusable elements after the button');
}, "Cases where the next focus candidate isn't in the direct parent scope");
</script>
Loading