tor-browser

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

thread-states.js (1337B)


      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 "use strict";
      6 
      7 const { Front, types } = require("resource://devtools/shared/protocol.js");
      8 
      9 module.exports = function ({ resource, watcherFront, targetFront }) {
     10  // only "paused" have a frame attribute, and legacy listeners are already passing a FrameFront
     11  if (resource.frame && !(resource.frame instanceof Front)) {
     12    // Use ThreadFront as parent as debugger's commands.js expects FrameFront to be children
     13    // of the ThreadFront.
     14    resource.frame = types
     15      .getType("frame")
     16      .read(resource.frame, targetFront.threadFront);
     17  }
     18 
     19  // If we are using server side request (i.e. watcherFront is defined)
     20  // Fake paused and resumed events as the thread front depends on them.
     21  // We can't emit "EventEmitter" events, as ThreadFront uses `Front.before`
     22  // to listen for paused and resumed. ("before" is part of protocol.js Front and not part of EventEmitter)
     23  if (watcherFront) {
     24    if (resource.state == "paused") {
     25      targetFront.threadFront._beforePaused(resource);
     26    } else if (resource.state == "resumed") {
     27      targetFront.threadFront._beforeResumed(resource);
     28    }
     29  }
     30 
     31  return resource;
     32 };