Closed Bug 1865544 Opened 2 years ago Closed 2 years ago

[wpt-sync] Sync PR 43244 - Add Test for text selection when Shadow Root has delegatesFocus enabled

Categories

(Core :: DOM: Core & HTML, task, P4)

task

Tracking

()

RESOLVED FIXED
124 Branch
Tracking Status
firefox124 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 43244 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/43244
Details from upstream follow.

Jesse Jurman <j.r.jurman@gmail.com> wrote:

Add Test for text selection when Shadow Root has delegatesFocus enabled

I recently discovered that text selection has inconsistent behavior across browsers when delegatesFocus is enabled for shadow DOM.

The behavior appears at the moment to be:

  • On Chromium browser (specifically Chrome and Edge), text selection of a non-focusable element (like <span>) does not work if another element in the shadow-root could retrieve focus (like a <button>).
  • On other browsers, like Firefox and Safari, text can be selected and works as it might if the content had been written in the light DOM.

Here's a codepen with two shadow roots, one with delegatesFocus is true, and one where delegatesFocus is false - it has mostly similar content to the test being proposed here: https://codepen.io/JRJurman/pen/gOqvxXz

It's actually not totally obvious what the expected behavior here is, given the description on mdn: https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/delegatesFocus

If true, when a non-focusable part of the shadow DOM is clicked, or .focus() is called on the host element, the first focusable part is given focus, and the shadow host is given any available :focus styling.

I believe the expected behavior here is the implementation found in Firefox and Safari, where text-selection still works as expected.


This has also been documented in the past on stack overflow (however these posts were dismissed by the authors because the feature was experimental at the time).

Component: web-platform-tests → DOM: Core & HTML
Product: Testing → Core

CI Results

Ran 6 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 1 tests and 2 subtests

Status Summary

Firefox

OK : 1
PASS: 2

Chrome

OK : 1
PASS: 1
FAIL: 1

Safari

OK : 1
PASS: 2

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Pushed by wptsync@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2eeab866b934 [wpt PR 43244] - Add Test for text selection when Shadow Root has delegatesFocus enabled, a=testonly
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 124 Branch
You need to log in before you can comment on or make changes to this bug.