/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** *Startwatchingforstatechangesofthethreadactor. *Thiswillnotifywheneverthethreadactorpauseandresume. * *@paramTargetActortargetActor *Thetargetactorfromwhichweshouldobservebreakpoints *@paramObjectoptions *Dictionaryobjectwithfollowingattributes: *-onAvailable:mandatoryfunction *Thiswillbecalledforeachresource.
*/
async watch(targetActor, { onAvailable }) { // The Browser Toolbox uses the Content Process target's Thread actor to debug all scripts // running into a given process. This includes WindowGlobal scripts. // Because of this, and in such configuration, we have to ignore the WindowGlobal targets. if (
targetActor.sessionContext.type == "all" &&
!targetActor.sessionContext.enableWindowGlobalThreadActors &&
targetActor.targetType === Targets.TYPES.FRAME &&
targetActor.typeName != "parentProcessTarget"
) { return;
}
// If this watcher is created during target creation, attach the thread actor automatically. // Otherwise it would not pause on anything (especially debugger statements). // However, do not attach the thread actor for Workers. They use a codepath // which releases the worker on `attach`. For them, the client will call `attach`. (bug 1691986) const isTargetCreation = this.threadActor.state == THREAD_STATES.DETACHED; if (isTargetCreation && !targetActor.targetType.endsWith("worker")) {
await this.threadActor.attach({});
}
// For top-level targets, the thread actor may have been attached by the frontend // on toolbox opening, and we start observing for thread state updates much later. // In which case, the thread actor may already be paused and we handle this here. // It will also occurs for all other targets once bug 1681698 lands, // as the thread actor will be initialized before the target starts loading. // And it will occur for all targets once bug 1686748 lands. // // Note that we have to check if we have a "lastPausedPacket", // because the thread Actor is immediately set as being paused, // but the pause packet is built asynchronously and available slightly later. // If the "lastPausedPacket" is null, while the thread actor is paused, // it is fine to ignore as the "paused" event will be fire later. if (threadActor.isPaused() && threadActor.lastPausedPacket()) { this.onPaused(threadActor.lastPausedPacket());
}
}
onPaused(packet) { // If paused by an explicit interrupt, which are generated by the // slow script dialog and internal events such as setting // breakpoints, ignore the event. const { why } = packet; if (why.type === PAUSE_REASONS.INTERRUPTED && !why.onNext) { this.isInterrupted = true; return;
}
// Ignore attached events because they are not useful to the user. if (why.type == PAUSE_REASONS.ALREADY_PAUSED) { return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.