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

WebDriver: [macOS] [Actions] [Key] Shift modifier not applying to typed text #7208

Conversation

patrickangle
Copy link
Contributor

@patrickangle patrickangle commented Dec 6, 2022

7bee9f5

WebDriver: [macOS] [Actions] [Key] Shift modifier not applying to typed text
https://bugs.webkit.org/show_bug.cgi?id=248770
rdar://100588610

Reviewed by BJ Burg.

AppKit expects the `characters` for an NSEvent to be pre-transformed to the actual character that will be typed, which
means for a capital letter, sending the key code for a letter with the shift modifier held should result in the capital
form of that letter being the `characters`. This also add support for composed characters, like Shift+Option+K resulting
in the Apple logo, or Shift+Option+8 resulting in the degree symbol.

The clearest way to obtain the OS-defined mapping for a letter and its modifiers is to create a temporary NSEvent and
call `-[NSEvent characterTransformingModifiers:]`, which applies the provided modifiers to an existing event's
`characters`, which we can then use to create the actual NSEvents we will dispatch to the system. Alternatively, we
could hardcode WebDriver's list of "shifted" characters, but that only covers keys on a US-English keyboard, and does
not provide any allowance for macOS's various Option/Shift modified key chords to produce special characters.

This progresses the following WPT test cases:
webdriver/tests/perform_actions/key_modifiers.py::test_shift_modifier_generates_capital_letters[\ue008]
webdriver/tests/perform_actions/key_modifiers.py::test_shift_modifier_generates_capital_letters[\ue050]

* Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm:
(WebKit::WebAutomationSession::platformSimulateKeyboardInteraction):

Canonical link: https://commits.webkit.org/259039@main

f0e0e90

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ›  gtk βœ… πŸ›  wincairo
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac ❌ πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-wk2
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch βœ… πŸ§ͺ mac-wk2-stress
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch-sim

@patrickangle patrickangle self-assigned this Dec 6, 2022
@patrickangle patrickangle added the WebDriver Bugs in WebDriver label Dec 6, 2022
Copy link
Contributor

@burg burg left a comment

Choose a reason for hiding this comment

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

Nice fix!

@patrickangle patrickangle force-pushed the eng/b248770-webdriver-macos-characters-not-honoring-modifiers branch from 2cef1f2 to f0e0e90 Compare January 17, 2023 21:55
@patrickangle patrickangle added the merge-queue Applied to send a pull request to merge-queue label Jan 18, 2023
…ed text

https://bugs.webkit.org/show_bug.cgi?id=248770
rdar://100588610

Reviewed by BJ Burg.

AppKit expects the `characters` for an NSEvent to be pre-transformed to the actual character that will be typed, which
means for a capital letter, sending the key code for a letter with the shift modifier held should result in the capital
form of that letter being the `characters`. This also add support for composed characters, like Shift+Option+K resulting
in the Apple logo, or Shift+Option+8 resulting in the degree symbol.

The clearest way to obtain the OS-defined mapping for a letter and its modifiers is to create a temporary NSEvent and
call `-[NSEvent characterTransformingModifiers:]`, which applies the provided modifiers to an existing event's
`characters`, which we can then use to create the actual NSEvents we will dispatch to the system. Alternatively, we
could hardcode WebDriver's list of "shifted" characters, but that only covers keys on a US-English keyboard, and does
not provide any allowance for macOS's various Option/Shift modified key chords to produce special characters.

This progresses the following WPT test cases:
webdriver/tests/perform_actions/key_modifiers.py::test_shift_modifier_generates_capital_letters[\ue008]
webdriver/tests/perform_actions/key_modifiers.py::test_shift_modifier_generates_capital_letters[\ue050]

* Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm:
(WebKit::WebAutomationSession::platformSimulateKeyboardInteraction):

Canonical link: https://commits.webkit.org/259039@main
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/b248770-webdriver-macos-characters-not-honoring-modifiers branch from f0e0e90 to 7bee9f5 Compare January 18, 2023 18:32
@webkit-commit-queue
Copy link
Collaborator

Committed 259039@main (7bee9f5): https://commits.webkit.org/259039@main

Reviewed commits have been landed. Closing PR #7208 and removing active labels.

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jan 18, 2023
@webkit-early-warning-system webkit-early-warning-system merged commit 7bee9f5 into WebKit:main Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebDriver Bugs in WebDriver
Projects
None yet
4 participants