summaryrefslogtreecommitdiffstats
path: root/dom/base/test/browser_user_input_handling_delay_aboutblank.js
blob: c49a9bf7ed9c880fdb9e79322b6345461ba5f0d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* -*- 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_aboutblank_helper(prefs) {
  await SpecialPowers.pushPrefEnv({
    set: prefs,
  });

  let newTabOpened = BrowserTestUtils.waitForNewTab(gBrowser, "about:blank");

  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
    // Open about:blank
    content.window.open();
  });

  const tab = await newTabOpened;

  let mouseDownPromise = BrowserTestUtils.waitForContentEvent(
    tab.linkedBrowser,
    "mousedown"
  ).then(function () {
    Assert.ok(true, "about:blank can handle user input events anytime");
  });

  // Now gBrowser.selectedBrowser is the newly opened about:blank
  await BrowserTestUtils.synthesizeMouseAtPoint(
    10,
    10,
    { type: "mousedown" },
    tab.linkedBrowser
  );

  await mouseDownPromise;
  BrowserTestUtils.removeTab(tab);
}

add_task(async function test_MinRAF_aboutblank() {
  const prefs = [
    ["dom.input_events.security.minNumTicks", 100],
    ["dom.input_events.security.minTimeElapsedInMS", 0],
    ["dom.input_events.security.isUserInputHandlingDelayTest", true],
  ];

  await test_user_input_handling_delay_aboutblank_helper(prefs);
});

add_task(async function test_MinElapsedTime_aboutblank() {
  const prefs = [
    ["dom.input_events.security.minNumTicks", 0],
    ["dom.input_events.security.minTimeElapsedInMS", 5000],
    ["dom.input_events.security.isUserInputHandlingDelayTest", true],
  ];

  await test_user_input_handling_delay_aboutblank_helper(prefs);
});