browser_user_input_handling_delay_reload_ticks.js (1757B)
1 /* -*- Mode: JavaScript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 async function test_user_input_handling_delay_helper(prefs) { 8 await SpecialPowers.pushPrefEnv({ 9 set: prefs, 10 }); 11 12 const tab = await BrowserTestUtils.openNewForegroundTab( 13 gBrowser, 14 `data:text/html,<body></body>` 15 ); 16 17 await BrowserTestUtils.reloadTab(tab); 18 19 // eslint-disable-next-line mozilla/no-arbitrary-setTimeout 20 await new Promise(r => setTimeout(r, 5000)); 21 22 const userInputHappend = SpecialPowers.spawn( 23 tab.linkedBrowser, 24 [], 25 async function () { 26 await ContentTaskUtils.waitForEvent(content, "keydown"); 27 } 28 ).then(function () { 29 Assert.ok( 30 true, 31 "User input event should be able to work after 5 seconds of an reload" 32 ); 33 }); 34 35 // In the buggy build, the following tab key doesn't work 36 await BrowserTestUtils.synthesizeKey("KEY_Tab", {}, tab.linkedBrowser); 37 await BrowserTestUtils.synthesizeKey("KEY_Tab", {}, tab.linkedBrowser); 38 await BrowserTestUtils.synthesizeKey("KEY_Tab", {}, tab.linkedBrowser); 39 await BrowserTestUtils.synthesizeKey("KEY_Tab", {}, tab.linkedBrowser); 40 41 await userInputHappend; 42 43 BrowserTestUtils.removeTab(tab); 44 } 45 46 add_task(async function test_MinTick() { 47 const prefs = [ 48 ["dom.input_events.security.minNumTicks", 10], 49 ["dom.input_events.security.minTimeElapsedInMS", 0], 50 ["dom.input_events.security.isUserInputHandlingDelayTest", true], 51 ]; 52 53 await test_user_input_handling_delay_helper(prefs); 54 });