browser_user_input_handling_delay_aboutblank.js (1821B)
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_aboutblank_helper(prefs) { 8 await SpecialPowers.pushPrefEnv({ 9 set: prefs, 10 }); 11 12 let newTabOpened = BrowserTestUtils.waitForNewTab(gBrowser, "about:blank"); 13 14 await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () { 15 // Open about:blank 16 content.window.open(); 17 }); 18 19 const tab = await newTabOpened; 20 21 let mouseDownPromise = BrowserTestUtils.waitForContentEvent( 22 tab.linkedBrowser, 23 "mousedown" 24 ).then(function () { 25 Assert.ok(true, "about:blank can handle user input events anytime"); 26 }); 27 28 // Now gBrowser.selectedBrowser is the newly opened about:blank 29 await BrowserTestUtils.synthesizeMouseAtPoint( 30 10, 31 10, 32 { type: "mousedown" }, 33 tab.linkedBrowser 34 ); 35 36 await mouseDownPromise; 37 BrowserTestUtils.removeTab(tab); 38 } 39 40 add_task(async function test_MinRAF_aboutblank() { 41 const prefs = [ 42 ["dom.input_events.security.minNumTicks", 100], 43 ["dom.input_events.security.minTimeElapsedInMS", 0], 44 ["dom.input_events.security.isUserInputHandlingDelayTest", true], 45 ]; 46 47 await test_user_input_handling_delay_aboutblank_helper(prefs); 48 }); 49 50 add_task(async function test_MinElapsedTime_aboutblank() { 51 const prefs = [ 52 ["dom.input_events.security.minNumTicks", 0], 53 ["dom.input_events.security.minTimeElapsedInMS", 5000], 54 ["dom.input_events.security.isUserInputHandlingDelayTest", true], 55 ]; 56 57 await test_user_input_handling_delay_aboutblank_helper(prefs); 58 });