-
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
shell: Fix and test skip links #20561
Conversation
The existing `key_press()` is named and implemented poorly, is hard to use for non-letter characters and requires Chromium/Firefox specific implementations. Introduce a new `key()` function which takes a *single* key name. This is portable across browsers, and something like "Enter" is much easier to read than "\r". TestHostSwitching.testEdit already used it that way.
@marusak As you introduced the skip links, I'd appreciate your review. My interactive test seems quite reasonable now (no reloads and focusing works), but I'd like to make sure it's what you had in mind. @jelly You recently dabbled with the keyboard test API -- please let me know if |
# FIXME: This should be key_press(), and key_press() should be something else | ||
def key(self, name: str) -> None: | ||
self.cdp.invoke("Input.dispatchKeyEvent", type="keyDown", key=name) | ||
self.cdp.invoke("Input.dispatchKeyEvent", type="keyUp", key=name) |
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.
key
sounds like a good compromise, breaking key_press
is imo a no-go at this moment as everyone uses it.
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.
Yes, I thought about .key()
and .input_text()
, moving everything over to these two, and eventually dropping .key_press()
We don't want the skiplinks to *actually* change the URL -- they will go from e.g. `/system` to `/cockpit/@localhost/shell/index.html#content`. This causes a page reload, breaks the focusing, and is also not an URL which we actually want to expose. Fix this by stopping event progression. Also remove the `return false` -- event handlers don't return anything [1]. Introduce a `TestMenu.testKeyboardNavigation` -- skip links and tabbing was previously not tested at all. [1] https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback
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.
Works for me, thanks!
We don't want the skiplinks to actually change the URL -- they will go
from e.g.
/system
to/cockpit/@localhost/shell/index.html#content
.This causes a page reload, breaks the focusing, and is also not an URL
which we actually want to expose. Fix this by stopping event
progression.
Also remove the
return false
-- event handlers don't return anything.Introduce a
TestMenu.testKeyboardNavigation
-- skip links and tabbingwas previously not tested at all.
[1] https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#the_event_listener_callback
Preparation for #20553 -- let's first test skiplinks before we change them.