
    this.targetActor.off("navigate", this._onNavigate);
    protocol.Actor.prototype.destroy.call(this);
  },

  _onNavigate() {
    this.document = this.targetActor.window.document;
  },

  capture: function(args) {
    if (args.nodeActorID) {
      const nodeActor = this.conn.getActor(args.nodeActorID);
      if (!nodeActor) {
        throw new Error(
          `Screenshot actor failed to find Node actor for '${args.nodeActorID}'`
        );
      }
      args.rawNode = nodeActor.rawNode;
    }
    return captureScreenshot(args, this.document);
  },
});
PK