tor-browser

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

commandwindowglobalonly.sys.mjs (1107B)


      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 class CommandWindowGlobalOnlyModule extends Module {
      8  destroy() {}
      9 
     10  /**
     11   * Commands
     12   */
     13 
     14  testOnlyInWindowGlobal() {
     15    return "only-in-windowglobal";
     16  }
     17 
     18  testBroadcast() {
     19    return `broadcast-${this.messageHandler.contextId}`;
     20  }
     21 
     22  testBroadcastWithParameter(params) {
     23    return `broadcast-${this.messageHandler.contextId}-${params.value}`;
     24  }
     25 
     26  testError() {
     27    throw new Error("error-from-module");
     28  }
     29 
     30  testMissingIntermediaryMethod(params, destination) {
     31    // Spawn a new internal command, but with a commandName which doesn't match
     32    // any method.
     33    return this.messageHandler.handleCommand({
     34      moduleName: "commandwindowglobalonly",
     35      commandName: "missingMethod",
     36      destination,
     37    });
     38  }
     39 }
     40 
     41 export const commandwindowglobalonly = CommandWindowGlobalOnlyModule;