-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
This causes a failure in PR cockpit-project/cockpit-machines#1150, where I try to input a text with newline into a textarea using "set_input_text", but it fails because our testlib._key_press_firefox expects newline to have value of 13 (as is browser's keycode for newline character), but instead a value of 10 is provided (as that's the value a Python's
|
Note that this is an issue only for firefox |
test/common/testlib.py
Outdated
13: "Enter", # Enter key | ||
10: "Enter", # Enter key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
13 is carriage return (enter key)
10 is not enter, but linefeed
The issue is the handling of CRLF.
Until now, we were mapping values of characters to their browser's keycodes values [1]. This however is incorrect, since to get a value of character, we use Python's 'ord' function, which returns character's Unicode value. In some cases, these values are different. For example, a value for Enter has keycode '13' in browser [1], but Python's 'ord' will give us value of '10' for a line feed character. [2] [1] https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode [2] https://python-reference.readthedocs.io/en/latest/docs/str/ASCII.html
Thanks! LGTM, but I'd really like to get a CI run -- and with that being down, we'll have to wait until tomorrow-ish I'm afraid 😢 |
Until now, we were mapping values of characters to their browser's keycodes values [1]. This however is incorrect, since to get a value of character, we use Python's 'ord' function, which returns character's Unicode value.
In some cases, these values are different. For example, a value for newline key has keycode '13' in browser [1], but Python's 'ord' will give us value of '10' [2].
[1] https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
[2] https://python-reference.readthedocs.io/en/latest/docs/str/ASCII.html