Bug 1689559 - [devtools] Remove devtools.target-switching.enabled preference r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D103452
This commit is contained in:
Julian Descottes 2021-01-29 14:37:21 +00:00
parent ab8b88783f
commit 9e73accb3e
6 changed files with 7 additions and 105 deletions

View File

@ -2119,14 +2119,6 @@ pref("devtools.browsertoolbox.fission", true);
pref("devtools.browsertoolbox.fission", false);
#endif
// This pref is also related to fission, but not only. It allows the toolbox
// to stay open even if the debugged tab switches to another process.
// It can happen between two documents, one running in the parent process like
// about:sessionrestore and another one running in the content process like
// any web page. Or between two distinct domain when running with fission turned
// on. See bug 1565263.
pref("devtools.target-switching.enabled", true);
// Toolbox Button preferences
pref("devtools.command-button-pick.enabled", true);
pref("devtools.command-button-frames.enabled", true);

View File

@ -26,14 +26,6 @@ const PREFERENCES = [
"Console, so that it can see and debug resources from the content " +
"processes at the same time as resources from the parent process",
],
[
"devtools.target-switching.enabled",
"If you navigate between two distinct process, the toolbox wont close " +
"and will instead switch to the new target. This impacts the regular " +
"web toolbox, when switching from eg. about:sessionrestore to any http " +
"url (parent process to content process). Or when navigating between " +
"two distinct domains if `fission.autostart` is set to true",
],
[
"devtools.testing.enableServerWatcherSupport",
"Enable experimental server-side resources (see watcher actor to get the " +

View File

@ -6,21 +6,9 @@ const URL_2 =
"data:text/html;charset=UTF-8," +
encodeURIComponent('<div id="remote-page">foo</div>');
// Testing navigation between processes
add_task(async function() {
// Test twice.
// Once without target switching, where the toolbox closes and reopens
// And a second time, with target switching, where the toolbox stays open
await navigateBetweenProcesses(false);
await navigateBetweenProcesses(true);
});
async function navigateBetweenProcesses(enableTargetSwitching) {
info(
`Testing navigation between processes ${
enableTargetSwitching ? "with" : "without"
} target switching`
);
await pushPref("devtools.target-switching.enabled", enableTargetSwitching);
info(`Testing navigation between processes`);
info("Open a tab on a URL supporting only running in parent process");
const tab = await addTab(URL_1);
@ -35,23 +23,10 @@ async function navigateBetweenProcesses(enableTargetSwitching) {
"And running in parent process"
);
let toolbox = await openToolboxForTab(tab);
const onToolboxDestroyed = toolbox.once("destroyed");
const onToolboxCreated = gDevTools.once("toolbox-created");
const onToolboxSwitchedToTarget = toolbox.targetList.once("switched-target");
const toolbox = await openToolboxForTab(tab);
info("Navigate to a URL supporting remote process");
if (enableTargetSwitching) {
await navigateTo(URL_2);
} else {
// `navigateTo` except the toolbox to be kept open.
// So, fallback to BrowserTestUtils helpers in this test when
// the target-switching preference is turned off.
const onBrowserLoaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
BrowserTestUtils.loadURI(tab.linkedBrowser, URL_2);
await onBrowserLoaded;
}
await navigateTo(URL_2);
is(
tab.linkedBrowser.getAttribute("remote"),
@ -59,20 +34,6 @@ async function navigateBetweenProcesses(enableTargetSwitching) {
"Navigated to a data: URI and switching to remote"
);
if (enableTargetSwitching) {
info("Waiting for the toolbox to be switched to the new target");
await onToolboxSwitchedToTarget;
} else {
info("Waiting for the toolbox to be destroyed");
await onToolboxDestroyed;
info("Waiting for a new toolbox to be created");
toolbox = await onToolboxCreated;
info("Waiting for the new toolbox to be ready");
await toolbox.once("ready");
}
info("Veryify we are inspecting the new document");
const console = await toolbox.selectTool("webconsole");
const { ui } = console.hud;
@ -88,4 +49,4 @@ async function navigateBetweenProcesses(enableTargetSwitching) {
const { client } = toolbox.target;
await toolbox.destroy();
ok(client._closed, "The client is closed after closing the toolbox");
}
});

View File

@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const Services = require("Services");
const { tabDescriptorSpec } = require("devtools/shared/specs/descriptors/tab");
loader.lazyRequireGetter(
@ -18,12 +17,6 @@ loader.lazyRequireGetter(
"devtools/client/fronts/targets/browsing-context",
true
);
loader.lazyRequireGetter(
this,
"TargetFactory",
"devtools/client/framework/target",
true
);
const {
FrontClassWithSpec,
registerFront,
@ -232,30 +225,9 @@ class TabDescriptorFront extends FrontClassWithSpec(tabDescriptorSpec) {
return;
}
const toolbox = gDevTools.getToolbox(this._targetFront);
const targetSwitchingEnabled = Services.prefs.getBoolPref(
"devtools.target-switching.enabled",
false
);
// When target switching is enabled, everything is handled by the TargetList
// In a near future, this client side code should be replaced by actor code,
// notifying about new tab targets.
if (targetSwitchingEnabled) {
this.emit("remoteness-change", this._targetFront);
return;
}
// Otherwise, if we don't support target switching, ensure the toolbox is destroyed.
// We need to wait for the toolbox destruction because the TargetFactory memoized the targets,
// and only cleans up the cache after the target is destroyed via toolbox destruction.
await toolbox.destroy();
// Fetch the new target for this tab
const newTarget = await TargetFactory.forTab(this.localTab, null);
gDevTools.showToolbox(newTarget);
this.emit("remoteness-change", this._targetFront);
}
}

View File

@ -493,17 +493,6 @@ async function navigateTo(uri, { isErrorPage = false } = {}) {
const switchedToAnotherProcess =
currentPID !== browser.browsingContext.currentWindowGlobal.osPid;
// If we switched to another process and the target switching pref is false,
// the toolbox will close and reopen.
// For now, this helper doesn't support this case
if (switchedToAnotherProcess && !isTargetSwitchingEnabled()) {
ok(
false,
`navigateTo(${uri}) navigated to another process, but the target switching is disabled`
);
return;
}
if (onPanelReloaded) {
info(`Waiting for ${toolbox.currentToolId} to be reloaded…`);
await onPanelReloaded();
@ -562,10 +551,6 @@ function isFissionEnabled() {
return SpecialPowers.useRemoteSubframes;
}
function isTargetSwitchingEnabled() {
return Services.prefs.getBoolPref("devtools.target-switching.enabled", false);
}
/**
* Open the inspector in a tab with given URL.
* @param {string} url The URL to open.

View File

@ -44,7 +44,7 @@ add_task(async function() {
// continuing the test or it might destroy messages we wait later on (Bug
// 1270234).
const promises = [hud.ui.once("messages-cleared")];
if (isFissionEnabled() && isTargetSwitchingEnabled()) {
if (isFissionEnabled()) {
promises.push(hud.targetList.once("switched-target"));
}