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/base/test/browser_user_input_handling_delay_reload_ticks.js | |
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 '')
-rw-r--r-- | dom/base/test/browser_user_input_handling_delay_reload_ticks.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/dom/base/test/browser_user_input_handling_delay_reload_ticks.js b/dom/base/test/browser_user_input_handling_delay_reload_ticks.js new file mode 100644 index 0000000000..8afc7f16bb --- /dev/null +++ b/dom/base/test/browser_user_input_handling_delay_reload_ticks.js @@ -0,0 +1,54 @@ +/* -*- Mode: JavaScript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +async function test_user_input_handling_delay_helper(prefs) { + await SpecialPowers.pushPrefEnv({ + set: prefs, + }); + + const tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + `data:text/html,<body></body>` + ); + + await BrowserTestUtils.reloadTab(tab); + + // eslint-disable-next-line mozilla/no-arbitrary-setTimeout + await new Promise(r => setTimeout(r, 5000)); + + const userInputHappend = SpecialPowers.spawn( + tab.linkedBrowser, + [], + async function () { + await ContentTaskUtils.waitForEvent(content, "keydown"); + } + ).then(function () { + Assert.ok( + true, + "User input event should be able to work after 5 seconds of an reload" + ); + }); + + // In the buggy build, the following tab key doesn't work + await BrowserTestUtils.synthesizeKey("KEY_Tab", {}, tab.linkedBrowser); + await BrowserTestUtils.synthesizeKey("KEY_Tab", {}, tab.linkedBrowser); + await BrowserTestUtils.synthesizeKey("KEY_Tab", {}, tab.linkedBrowser); + await BrowserTestUtils.synthesizeKey("KEY_Tab", {}, tab.linkedBrowser); + + await userInputHappend; + + BrowserTestUtils.removeTab(tab); +} + +add_task(async function test_MinTick() { + const prefs = [ + ["dom.input_events.security.minNumTicks", 10], + ["dom.input_events.security.minTimeElapsedInMS", 0], + ["dom.input_events.security.isUserInputHandlingDelayTest", true], + ]; + + await test_user_input_handling_delay_helper(prefs); +}); |