Bug 1358020 - Prevent default behaviour when testing function keys; r?ato
F10, F7 and others activate browser menus in the Linux test environment,
so call preventDefault to stop it.
The default bevahiour interferes with tests running against the upcoming
beta build. Although nightly builds also have this behaviour, it doesn't
appear to intefere with the tests.
MozReview-Commit-ID: 1PiqmtG1SfB
--- a/testing/web-platform/tests/webdriver/actions/special_keys.py
+++ b/testing/web-platform/tests/webdriver/actions/special_keys.py
@@ -6,23 +6,30 @@ from support.refine import filter_dict,
@pytest.mark.parametrize("name,expected", ALL_EVENTS.items())
def test_webdriver_special_key_sends_keydown(session,
key_reporter,
key_chain,
name,
expected):
+ if name.startswith("F"):
+ # Prevent default behavior for F1, etc., but only after keydown
+ # bubbles up to body. (Otherwise activated browser menus/functions
+ # may interfere with subsequent tests.)
+ session.execute_script("""
+ document.body.addEventListener("keydown",
+ (e) => e.preventDefault());
+ """)
key_chain.key_down(getattr(Keys, name)).perform()
# only interested in keydown
first_event = get_events(session)[0]
# make a copy so we can throw out irrelevant keys and compare to events
expected = dict(expected)
-
del expected["value"]
# check and remove keys that aren't in expected
assert first_event["type"] == "keydown"
assert first_event["repeat"] == False
first_event = filter_dict(first_event, expected)
assert first_event == expected
# only printable characters should be recorded in input field
entered_keys = get_keys(key_reporter)