tor-browser

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

input.sys.mjs (1064B)


      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 import { Module } from "chrome://remote/content/shared/messagehandler/Module.sys.mjs";
      6 
      7 const lazy = {};
      8 
      9 ChromeUtils.defineESModuleGetters(lazy, {
     10  NavigableManager: "chrome://remote/content/shared/NavigableManager.sys.mjs",
     11  TabManager: "chrome://remote/content/shared/TabManager.sys.mjs",
     12 });
     13 
     14 class InputModule extends Module {
     15  destroy() {}
     16 
     17  interceptEvent(name, payload) {
     18    if (name == "input.fileDialogOpened") {
     19      const browsingContext = payload.context;
     20      if (!lazy.TabManager.isValidCanonicalBrowsingContext(browsingContext)) {
     21        // Discard events for invalid browsing contexts.
     22        return null;
     23      }
     24 
     25      // Resolve browsing context to a Navigable id.
     26      payload.context =
     27        lazy.NavigableManager.getIdForBrowsingContext(browsingContext);
     28    }
     29 
     30    return payload;
     31  }
     32 }
     33 
     34 export const input = InputModule;