-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
HTML: Handle shadow host with delegatesFocus=true in Element.focus(), click and sequential focus navigation #18035
Conversation
Will ad the delegatesFocus test in the delegatesFocus PR instead (web-platform-tests#18035)
…#17523) * HTML: Sequential focus navigation with shadow dom The delegatesFocus test will be in the delegatesFocus PR (web-platform-tests#18035)
…hadow dom, a=testonly Automatic update from web-platform-tests HTML: Sequential focus navigation with shadow dom (#17523) * HTML: Sequential focus navigation with shadow dom The delegatesFocus test will be in the delegatesFocus PR (web-platform-tests/wpt#18035) -- wpt-commits: 888da5c479354a840d253c4acbceb18999bb9bf7 wpt-pr: 17523
…hadow dom, a=testonly Automatic update from web-platform-tests HTML: Sequential focus navigation with shadow dom (#17523) * HTML: Sequential focus navigation with shadow dom The delegatesFocus test will be in the delegatesFocus PR (web-platform-tests/wpt#18035) -- wpt-commits: 888da5c479354a840d253c4acbceb18999bb9bf7 wpt-pr: 17523
…#17523) * HTML: Sequential focus navigation with shadow dom The delegatesFocus test will be in the delegatesFocus PR (web-platform-tests#18035)
Updated the tests after the change in whatwg/html#4796. We have tests for focus() and sequential focus navigation here, since click focus delegation can't really be tested? (there is no difference between focusable and click focusable in Blink) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice exhaustive tests :D.
We should probably also add tests for .click(), I think... in particular checking that it doesn't use sequential focus navigation order, in the way Chrome does currently.
shadow-dom/focus/focus-tabindex-order-shadow-varying-delegatesFocus.html
Show resolved
Hide resolved
resetFocus(); | ||
// Focus should move in flat tree order since every one of them has tabindex ==0, | ||
// but doesn't include slots and #host. | ||
return assertFocusOrder(elementsInFlatTreeOrder.filter(el => (el !== slotAbove && el !== slotBelow && el !== host))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think listing them explicitly would make the test easier to read...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes sense. Changed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nit about explicitly listing them
|
You can do it by |
Tried this just now, looks like this also doesn't trigger the focus on any element I tried it on :( |
Let's at least add a basic test or two that |
Makes sense, added. Thanks! |
test(() => { | ||
resetTabIndexAndFocus(); | ||
setAllTabIndex(0); | ||
test_driver.click(host); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should have these test_driver tests. It feels like a bug in test_driver that it doesn't properly emulate real clicks. So, this test is really a test of test_driver, not a test of the spec, and I think it's testing that test_driver has a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just found out that test_driver.click actually works (click() still won't focus though), so I separated the test driver tests now. PTAL!
test(() => { | ||
resetTabIndexAndFocus(); | ||
setAllTabIndex(0); | ||
test_driver.click(host); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_driver.click() is asynchronous. We need to wait until the retuned promise is resolved.
promise_test(async () => {
reset...
setAll...
await test_driver.click(host);
assert_equals(...
assert_equals(...
}, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG, you're right. It actually focuses now!! Thank you :D
shadow-dom/focus/click-focus-delegatesFocus-tabindex-varies.html
Outdated
Show resolved
Hide resolved
…hadow dom, a=testonly Automatic update from web-platform-tests HTML: Sequential focus navigation with shadow dom (#17523) * HTML: Sequential focus navigation with shadow dom The delegatesFocus test will be in the delegatesFocus PR (web-platform-tests/wpt#18035) -- wpt-commits: 888da5c479354a840d253c4acbceb18999bb9bf7 wpt-pr: 17523 UltraBlame original commit: 514a4abb6174e424e238d5e3ee31819777408e49
…hadow dom, a=testonly Automatic update from web-platform-tests HTML: Sequential focus navigation with shadow dom (#17523) * HTML: Sequential focus navigation with shadow dom The delegatesFocus test will be in the delegatesFocus PR (web-platform-tests/wpt#18035) -- wpt-commits: 888da5c479354a840d253c4acbceb18999bb9bf7 wpt-pr: 17523 UltraBlame original commit: 514a4abb6174e424e238d5e3ee31819777408e49
…hadow dom, a=testonly Automatic update from web-platform-tests HTML: Sequential focus navigation with shadow dom (#17523) * HTML: Sequential focus navigation with shadow dom The delegatesFocus test will be in the delegatesFocus PR (web-platform-tests/wpt#18035) -- wpt-commits: 888da5c479354a840d253c4acbceb18999bb9bf7 wpt-pr: 17523 UltraBlame original commit: 514a4abb6174e424e238d5e3ee31819777408e49
We should use flat-tree order instead of tabindex order, add test to ensure that.
// No focusable element under #host in the flat tree. | ||
host.focus(); | ||
assert_equals(shadowRoot.activeElement, null); | ||
assert_equals(document.activeElement, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be document.body
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
// No focusable element under #host in the flat tree. | ||
host.focus(); | ||
assert_equals(shadowRoot.activeElement, null); | ||
assert_equals(document.activeElement, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
setTabIndex([aboveSlot], 2); | ||
setTabIndex([slot, slotted], 1); | ||
await test_driver.click(host); | ||
assert_equals(shadowRoot.activeElement, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearly you meant aboveSlot here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, thanks!
setTabIndex([slot, slotted], 1); | ||
await test_driver.click(host); | ||
assert_equals(shadowRoot.activeElement, null); | ||
assert_equals(document.activeElement, aboveSlot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And host here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @rniwa!
setTabIndex([slot, slotted], 1); | ||
await test_driver.click(host); | ||
assert_equals(shadowRoot.activeElement, null); | ||
assert_equals(document.activeElement, aboveSlot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
setTabIndex([aboveSlot], 2); | ||
setTabIndex([slot, slotted], 1); | ||
await test_driver.click(host); | ||
assert_equals(shadowRoot.activeElement, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, thanks!
// No focusable element under #host in the flat tree. | ||
host.focus(); | ||
assert_equals(shadowRoot.activeElement, null); | ||
assert_equals(document.activeElement, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
// No focusable element under #host in the flat tree. | ||
host.focus(); | ||
assert_equals(shadowRoot.activeElement, null); | ||
assert_equals(document.activeElement, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me.
This is the last piece of #2013. Incoporating support for delegates-focus shadow roots into the focusing steps impact the behavior of programmatic and click focus. (Sequential focus navigation was handled in d19d963.) Tests: web-platform-tests/wpt#18035
This is the last piece of #2013. Incoporating support for delegates-focus shadow roots into the focusing steps impact the behavior of programmatic and click focus. (Sequential focus navigation was handled in d19d963.) Tests: web-platform-tests/wpt#18035
WPT for whatwg/html#4796.
As noted there, the behavior in Chrome for focus() when the flattened tabindex-ordered focus navigation scope is empty (there's nothing to focus on) so it fails in some of the tests.