-
Notifications
You must be signed in to change notification settings - Fork 7
Description
From display: contents testing work, we've identified opportunities to expand testing coverage in accessibility interop to include keyboard testing.
Common keyboard web accessibility issues which may be WPT-testable include:
- lack of focusability (i.e., an element is neither tabbable nor programmatically focusable)
- keyboard traps (i.e., an element may receive focus but focus cannot subsequently be moved to the previous/next focusable element)
- general lack of expected keyboard operability (e.g., a button-like element is not operable with Enter/Return or Spacebar)
- focus management issues (e.g., dismissing
<dialog>oralert()element should return focus to the triggering control) - modal interfaces that don't hide hidden/inert controls outside the modal window
- missing visible keyboard focus indication (likely non-trivial but may be possible!)
Current WPT keyboard APIs/utilities and proposed stuff
In addition to our currently utilized test_driver.get_computed_label() and test_driver.get_computed_role() functions, testdriver.js includes APIs for actions such as keyboard operation (testdriver-actions.js Actions API).
testdriver-actions.js has a number of functions to simulate keyboard operation (such as .keyUp()) however, accessibility-focused utilities that address common a11y issues like the above are unavailable.
Some proposed new keyboard testing functions:
isFocusable(): usesassert_equals()and JS.focus()to verifydocument.activeElement; alternatively, we could simulate a Tab key press and check that the element is focusedisTabbable: usestest_driver.send_keys()to operate an element with the Tab keyisFocused(): e.g., when a modal overlay is dismissed, checks that the appropriate element has focusisNotFocused(): usesassert_not_equals()to verify that the current element is notdocument.activeElement(or has been keyboard-navigated away from)isKeyboardOperable(someKeys): given a set of keys, ensure that pressing them dispatches appropriate eventverifyFocusIsTrapped(): given a DOM node, walks all focusable descendants and ensures that only they are in the focus/tab orderverifyFocusOutline(): check if an element draws a focus ring
These could be written as either a common WPT utility, or set of functions exposed by testdriver.js. I recognize that some of these tests may belong outside of accessibility interop, and likely tested outside of it too, but it could simplify/support external testing efforts as well to standardize WPT keyboard testing.
General examples of keyboard testing in other WPT areas
I've identified some notable existing keyboard-focused tests to see how such testing is handled:
- Keyboard access key only fires
clickevent display: noneelement is not focusable- invalid
tabindexshould be non-focusable - focus events are trusted and should fire appropriately
- key events when an element is not focused
autofocusteststabindextestspopoveris not focusable- escape key doesn't result in user activation
- input type="radio" keyboard operability follows tree order
Generally, existing tests rely on test_driver.send_keys(), document.activeElement, JS .focus() and WPT assert...() functions for keyboard testing.