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

HTML: Handle shadow host with delegatesFocus=true in Element.focus(), click and sequential focus navigation #18035

Merged
merged 9 commits into from
Oct 16, 2019

Conversation

rakina
Copy link
Contributor

@rakina rakina commented Jul 24, 2019

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.

rakina added a commit to rakina/wpt that referenced this pull request Aug 15, 2019
Will ad the delegatesFocus test in the delegatesFocus PR instead (web-platform-tests#18035)
pull bot pushed a commit to hoojaoh/web-platform-tests that referenced this pull request Aug 15, 2019
…#17523)

* HTML: Sequential focus navigation with shadow dom

The delegatesFocus test will be in the delegatesFocus PR (web-platform-tests#18035)
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Aug 23, 2019
…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
xeonchen pushed a commit to xeonchen/gecko that referenced this pull request Aug 23, 2019
…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
natechapin pushed a commit to natechapin/wpt that referenced this pull request Aug 23, 2019
…#17523)

* HTML: Sequential focus navigation with shadow dom

The delegatesFocus test will be in the delegatesFocus PR (web-platform-tests#18035)
@rakina rakina changed the title HTML: Handle shadow host with delegatesFocus=true in Element.focus() HTML: Handle shadow host with delegatesFocus=true in Element.focus() and sequential focus navigation Sep 25, 2019
@rakina
Copy link
Contributor Author

rakina commented Sep 25, 2019

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)

Copy link
Member

@domenic domenic left a 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.

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)));
Copy link
Member

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...

Copy link
Contributor Author

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!

Copy link
Member

@domenic domenic left a 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

@rakina
Copy link
Contributor Author

rakina commented Sep 26, 2019

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.

click() fires a synthetic click event, which triggers activation behavior but not focus - discovered this with @tkent-google earlier today, gotta update that part of the spec D: - so we can't test click focus with that. I'm not sure if there's another way to trigger clicks in WPTs...

@tkent-google
Copy link
Contributor

I'm not sure if there's another way to trigger clicks in WPTs...

You can do it by test_driver.click(element).

@rakina
Copy link
Contributor Author

rakina commented Sep 27, 2019

I'm not sure if there's another way to trigger clicks in WPTs...

You can do it by test_driver.click(element).

Tried this just now, looks like this also doesn't trigger the focus on any element I tried it on :(

@domenic
Copy link
Member

domenic commented Sep 27, 2019

Let's at least add a basic test or two that .click() does not focus things, since we also need to update that in the PR.

@rakina rakina changed the title HTML: Handle shadow host with delegatesFocus=true in Element.focus() and sequential focus navigation HTML: Handle shadow host with delegatesFocus=true in Element.focus(), click and sequential focus navigation Sep 27, 2019
@rakina
Copy link
Contributor Author

rakina commented Sep 27, 2019

Let's at least add a basic test or two that .click() does not focus things, since we also need to update that in the PR.

Makes sense, added. Thanks!

test(() => {
resetTabIndexAndFocus();
setAllTabIndex(0);
test_driver.click(host);
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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(...
}, ...

Copy link
Contributor Author

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.html Outdated Show resolved Hide resolved
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 4, 2019
…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
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 4, 2019
…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
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 4, 2019
…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);
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And host here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor Author

@rakina rakina left a 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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@rniwa rniwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me.

domenic pushed a commit to whatwg/html that referenced this pull request Oct 16, 2019
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
@domenic domenic merged commit e2ee0f7 into web-platform-tests:master Oct 16, 2019
zcorpan pushed a commit to whatwg/html that referenced this pull request Nov 6, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants