Bug 1657194 - Prevent attaching to frame target in the context of the browser toolbox. r=jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D85918
This commit is contained in:
Alexandre Poirot 2020-08-05 14:15:20 +00:00
Родитель ce2278580f
Коммит 28ef7f3731
2 изменённых файлов: 20 добавлений и 4 удалений

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

@ -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<void> {
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<void> {
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;

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

@ -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}"`
);
}