Bug 1663649 - [devtools] Enable target switching by default. r=jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D91020
This commit is contained in:
Alexandre Poirot 2020-09-23 17:50:20 +00:00
parent 061206b7f2
commit fad9e1690b
31 changed files with 6 additions and 71 deletions

View File

@ -2077,8 +2077,7 @@ pref("devtools.contenttoolbox.fission", true);
// 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.
// ⚠ This is a work in progress. Expect weirdness when the pref is flipped on ⚠
pref("devtools.target-switching.enabled", false);
pref("devtools.target-switching.enabled", true);
// Toolbox Button preferences
pref("devtools.command-button-pick.enabled", true);

View File

@ -40,17 +40,10 @@ async function navigateTo(uri, tab, toolbox, extension) {
);
}
async function pushPref(preferenceName, value) {
const options = { set: [[preferenceName, value]] };
await SpecialPowers.pushPrefEnv(options);
}
/**
* This test checks whether inspectedWindow works well even target-switching happens.
*/
add_task(async () => {
await pushPref("devtools.target-switching.enabled", true);
const tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
CONTENT_PROCESS_PAGE

View File

@ -20,17 +20,10 @@ async function testOnNavigatedEvent(uri, tab, toolbox, extension) {
is(result, uri, "devtools.network.onNavigated works correctly");
}
async function pushPref(preferenceName, value) {
const options = { set: [[preferenceName, value]] };
await SpecialPowers.pushPrefEnv(options);
}
/**
* This test checks whether network works well even target-switching happens.
*/
add_task(async () => {
await pushPref("devtools.target-switching.enabled", true);
const tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
CONTENT_PROCESS_PAGE

View File

@ -40,8 +40,6 @@ const CONTENT_PROCESS_EXPECTED = [
];
add_task(async () => {
await pushPref("devtools.target-switching.enabled", true);
info(
"Open a test page running on the content process and accessibility panel"
);

View File

@ -15,7 +15,6 @@ const CONTENT_PROCESS_URI_MANIFEST =
// test workers when target switching
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
await enableApplicationPanel();
info("Open a page that runs in the parent process");
@ -43,7 +42,6 @@ add_task(async function() {
// test manifest when target switching
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
await enableApplicationPanel();
info("Open a page that runs in the parent process");

View File

@ -7,8 +7,6 @@
const PARENT_PROCESS_URI = "about:robots";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
// Start the debugger on a parent process URL
const dbg = await initDebuggerWithAbsoluteURL(
PARENT_PROCESS_URI,

View File

@ -8,8 +8,6 @@ const PARENT_PROCESS_URI = "about:robots";
const CONTENT_PROCESS_URI = URL_ROOT + "page_basic.html";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
// We use about:robots as the starting page because it will run in the parent process.
// Navigating from that page to a regular content page will always trigger a target
// switch, with or without fission.

View File

@ -14,8 +14,6 @@ const EXAMPLE_NET_URI =
"http://example.net/document-builder.sjs?html=<div id=net>net";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
const tab = await addTab(EXAMPLE_COM_URI);
const target = await TargetFactory.forTab(tab);
const toolbox = await gDevTools.showToolbox(target);

View File

@ -24,7 +24,6 @@ const PAGE_ON_MAIN = "about:networking";
add_task(async function() {
await pushPref("devtools.inspector.three-pane-enabled", false);
await pushPref("devtools.target-switching.enabled", true);
info("Open a page that runs on the content process and has animations");
const tab = await addTab(PAGE_ON_CONTENT);

View File

@ -12,8 +12,6 @@ const EXAMPLE_NET_URI =
"http://example.net/document-builder.sjs?html=<div id=net>net";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
const { inspector } = await openInspectorForURL(PARENT_PROCESS_URI);
const aboutRobotsNodeFront = await getNodeFront(".title-text", inspector);
ok(!!aboutRobotsNodeFront, "Can retrieve a node front from about:robots");

View File

@ -8,8 +8,6 @@
const TEST_URL = URL_ROOT + "doc_inspector_remove-iframe-during-load.html";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
const { inspector, tab } = await openInspectorForURL("about:blank");
await selectNode("body", inspector);

View File

@ -13,8 +13,6 @@ const EXPECTED_ELEMENT_IN_PARENT_PROCESS = "button";
const EXPECTED_ELEMENT_IN_CONTENT_PROCESS = "section";
add_task(async () => {
await pushPref("devtools.target-switching.enabled", true);
info("Open the memory panel with empty page");
const tab = await addTab();
const { panel } = await openMemoryPanel(tab);

View File

@ -11,8 +11,6 @@ const REQUEST_URL = SEARCH_SJS + "?value=test";
const PARENT_PROCESS_URL = "about:blank";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
info("Open a page that runs on the content process and the netmonitor");
const { monitor } = await initNetMonitor(EXAMPLE_COM_URL, {
requestCount: 1,

View File

@ -26,10 +26,6 @@ const {
} = require("devtools/client/performance/test/helpers/actions");
add_task(async function() {
await SpecialPowers.pushPrefEnv({
set: [["devtools.target-switching.enabled", true]],
});
info("Open a page running on content process");
const tab = await addTab({
url: CONTENT_PROCESS_URL,

View File

@ -464,7 +464,7 @@ async function navigateTo(uri, { isErrorPage = false } = {}) {
// event to make sure everything is ready.
// Navigating from/to pages loaded in the parent process, like about:robots,
// also spawn new targets.
// (If target-switching pref is false, the toolbox will reboot)
// (If target switching is disabled, the toolbox will reboot)
const onTargetSwitched = toolbox.targetList.once("switched-target");
// Otherwise, if we don't switch target, it is safe to wait for navigate event.
const onNavigate = target.once("navigate");
@ -500,13 +500,10 @@ async function navigateTo(uri, { isErrorPage = false } = {}) {
// 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 &&
!Services.prefs.getBoolPref("devtools.target-switching.enabled", false)
) {
if (switchedToAnotherProcess && !isTargetSwitchingEnabled()) {
ok(
false,
`navigateTo(${uri}) navigated to another process, but the target-switching preference is false`
`navigateTo(${uri}) navigated to another process, but the target switching is disabled`
);
return;
}
@ -570,10 +567,7 @@ function isFissionEnabled() {
}
function isTargetSwitchingEnabled() {
return (
isFissionEnabled() &&
Services.prefs.getBoolPref("devtools.target-switching.enabled", false)
);
return Services.prefs.getBoolPref("devtools.target-switching.enabled", false);
}
/**

View File

@ -8,8 +8,6 @@ const PARENT_PROCESS_URI = "about:robots";
const CONTENT_PROCESS_URI = TEST_BASE_HTTPS + "simple.html";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
// We use about:robots, because this page will run in the parent process.
// Navigating from about:robots to a regular content page will always trigger a target
// switch, with or without fission.

View File

@ -27,7 +27,6 @@ registerCleanupFunction(function() {
});
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
const hud = await openNewTabAndConsole(TEST_URI);
info("Test SHA1 warnings");

View File

@ -17,7 +17,6 @@ const TEST_URI =
"data:text/html;charset=utf8,Web Console CSP ignoring reflected XSS (bug 1045902)";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
const hud = await openNewTabAndConsole(TEST_URI);
await navigateTo(TEST_FILE);

View File

@ -7,8 +7,6 @@
"use strict";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
const TEST_URI = "data:text/html;charset=utf8,Web Console CSP violation test";
const hud = await openNewTabAndConsole(TEST_URI);
await clearOutput(hud);

View File

@ -29,7 +29,6 @@ const CSP_REPORT_MSG =
"(\u201cscript-src\u201d). A CSP report is being sent.";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
const hud = await openNewTabAndConsole(TEST_URI);
const onCspViolationMessage = waitForMessage(

View File

@ -16,8 +16,6 @@ const LEARN_MORE_URI =
DOCS_GA_PARAMS;
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
const hud = await openNewTabAndConsole(TEST_URI);
await navigateAndCheckWarningMessage(

View File

@ -91,7 +91,6 @@ const TESTS = [
add_task(async function() {
requestLongerTimeout(2);
await pushPref("devtools.target-switching.enabled", true);
await pushPref("devtools.webconsole.filter.css", true);
await pushPref("devtools.webconsole.filter.net", true);

View File

@ -16,7 +16,6 @@ const CSP_VIOLATION_MSG =
"Content Security Policy: Couldn\u2019t process unknown directive \u2018navigate-to\u2019";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
const hud = await openNewTabAndConsole(TEST_URI);
await clearOutput(hud);

View File

@ -12,7 +12,6 @@ const TEST_URI2 =
"test/browser/test-network-exceptions.html";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
const hud = await openNewTabAndConsole(TEST_URI);
// On e10s, the exception is triggered in child process

View File

@ -30,8 +30,6 @@ registerCleanupFunction(async () => {
});
add_task(async function task() {
await pushPref("devtools.target-switching.enabled", true);
const hud = await openNewTabAndConsole(TEST_URI);
const currentTab = gBrowser.selectedTab;

View File

@ -20,7 +20,6 @@ registerCleanupFunction(async function() {
});
add_task(async function task() {
await pushPref("devtools.target-switching.enabled", true);
await pushPref("devtools.webconsole.filter.net", true);
const hud = await openNewTabAndConsole(TEST_URI);

View File

@ -11,7 +11,6 @@ const TEST_PATH =
const TEST_URI = "data:text/html;charset=utf8,<p>test file URI";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
await pushPref("devtools.webconsole.filter.net", true);
const toolbox = await openNewTabAndToolbox(TEST_URI, "webconsole");

View File

@ -13,7 +13,6 @@ const TEST_URI1 = "http://example.com/" + BASE_URI;
const TEST_URI2 = "http://example.org/" + BASE_URI;
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
await pushPref("devtools.webconsole.persistlog", false);
const hud = await openNewTabAndConsole(TEST_URI1);
@ -45,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 (isTargetSwitchingEnabled()) {
if (isFissionEnabled() && isTargetSwitchingEnabled()) {
promises.push(hud.targetList.once("switched-target"));
}

View File

@ -13,7 +13,6 @@ const TEST_DOC =
const SAMPLE_MSG = "specified a header that could not be parsed successfully.";
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
const hud = await openNewTabAndConsole(TEST_URI);
await clearOutput(hud);
await navigateTo(TEST_DOC);

View File

@ -27,8 +27,6 @@ registerCleanupFunction(async () => {
});
add_task(async function task() {
await pushPref("devtools.target-switching.enabled", true);
// Test that the request appears in the console.
const hud = await openNewTabAndConsole(TEST_URI);
const currentTab = gBrowser.selectedTab;

View File

@ -26,7 +26,6 @@ registerCleanupFunction(async () => {
});
add_task(async function() {
await pushPref("devtools.target-switching.enabled", true);
const toolbox = await openNewTabAndToolbox(TEST_URI, "netmonitor");
info("Network panel is open.");