Intent to ship in Nightly channel and early Beta: `beforeinput` event and `InputEvent.getTargetRanges()`

270 views
Skip to first unread message

Masayuki Nakano

unread,
Sep 17, 2020, 12:15:13 PM9/17/20
to dev-platform
Gecko is the last browser engine which does not support `beforeinput`
event. The event allows web apps to cancel user input **before**
updating the DOM tree, and web apps can modify the DOM tree as they
need. Web apps can know what's going on with `InputEvent.inputType`,
can know what's being inserted with `InputEvent.data` and
`InputEvent.dataTransfer`. They have already released for `input` event.

The new API, `InputEvent.getTargetRanges()` tells web apps where will be
modified with static ranges.

Note that Chrome supports Level 1, Safari supports Level 2 partially.
Due to spec issues of Level 2, we follow Chrome's implementation for now.

Currently landing early timing of the next cycle (83).

Bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=1609291

Standard:
https://w3c.github.io/uievents/#event-type-beforeinput
https://rawgit.com/w3c/input-events/v1/index.html#event-type-beforeinput
https://w3c.github.io/input-events/#event-type-beforeinput
https://rawgit.com/w3c/input-events/v1/index.html#dom-inputevent-gettargetranges
https://w3c.github.io/input-events/#dom-inputevent-gettargetranges

Platform coverage:
All

Preference:
Both of them can be enabled by "dom.input_events.beforeinput.enabled"

Devtools support:
`beforeinput` event listener breakpoint has already been added.

Other browsers:
Chrome (Level 1) and Safari (Level 2 partially)

web-platform-tests:
none for `beforeinput` (because of it requires user input, and test
driver was not when other browsers implement it), but there are a lot of
tests for `getTargetRanges()` which I added (200+).
https://searchfox.org/mozilla-central/source/testing/web-platform/tests/input-events
(FYI: We have a lot of `beforeinput` event tests in mochitests:
https://searchfox.org/mozilla-central/search?q=%22beforeinput%22&path=%2Ftests%2F&case=true&regexp=false)

Restricted to secure contexts: No

--
Masayuki Nakano <masa...@d-toybox.com>
Working on DOM, Events, editor and IME handling for Gecko

James Graham

unread,
Sep 17, 2020, 2:13:47 PM9/17/20
to dev-pl...@lists.mozilla.org
On 17/09/2020 17:14, Masayuki Nakano wrote:
> web-platform-tests:
> none for `beforeinput` (because of it requires user input, and test
> driver was not when other browsers implement it), but there are a lot of
> tests for `getTargetRanges()` which I added (200+).
> https://searchfox.org/mozilla-central/source/testing/web-platform/tests/input-events
>
> (FYI: We have a lot of `beforeinput` event tests in mochitests:
> https://searchfox.org/mozilla-central/search?q=%22beforeinput%22&path=%2Ftests%2F&case=true&regexp=false)

This seems unfortunate. How confident are we that our implementation
works like other browsers? Are there blockers other than time to porting
to mochitests to wpt?

Masayuki Nakano

unread,
Sep 17, 2020, 8:52:18 PM9/17/20
to James Graham, dev-pl...@lists.mozilla.org
Some of them are portable with the test driver, but some of them may
need to change key combination due to shortcut key differences.
Additionally, most of them are not portable. E.g., correcting a word
with builtin spellchecker, autocomplete, switching text direction, input
from IME, etc.

(FYI: The simple editing cases are tested by the `getTargetRanges()` tests.)


Reply all
Reply to author
Forward
0 new messages