зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
ce2278580f
Коммит
28ef7f3731
|
@ -9,13 +9,15 @@ import { setupEvents, clientEvents } from "./firefox/events";
|
||||||
import { features, prefs } from "../utils/prefs";
|
import { features, prefs } from "../utils/prefs";
|
||||||
|
|
||||||
let actions;
|
let actions;
|
||||||
|
let targetList;
|
||||||
|
|
||||||
export async function onConnect(
|
export async function onConnect(
|
||||||
connection: any,
|
connection: any,
|
||||||
_actions: Object
|
_actions: Object
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { devToolsClient, targetList } = connection;
|
const { devToolsClient, targetList: _targetList } = connection;
|
||||||
actions = _actions;
|
actions = _actions;
|
||||||
|
targetList = _targetList;
|
||||||
|
|
||||||
setupCommands({ devToolsClient, targetList });
|
setupCommands({ devToolsClient, targetList });
|
||||||
setupEvents({ actions, devToolsClient });
|
setupEvents({ actions, devToolsClient });
|
||||||
|
@ -40,6 +42,19 @@ async function onTargetAvailable({
|
||||||
targetFront,
|
targetFront,
|
||||||
isTargetSwitching,
|
isTargetSwitching,
|
||||||
}): Promise<void> {
|
}): 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) {
|
if (!targetFront.isTopLevel) {
|
||||||
await actions.addTarget(targetFront);
|
await actions.addTarget(targetFront);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -738,7 +738,8 @@ Toolbox.prototype = {
|
||||||
|
|
||||||
const isBrowserToolbox = this.targetList.targetFront.isParentProcess;
|
const isBrowserToolbox = this.targetList.targetFront.isParentProcess;
|
||||||
const isNonTopLevelFrameTarget =
|
const isNonTopLevelFrameTarget =
|
||||||
!targetFront.isTopLevel && targetFront.type === TargetList.TYPES.FRAME;
|
!targetFront.isTopLevel &&
|
||||||
|
targetFront.targetType === TargetList.TYPES.FRAME;
|
||||||
|
|
||||||
if (isBrowserToolbox && isNonTopLevelFrameTarget) {
|
if (isBrowserToolbox && isNonTopLevelFrameTarget) {
|
||||||
// In the BrowserToolbox, non-top-level frame targets are already
|
// In the BrowserToolbox, non-top-level frame targets are already
|
||||||
|
@ -766,7 +767,7 @@ Toolbox.prototype = {
|
||||||
_attachAndResumeThread: async function(target) {
|
_attachAndResumeThread: async function(target) {
|
||||||
if (target.threadFront) {
|
if (target.threadFront) {
|
||||||
// if threadFront already exists, the thread is already attached.
|
// 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.
|
// This can legitimately happen for service workers. See Bug 1655439.
|
||||||
console.warn(
|
console.warn(
|
||||||
"Attaching to an already attached thread for a service worker target"
|
"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.
|
// This should not happen for non-server-worker targets, throw otherwise.
|
||||||
throw new Error(
|
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}"`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче