mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 12:50:09 +00:00
Bug 1714395 - [devtools] Use descriptor front or toolbox to know if we are in a BrowserToolbox r=nchevobbe
That, instead of using the current top level target, which may change, be null, ... Differential Revision: https://phabricator.services.mozilla.com/D118549
This commit is contained in:
parent
6d29185618
commit
b0f6ee610d
@ -14,25 +14,29 @@ import { recordEvent } from "../utils/telemetry";
|
||||
import sourceQueue from "../utils/source-queue";
|
||||
|
||||
let actions;
|
||||
let commands;
|
||||
let targetCommand;
|
||||
let resourceCommand;
|
||||
let commands;
|
||||
|
||||
export async function onConnect(_commands, _resourceCommand, _actions, store) {
|
||||
actions = _actions;
|
||||
commands = _commands;
|
||||
targetCommand = _commands.targetCommand;
|
||||
resourceCommand = _resourceCommand;
|
||||
commands = _commands;
|
||||
|
||||
setupCommands(commands);
|
||||
setupCreate({ store });
|
||||
|
||||
sourceQueue.initialize(actions);
|
||||
|
||||
const { descriptorFront } = commands;
|
||||
const { targetFront } = targetCommand;
|
||||
if (targetFront.isBrowsingContext || targetFront.isParentProcess) {
|
||||
if (
|
||||
targetFront.isBrowsingContext ||
|
||||
descriptorFront.isParentProcessDescriptor
|
||||
) {
|
||||
targetCommand.listenForWorkers = true;
|
||||
if (targetFront.localTab && features.windowlessServiceWorkers) {
|
||||
if (descriptorFront.isLocalTab && features.windowlessServiceWorkers) {
|
||||
targetCommand.listenForServiceWorkers = true;
|
||||
targetCommand.destroyServiceWorkersOnNavigation = true;
|
||||
}
|
||||
@ -104,7 +108,7 @@ export function onDisconnect() {
|
||||
}
|
||||
|
||||
async function onTargetAvailable({ targetFront, isTargetSwitching }) {
|
||||
const isBrowserToolbox = targetCommand.targetFront.isParentProcess;
|
||||
const isBrowserToolbox = commands.descriptorFront.isParentProcessDescriptor;
|
||||
const isNonTopLevelFrameTarget =
|
||||
!targetFront.isTopLevel &&
|
||||
targetFront.targetType === targetCommand.TYPES.FRAME;
|
||||
|
@ -588,7 +588,7 @@ exports.ToolboxButtons = [
|
||||
// But in the browser toolbox, we can't see the download UI, so we'll display the
|
||||
// saved message so the user knows there the file was saved.
|
||||
if (
|
||||
!toolbox.target.isParentProcess &&
|
||||
!toolbox.isBrowserToolbox &&
|
||||
level !== "warn" &&
|
||||
level !== "error"
|
||||
) {
|
||||
|
@ -434,7 +434,7 @@ OptionsPanel.prototype = {
|
||||
});
|
||||
}
|
||||
|
||||
if (this.target.isParentProcess) {
|
||||
if (this.toolbox.isBrowserToolbox) {
|
||||
// The Multiprocess Browser Toolbox is only displayed in the settings
|
||||
// panel for the Browser Toolbox, or when debugging the main process in
|
||||
// remote debugging.
|
||||
@ -448,7 +448,7 @@ OptionsPanel.prototype = {
|
||||
// custom behavior for the Browser Toolbox, so we pass an additional
|
||||
// onChange callback.
|
||||
onChange: async checked => {
|
||||
if (!this.toolbox.isBrowserToolbox()) {
|
||||
if (!this.toolbox.isBrowserToolbox) {
|
||||
// If we are debugging a parent process, but the toolbox is not a
|
||||
// Browser Toolbox, it means we are remote debugging another
|
||||
// browser. In this case, the value of devtools.browsertoolbox.fission
|
||||
|
@ -614,7 +614,7 @@ Toolbox.prototype = {
|
||||
);
|
||||
},
|
||||
|
||||
isBrowserToolbox: function() {
|
||||
get isBrowserToolbox() {
|
||||
return this.hostType === Toolbox.HostType.BROWSERTOOLBOX;
|
||||
},
|
||||
|
||||
@ -3068,7 +3068,7 @@ Toolbox.prototype = {
|
||||
let title;
|
||||
|
||||
const isMultiProcessBrowserToolbox =
|
||||
this.target.isParentProcess &&
|
||||
this.isBrowserToolbox &&
|
||||
Services.prefs.getBoolPref("devtools.browsertoolbox.fission", false);
|
||||
|
||||
if (isMultiProcessBrowserToolbox) {
|
||||
|
@ -64,6 +64,10 @@ class ProcessDescriptorFront extends DescriptorMixin(
|
||||
return front;
|
||||
}
|
||||
|
||||
get isParentProcessDescriptor() {
|
||||
return this.isParent;
|
||||
}
|
||||
|
||||
get isProcessDescriptor() {
|
||||
return true;
|
||||
}
|
||||
|
@ -510,7 +510,8 @@ function TargetMixin(parentClass) {
|
||||
await this.attach();
|
||||
}
|
||||
|
||||
const isBrowserToolbox = targetCommand.targetFront.isParentProcess;
|
||||
const isBrowserToolbox =
|
||||
targetCommand.descriptorFront.isParentProcessDescriptor;
|
||||
const isNonTopLevelFrameTarget =
|
||||
!this.isTopLevel && this.targetType === targetCommand.TYPES.FRAME;
|
||||
|
||||
|
@ -62,9 +62,8 @@ class WebConsoleUI {
|
||||
this.isBrowserConsole = this.hud.isBrowserConsole;
|
||||
|
||||
this.isBrowserToolboxConsole =
|
||||
this.hud.currentTarget &&
|
||||
this.hud.currentTarget.isParentProcess &&
|
||||
!this.hud.currentTarget.isAddon;
|
||||
this.hud.commands.descriptorFront.isParentProcessDescriptor &&
|
||||
!this.isBrowserConsole;
|
||||
this.fissionSupport = Services.prefs.getBoolPref(
|
||||
constants.PREFS.FEATURES.BROWSER_TOOLBOX_FISSION
|
||||
);
|
||||
|
@ -24,7 +24,8 @@ const ResourceCommand = require("devtools/shared/commands/resource/resource-comm
|
||||
* - extensionName {null|String}: If the source comes from an add-on, the add-on name.
|
||||
*/
|
||||
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
||||
const isBrowserToolbox = targetCommand.targetFront.isParentProcess;
|
||||
const isBrowserToolbox =
|
||||
targetCommand.descriptorFront.isParentProcessDescriptor;
|
||||
const isNonTopLevelFrameTarget =
|
||||
!targetFront.isTopLevel &&
|
||||
targetFront.targetType === targetCommand.TYPES.FRAME;
|
||||
|
@ -7,7 +7,8 @@
|
||||
const ResourceCommand = require("devtools/shared/commands/resource/resource-command");
|
||||
|
||||
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
||||
const isBrowserToolbox = targetCommand.targetFront.isParentProcess;
|
||||
const isBrowserToolbox =
|
||||
targetCommand.descriptorFront.isParentProcessDescriptor;
|
||||
const isNonTopLevelFrameTarget =
|
||||
!targetFront.isTopLevel &&
|
||||
targetFront.targetType === targetCommand.TYPES.FRAME;
|
||||
|
@ -811,7 +811,7 @@ class ResourceCommand {
|
||||
// In such case, if the browser toolbox fission pref is disabled, we don't want to use watchers
|
||||
// (even if traits on the server are enabled).
|
||||
if (
|
||||
this.targetCommand.targetFront.isParentProcess &&
|
||||
this.targetCommand.descriptorFront.isParentProcessDescriptor &&
|
||||
!Services.prefs.getBoolPref(BROWSERTOOLBOX_FISSION_ENABLED, false)
|
||||
) {
|
||||
return false;
|
||||
|
@ -245,7 +245,7 @@ class LegacyServiceWorkersWatcher extends LegacyWorkersWatcher {
|
||||
// Check if the registration is relevant for the current target, ie
|
||||
// corresponds to the same domain.
|
||||
_isRegistrationValidForTarget(registration) {
|
||||
if (this.target.isParentProcess) {
|
||||
if (this.targetCommand.descriptorFront.isParentProcessDescriptor) {
|
||||
// All registrations are valid for main process debugging.
|
||||
return true;
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ class TargetCommand extends EventEmitter {
|
||||
// In such case, if the browser toolbox fission pref is disabled, we don't want to use watchers
|
||||
// (even if traits on the server are enabled).
|
||||
if (
|
||||
this.descriptorFront.isParent &&
|
||||
this.descriptorFront.isParentProcessDescriptor &&
|
||||
!Services.prefs.getBoolPref(BROWSERTOOLBOX_FISSION_ENABLED, false)
|
||||
) {
|
||||
return false;
|
||||
@ -437,7 +437,7 @@ class TargetCommand extends EventEmitter {
|
||||
|
||||
if (this.descriptorFront.isLocalTab) {
|
||||
types = [TargetCommand.TYPES.FRAME];
|
||||
} else if (this.targetFront.isParentProcess) {
|
||||
} else if (this.descriptorFront.isParentProcessDescriptor) {
|
||||
const fissionBrowserToolboxEnabled = Services.prefs.getBoolPref(
|
||||
BROWSERTOOLBOX_FISSION_ENABLED
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user