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

test: Follow ASCII chart instead of browser's keycodes #19442

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions test/common/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,13 @@ def _key_press_chromium(self, keys: str, modifiers: int = 0, use_ord=False):
self.cdp.invoke("Input.dispatchKeyEvent", **args)

def _key_press_firefox(self, keys: str, modifiers: int = 0, use_ord: bool = False):
# https://github.com/GoogleChrome/puppeteer/blob/master/lib/USKeyboardLayout.js
# https://python-reference.readthedocs.io/en/latest/docs/str/ASCII.html
# Both line feed and carriage return are normalized to Enter (https://html.spec.whatwg.org/multipage/form-elements.html)
keyMap = {
8: "Backspace", # Backspace key
9: "Tab", # Tab key
13: "Enter", # Enter key
10: "Enter", # Enter key (normalized from line feed)
13: "Enter", # Enter key (normalized from carriage return)
27: "Escape", # Escape key
37: "ArrowLeft", # Arrow key left
40: "ArrowDown", # Arrow key down
Expand Down