diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/html/test/test_bug1295719_event_sequence_for_arrow_keys.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/html/test/test_bug1295719_event_sequence_for_arrow_keys.html')
-rw-r--r-- | dom/html/test/test_bug1295719_event_sequence_for_arrow_keys.html | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/dom/html/test/test_bug1295719_event_sequence_for_arrow_keys.html b/dom/html/test/test_bug1295719_event_sequence_for_arrow_keys.html new file mode 100644 index 0000000000..4e622391e8 --- /dev/null +++ b/dom/html/test/test_bug1295719_event_sequence_for_arrow_keys.html @@ -0,0 +1,66 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1295719 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1295719</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/EventUtils.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1295719">Mozilla Bug 1295719</a> +<p id="display"></p> +<div id="content" style="display: none"> +</div> +<input id="test_number" type="number" value=50> +<input id="test_range" type="range" value=50 max=100 min=0> +<script type="text/javascript"> + +/** Test for Bug 1295719 **/ +SimpleTest.waitForExplicitFinish(); +SimpleTest.waitForFocus(runTests); + +function runTests() { + let number = window.document.getElementById("test_number"); + let range = window.document.getElementById("test_range"); + let waiting_event_sequence = ["keydown", "input", "change"]; + let waiting_event_idx = 0; + waiting_event_sequence.forEach((eventType) => { + number.addEventListener(eventType, (event) => { + let waiting_event = waiting_event_sequence[waiting_event_idx]; + is(waiting_event, eventType, "Waiting " + waiting_event + " get " + eventType); + // Input element will fire input and change events when handling keypress + // with keycode=arrows. When user press and hold the keyboard, we expect + // that input element repeatedly fires "keydown"(, "keypress"), "input", and + // "change" events until user release the keyboard. Using + // waiting_event_sequence as a circular buffer and reset waiting_event_idx + // when it point to the end of buffer. + waiting_event_idx = waiting_event_idx == waiting_event_sequence.length -1 ? 0 : waiting_event_idx + 1; + }); + range.addEventListener(eventType, (event) => { + let waiting_event = waiting_event_sequence[waiting_event_idx]; + is(waiting_event, eventType, "Waiting " + waiting_event + " get " + eventType); + waiting_event_idx = waiting_event_idx == waiting_event_sequence.length - 1 ? 0 : waiting_event_idx + 1; + }); + }); + + number.focus(); + synthesizeKey("KEY_ArrowDown", {type: "keydown"}); + synthesizeKey("KEY_ArrowDown", {type: "keydown"}); + synthesizeKey("KEY_ArrowDown", {type: "keyup"}); + number.blur(); + range.focus(); + waiting_event_idx = 0; + synthesizeKey("KEY_ArrowDown", {type: "keydown"}); + synthesizeKey("KEY_ArrowDown", {type: "keydown"}); + synthesizeKey("KEY_ArrowDown", {type: "keyup"}); + + SimpleTest.finish(); +} + +</script> +</body> +</html> |