diff --git a/devtools/client/debugger/src/client/firefox.js b/devtools/client/debugger/src/client/firefox.js index fb0734152604..d0868a9eb3bc 100644 --- a/devtools/client/debugger/src/client/firefox.js +++ b/devtools/client/debugger/src/client/firefox.js @@ -9,13 +9,15 @@ import { setupEvents, clientEvents } from "./firefox/events"; import { features, prefs } from "../utils/prefs"; let actions; +let targetList; export async function onConnect( connection: any, _actions: Object ): Promise { - const { devToolsClient, targetList } = connection; + const { devToolsClient, targetList: _targetList } = connection; actions = _actions; + targetList = _targetList; setupCommands({ devToolsClient, targetList }); setupEvents({ actions, devToolsClient }); @@ -40,6 +42,19 @@ async function onTargetAvailable({ targetFront, isTargetSwitching, }): Promise { + const isBrowserToolbox = targetList.targetFront.isParentProcess; + const isNonTopLevelFrameTarget = + !targetFront.isTopLevel && + targetFront.targetType === targetList.TYPES.FRAME; + + if (isBrowserToolbox && isNonTopLevelFrameTarget) { + // In the BrowserToolbox, non-top-level frame targets are already + // debugged via content-process targets. + // Do not attach the thread here, as it was already done by the + // corresponding content-process target. + return; + } + if (!targetFront.isTopLevel) { await actions.addTarget(targetFront); return; diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js index 166ae4825795..a2de31397a8c 100644 --- a/devtools/client/framework/toolbox.js +++ b/devtools/client/framework/toolbox.js @@ -738,7 +738,8 @@ Toolbox.prototype = { const isBrowserToolbox = this.targetList.targetFront.isParentProcess; const isNonTopLevelFrameTarget = - !targetFront.isTopLevel && targetFront.type === TargetList.TYPES.FRAME; + !targetFront.isTopLevel && + targetFront.targetType === TargetList.TYPES.FRAME; if (isBrowserToolbox && isNonTopLevelFrameTarget) { // In the BrowserToolbox, non-top-level frame targets are already @@ -766,7 +767,7 @@ Toolbox.prototype = { _attachAndResumeThread: async function(target) { if (target.threadFront) { // if threadFront already exists, the thread is already attached. - if (target.type !== TargetList.TYPES.SERVICE_WORKER) { + if (target.targetType === TargetList.TYPES.SERVICE_WORKER) { // This can legitimately happen for service workers. See Bug 1655439. console.warn( "Attaching to an already attached thread for a service worker target" @@ -778,7 +779,7 @@ Toolbox.prototype = { // This should not happen for non-server-worker targets, throw otherwise. throw new Error( - `Attaching to an already attached thread for a target of type "${target.type}"` + `Attaching to an already attached thread for a target of type "${target.targetType}"` ); }