Bug 1682220 - [devtools] Use nsiWorkerDebugger#windowIds instead of window reference in DevToolsWorkerChild. r=ochameau.

This also allow us to remove the ignoreExistingTargets option we had to workaround Bug 1673024.

Depends on D99441

Differential Revision: https://phabricator.services.mozilla.com/D99648
This commit is contained in:
nchevobbe 2021-01-20 07:04:55 +00:00
Родитель 477b1bc69a
Коммит 087cac0b8e
1 изменённых файлов: 13 добавлений и 26 удалений

Просмотреть файл

@ -128,11 +128,6 @@ class DevToolsWorkerChild extends JSWindowActorChild {
watcherActorID,
parentConnectionPrefix: connectionPrefix,
watchedData,
// When navigating, this code is triggered _before_ the workers living on the page
// we navigate from are terminated, which would create worker targets for them again.
// Since at this point the new document can't have any workers yet, we are going to
// ignore existing targets (i.e. the workers that belong to the previous document).
ignoreExistingTargets: true,
});
}
}
@ -209,15 +204,10 @@ class DevToolsWorkerChild extends JSWindowActorChild {
* @param {Object} options.watchedData: Data (targets, resources, ) the watcher wants
* to be notified about. See WatcherRegistry.getWatchedData to see the full list
* of properties.
* @param {Boolean} options.ignoreExistingTargets: Set to true to not loop on existing
* workers. This is useful when this function is called at the very early stage
* of the life of a document, since workers of the previous document are still
* alive, and there's no way to filter them out.
*/
async _watchWorkerTargets({
watcherActorID,
parentConnectionPrefix,
ignoreExistingTargets,
watchedData,
}) {
if (this._connections.has(watcherActorID)) {
@ -254,20 +244,18 @@ class DevToolsWorkerChild extends JSWindowActorChild {
watchedData,
});
if (ignoreExistingTargets !== true) {
await Promise.all(
Array.from(wdm.getWorkerDebuggerEnumerator())
.filter(dbg => this._shouldHandleWorker(dbg))
.map(dbg =>
this._createWorkerTargetActor({
dbg,
connection,
forwardingPrefix,
watcherActorID,
})
)
);
}
await Promise.all(
Array.from(wdm.getWorkerDebuggerEnumerator())
.filter(dbg => this._shouldHandleWorker(dbg))
.map(dbg =>
this._createWorkerTargetActor({
dbg,
connection,
forwardingPrefix,
watcherActorID,
})
)
);
}
_createConnection(forwardingPrefix) {
@ -302,8 +290,7 @@ class DevToolsWorkerChild extends JSWindowActorChild {
return (
DevToolsUtils.isWorkerDebuggerAlive(dbg) &&
dbg.type === Ci.nsIWorkerDebugger.TYPE_DEDICATED &&
dbg.window?.windowGlobalChild?.innerWindowId ===
this.manager.innerWindowId
dbg.windowIDs.includes(this.manager.innerWindowId)
);
}