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 /testing/web-platform/tests/uievents/click/click_events_on_input.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 'testing/web-platform/tests/uievents/click/click_events_on_input.html')
-rw-r--r-- | testing/web-platform/tests/uievents/click/click_events_on_input.html | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/testing/web-platform/tests/uievents/click/click_events_on_input.html b/testing/web-platform/tests/uievents/click/click_events_on_input.html new file mode 100644 index 0000000000..2f380eb451 --- /dev/null +++ b/testing/web-platform/tests/uievents/click/click_events_on_input.html @@ -0,0 +1,62 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <title>Clicking with primary vs non-primary buttons</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/resources/testdriver.js"></script> + <script src="/resources/testdriver-actions.js"></script> + <script src="/resources/testdriver-vendor.js"></script> + </head> + <body> + <h1>Clicking on input type=text element when placeholder changes</h1> + <input id="target" onfocus="this.placeholder = ++focusCount;" placeholder="initial"> + <input id="other"> + <script> + var focusCount = 0; + var target = document.querySelector('#target'); + document.addEventListener('contextmenu', event => { event.preventDefault(); }); + + var test_click = async_test("Test click and auxclick on input element"); + + // The test is on purpose rather vague, since auxclick handling on + // touchscreens isn't well defined. + // But at least there should be 'click' + var didGetClick = false; + async function testClick(type, mouseButton) { + return new Promise((resolve) => { + target.addEventListener(type, event => { + event.preventDefault(); + didGetClick = didGetClick || event.type == "click"; + test_click.step(() => { + assert_equals(event.type, type, 'Should have got an event.'); + }); + }, {once: true}); + + // Inject mouse click events. + var actions = new test_driver.Actions(); + document.getElementById("other").focus(); + actions.pointerMove(0, 0, {origin: target}) + .pointerDown({button: mouseButton}) + .pointerUp({button: mouseButton}) + .send() + .then(resolve); + }); + } + + async function testClicks() { + var buttonType = test_driver.Actions.prototype.ButtonType; + await testClick("click", buttonType.LEFT); + await testClick("auxclick", buttonType.MIDDLE); + await testClick("auxclick", buttonType.RIGHT); + test_click.step(() => { + assert_true(didGetClick, 'Should have got at least "click".'); + }); + test_click.done(); + } + + testClicks(); + </script> + </body> +</html> |