tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SpecialPowersEventUtils.sys.mjs (1076B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 /**
      6 * Loads a stub copy of EventUtils.js which can be used by things like
      7 * content tasks without holding any direct references to windows.
      8 */
      9 
     10 import { setTimeout } from "resource://gre/modules/Timer.sys.mjs";
     11 
     12 export let EventUtils = { setTimeout, window: {}, _EU_Ci: Ci, _EU_Cc: Cc };
     13 
     14 EventUtils.parent = EventUtils.window;
     15 
     16 EventUtils.synthesizeClick = element =>
     17  new Promise(resolve => {
     18    element.addEventListener("click", () => resolve(), { once: true });
     19 
     20    EventUtils.synthesizeMouseAtCenter(
     21      element,
     22      { type: "mousedown", isSynthesized: false },
     23      element.ownerGlobal
     24    );
     25    EventUtils.synthesizeMouseAtCenter(
     26      element,
     27      { type: "mouseup", isSynthesized: false },
     28      element.ownerGlobal
     29    );
     30  });
     31 
     32 Services.scriptloader.loadSubScript(
     33  "chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
     34  EventUtils
     35 );