Closed Bug 1685491 Opened 3 years ago Closed 3 years ago

Cannot test `Home`, `End`, `PageDown`, `PageUp` etc, on Linux and macOS

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P2)

defect

Tracking

()

RESOLVED FIXED
87 Branch
Tracking Status
firefox86 --- wontfix
firefox87 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(5 files)

On Linux and macOS, some shortcut keys are not defined by our UI, instead, NativeKeyBindings retrieve command for the keys in the environment to honor the system settings. For making mochitest and WPT independent from system settings, we don't check such system settings at generating keydown events.

However, this makes some tests need to handle specially with checking the platform.

I think that NativeKeyBindings should have static methods to map typical system settings instead. Then, tests won't depend on system setting differences, and tests can run without checking platforms.

Currently, we don't allow keyboard events synthesized for tests retrieve native
key bindings in content process. However, due to this, we cannot test keyboard
navigation, deleting per word, etc on Linux and macOS either with mochitest
or WPT. For making better compatibility with the other browsers, we should
write WPT more with the test driver. Therefore, we should allow keyboard
events synthesized for tests retrieve native key bindings.

On the other hand, if we make them retrieve customized keyboard shortcuts
in the environment, some developers may not run tests locally without
stopping their customization. Therefore, this patch makes NativeKeyBindings
set "standard" shortcut keys on the platform.

If this is not good thing for WebDriver/CDP, perhaps, TextInputProcessor
should have a new flag which can refer customized shortcut keys even in content
process. But I think that it should be done in another bug because some
edit commands are mapped forcibly like this patch.
https://searchfox.org/mozilla-central/rev/c03e8de87cdb0ce0378c0886d3c0ce8bbf9dc44e/remote/domains/parent/Input.jsm#82-102

Applying default edit action for some shortcut keys on Linux and macOS
causes some oranges. The new failure reasons are:

  • The keyboard events are consumed in the bubbling phase of the system
    group if editor has focus (EditorEventListener or TextInputListener
    does it).
  • No key combinations are mapped to per-word move or select on macOS.
  • Home/End keys on macOS do not change selection.

Therefore, this adjusts each failure case for the new behavior.

Depends on D102877

Some mochitests use nsISelectionController instead of synthesizing key since
Home, End, PageUp and PageDown didn't work as native key event.

Depends on D102878

On macOS, Home and End just scroll the scrollable element (i.e., not moving
caret position), ArrowLeft and ArrowRight with Meta (command key) work as
same as the other platforms. So, this patch fixes some WPT too. This may help
failures on Safari too.

Depends on D102879

Currently, this feature is implemented only on Linux and macOS (see also
bug 1077515 and bug 1301497), and the code is really similar each other.
Additionally, it always tries to query selection to check whether the caret is
in vertical content or not if arrow keys are pressed. For avoiding a lot of
query, this patch makes TextEventDispatcher cache writing mode at every
selection change notification. However, unfortunately, it's not available when
non-editable content has focus, but it should be out of scope of this bug since
it requires a lot of changes.

Anyway, with this patch, we can write a mochitest only on Linux and macOS.
The following patch adds a test for this as a fix of bug 1103374.

Depends on D102880

No longer blocks: 1301497
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/a17e953b80f8
part.1: Map typical commands to synthesized keyboard events for test on Linux and macOS r=smaug,remote-protocol-reviewers
https://hg.mozilla.org/integration/autoland/rev/49ca8740a116
part 2: Fix all new oranges caused by the previous patch r=smaug
https://hg.mozilla.org/integration/autoland/rev/719303fc1d0e
part 3: Fix some mochitests for conforming to use system default shortcut keys r=smaug
https://hg.mozilla.org/integration/autoland/rev/2d2d69daa750
part 4: Make typing-around-link-element-at-collapsed-selection.tentative.html use `Meta` + `ArrowLeft`/`ArrowRight` instead of unmodified `Home`/`End` on macOS r=smaug
https://hg.mozilla.org/integration/autoland/rev/08a804df3b6c
part 5: Move the code remapping arrow keys in vertical content to `NativeKeyBindings` r=smaug,jfkthame
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/27437 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot

The patch landed in nightly and beta is affected.
:masayuki, is this bug important enough to require an uplift?
If not please set status_beta to wontfix.

For more information, please visit auto_nag documentation.

Flags: needinfo?(masayuki)

This is just an improvement of test APIs on macOS and Linux. So, we don't need to uplift them.

Flags: needinfo?(masayuki)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: