зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1704521 - [devtools] Remove F12 experiment preference r=devtools-reviewers,nchevobbe
Depends on D143833 Differential Revision: https://phabricator.services.mozilla.com/D143835
This commit is contained in:
Родитель
4a44e5775e
Коммит
2476e7a6e9
|
@ -56,19 +56,9 @@ loader.lazyRequireGetter(
|
|||
"ResponsiveUIManager",
|
||||
"resource://devtools/client/responsive/manager.js"
|
||||
);
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"toggleEnableDevToolsPopup",
|
||||
"resource://devtools/client/framework/enable-devtools-popup.js",
|
||||
true
|
||||
);
|
||||
|
||||
const BROWSER_STYLESHEET_URL = "chrome://devtools/skin/devtools-browser.css";
|
||||
|
||||
// XXX: This could also be moved to DevToolsStartup, which is the first
|
||||
// "entry point" for DevTools shortcuts and forwards the events
|
||||
// devtools-browser.
|
||||
const DEVTOOLS_F12_DISABLED_PREF = "devtools.experiment.f12.shortcut_disabled";
|
||||
/**
|
||||
* gDevToolsBrowser exposes functions to connect the gDevTools instance with a
|
||||
* Firefox instance.
|
||||
|
@ -289,22 +279,7 @@ var gDevToolsBrowser = (exports.gDevToolsBrowser = {
|
|||
await gDevToolsBrowser.toggleToolboxCommand(window.gBrowser, startTime);
|
||||
break;
|
||||
case "toggleToolboxF12":
|
||||
// See Bug 1630228. F12 is responsible for most of the accidental usage
|
||||
// of DevTools. The preference here is used as part of an experiment to
|
||||
// disable the F12 shortcut by default.
|
||||
const isF12Disabled = Services.prefs.getBoolPref(
|
||||
DEVTOOLS_F12_DISABLED_PREF,
|
||||
false
|
||||
);
|
||||
|
||||
if (isF12Disabled) {
|
||||
toggleEnableDevToolsPopup(window.document, startTime);
|
||||
} else {
|
||||
await gDevToolsBrowser.toggleToolboxCommand(
|
||||
window.gBrowser,
|
||||
startTime
|
||||
);
|
||||
}
|
||||
await gDevToolsBrowser.toggleToolboxCommand(window.gBrowser, startTime);
|
||||
break;
|
||||
case "browserToolbox":
|
||||
lazy.BrowserToolboxLauncher.init();
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
BROWSER_CHROME_MANIFESTS += [
|
||||
"test/browser-enable-popup-devtools-user.ini",
|
||||
"test/browser-enable-popup-new-user.ini",
|
||||
"test/browser-telemetry-startup.ini",
|
||||
"test/browser.ini",
|
||||
"test/metrics/browser_metrics.ini",
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
[DEFAULT]
|
||||
tags = devtools
|
||||
subsuite = devtools
|
||||
support-files =
|
||||
head.js
|
||||
helper_enable_devtools_popup.js
|
||||
!/devtools/client/shared/test/shared-head.js
|
||||
!/devtools/client/shared/test/telemetry-test-helpers.js
|
||||
prefs =
|
||||
devtools.experiment.f12.shortcut_disabled=true
|
||||
devtools.selfxss.count=5
|
||||
|
||||
# This test checks the interaction between devtools.selfxss.count and
|
||||
# devtools.experiment.f12.shortcut_disabled which is handled by DevToolsStartup
|
||||
# and therefore needs to run in isolation, with preferences set before starting
|
||||
# the browser.
|
||||
[browser_enable_devtools_popup_devtools_user.js]
|
||||
skip-if = verify # This test is only valid with a new browser instance.
|
|
@ -1,18 +0,0 @@
|
|||
[DEFAULT]
|
||||
tags = devtools
|
||||
subsuite = devtools
|
||||
support-files =
|
||||
head.js
|
||||
helper_enable_devtools_popup.js
|
||||
!/devtools/client/shared/test/shared-head.js
|
||||
!/devtools/client/shared/test/telemetry-test-helpers.js
|
||||
prefs =
|
||||
devtools.experiment.f12.shortcut_disabled=true
|
||||
devtools.selfxss.count=0
|
||||
|
||||
# This test checks the interaction between devtools.selfxss.count and
|
||||
# devtools.experiment.f12.shortcut_disabled which is handled by DevToolsStartup
|
||||
# and therefore needs to run in isolation, with preferences set before starting
|
||||
# the browser.
|
||||
[browser_enable_devtools_popup_new_user.js]
|
||||
skip-if = verify # Test runs in isolation which is incompatible with test-verify
|
|
@ -33,7 +33,6 @@ support-files =
|
|||
doc_textbox_tool.html
|
||||
head.js
|
||||
helper_disable_cache.js
|
||||
helper_enable_devtools_popup.js
|
||||
doc_theme.css
|
||||
doc_viewsource.html
|
||||
browser_toolbox_options_enable_serviceworkers_testing.html
|
||||
|
@ -54,7 +53,6 @@ prefs =
|
|||
[browser_about-devtools-toolbox_reload.js]
|
||||
[browser_devtools_api_destroy.js]
|
||||
[browser_dynamic_tool_enabling.js]
|
||||
[browser_enable_devtools_popup.js]
|
||||
[browser_front_parentFront.js]
|
||||
[browser_ignore_toolbox_network_requests.js]
|
||||
[browser_keybindings_01.js]
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper_enable_devtools_popup.js */
|
||||
loadHelperScript("helper_enable_devtools_popup.js");
|
||||
|
||||
const TEST_URL =
|
||||
"data:text/html,<html><head><title>Test Disable F12 experiment</title></head><body>" +
|
||||
"<h1>Disable F12 experiment</h1></body></html>";
|
||||
|
||||
// Test the basic behavior of the enable devtools popup depending on the value
|
||||
// of the devtools.experiment.f12.shortcut_disabled preference
|
||||
add_task(async function testWithF12Disabled() {
|
||||
await pushPref("devtools.experiment.f12.shortcut_disabled", true);
|
||||
|
||||
const tab = await addTab(TEST_URL);
|
||||
await new Promise(done => waitForFocus(done));
|
||||
|
||||
await checkF12IsDisabled(tab);
|
||||
const toolbox = await openDevToolsWithInspectorKey(tab);
|
||||
await closeDevToolsWithF12(tab, toolbox);
|
||||
await checkF12IsEnabled(tab);
|
||||
});
|
||||
|
||||
add_task(async function testWithF12Enabled() {
|
||||
await pushPref("devtools.experiment.f12.shortcut_disabled", false);
|
||||
|
||||
const tab = await addTab(TEST_URL);
|
||||
await new Promise(done => waitForFocus(done));
|
||||
|
||||
await checkF12IsEnabled(tab);
|
||||
});
|
|
@ -1,33 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper_enable_devtools_popup.js */
|
||||
loadHelperScript("helper_enable_devtools_popup.js");
|
||||
|
||||
const TEST_URL =
|
||||
"data:text/html,<html><head><title>Test Disable F12 experiment</title></head><body>" +
|
||||
"<h1>Disable F12 experiment</h1></body></html>";
|
||||
|
||||
// See the corresponding browser-enable-popup-devtools-user.ini for the
|
||||
// initialization of the prefs:
|
||||
// - devtools.experiment.f12.shortcut_disabled -> true
|
||||
// - devtools.selfxss.count -> 5
|
||||
//
|
||||
// Those prefs are set in the browser ini to run before DevToolsStartup.jsm init
|
||||
// logic. We expect devtools.selfxss.count to force shortcut_disabled to false.
|
||||
add_task(async function () {
|
||||
const tab = await addTab(TEST_URL);
|
||||
await new Promise(done => waitForFocus(done));
|
||||
|
||||
// With the shortcut initially disabled and the selfxss pref at 5, we expect
|
||||
// the user to be considered as a devtools user and F12 to be immediately
|
||||
// enabled.
|
||||
await checkF12IsEnabled(tab);
|
||||
|
||||
const isF12Disabled = Services.prefs.getBoolPref(
|
||||
"devtools.experiment.f12.shortcut_disabled"
|
||||
);
|
||||
ok(!isF12Disabled, "The F12 disabled preference has been correctly flipped");
|
||||
});
|
|
@ -1,30 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper_enable_devtools_popup.js */
|
||||
loadHelperScript("helper_enable_devtools_popup.js");
|
||||
|
||||
const TEST_URL =
|
||||
"data:text/html,<html><head><title>Test Disable F12 experiment</title></head><body>" +
|
||||
"<h1>Disable F12 experiment</h1></body></html>";
|
||||
|
||||
// See the corresponding browser-enable-popup-devtools-user.ini for the
|
||||
// initialization of the prefs:
|
||||
// - devtools.experiment.f12.shortcut_disabled -> true
|
||||
// - devtools.selfxss.count -> 0
|
||||
//
|
||||
// Those prefs are set in the browser ini to run before DevToolsStartup.jsm init
|
||||
// logic. We expect devtools.selfxss.count to force shortcut_disabled to false.
|
||||
add_task(async function () {
|
||||
const tab = await addTab(TEST_URL);
|
||||
await new Promise(done => waitForFocus(done));
|
||||
|
||||
// With the shortcut initially disabled and the selfxss pref at 0, we expect
|
||||
// the shortcut to be effectively disabled.
|
||||
await checkF12IsDisabled(tab);
|
||||
const toolbox = await openDevToolsWithInspectorKey(tab);
|
||||
await closeDevToolsWithF12(tab, toolbox);
|
||||
await checkF12IsEnabled(tab);
|
||||
});
|
|
@ -1,156 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from ../../shared/test/shared-head.js */
|
||||
|
||||
const { listenOnce } = require("resource://devtools/shared/async-utils.js");
|
||||
|
||||
/**
|
||||
* Helpers dedicated to the browser_enable_devtools_popup* tests.
|
||||
* Those tests usually test the same exact things, but using different
|
||||
* configurations.
|
||||
*/
|
||||
|
||||
function openDevToolsWithKey(key, modifiers) {
|
||||
const onToolboxReady = gDevTools.once("toolbox-ready");
|
||||
EventUtils.synthesizeKey(key, modifiers);
|
||||
return onToolboxReady;
|
||||
}
|
||||
/* exported openDevToolsWithKey */
|
||||
|
||||
function closeDevToolsWithKey(toolbox, key, modifiers) {
|
||||
const onToolboxDestroyed = toolbox.once("destroyed");
|
||||
EventUtils.synthesizeKey(key, modifiers);
|
||||
return onToolboxDestroyed;
|
||||
}
|
||||
/* exported closeDevToolsWithKey */
|
||||
|
||||
/**
|
||||
* The popup element might still be in its template wrapper.
|
||||
*/
|
||||
function unwrapEnableDevToolsPopup(tab) {
|
||||
const panelWrapper = tab.ownerDocument.getElementById(
|
||||
"wrapper-enable-devtools-popup"
|
||||
);
|
||||
if (panelWrapper) {
|
||||
info("Unwrapping enable devtools popup");
|
||||
panelWrapper.replaceWith(panelWrapper.content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if F12 is currently disabled:
|
||||
* - press F12 -> popup is displayed
|
||||
* - press F12 again -> popup is hidden
|
||||
* - no toolbox was opened during the process
|
||||
*/
|
||||
async function checkF12IsDisabled(tab) {
|
||||
unwrapEnableDevToolsPopup(tab);
|
||||
|
||||
const popup = tab.ownerDocument.getElementById("enable-devtools-popup");
|
||||
is(popup.state, "closed", "The enable devtools popup is initially hidden");
|
||||
|
||||
const failOnToolboxReady = () => {
|
||||
ok(false, "The devtools toolbox should not open");
|
||||
};
|
||||
gDevTools.on("toolbox-ready", failOnToolboxReady);
|
||||
|
||||
info("Press F12 and wait for the enable devtools popup to be displayed");
|
||||
const onPopupShown = listenOnce(popup, "popupshown");
|
||||
EventUtils.synthesizeKey("VK_F12");
|
||||
await onPopupShown;
|
||||
is(popup.state, "open", "The enable devtools popup is now visible");
|
||||
|
||||
info("Press F12 again and wait for the enable devtools popup to hide");
|
||||
const onPopupHidden = listenOnce(popup, "popuphidden");
|
||||
EventUtils.synthesizeKey("VK_F12");
|
||||
await onPopupHidden;
|
||||
is(popup.state, "closed", "The enable devtools popup is hidden again");
|
||||
|
||||
gDevTools.off("toolbox-ready", failOnToolboxReady);
|
||||
}
|
||||
/* exported checkF12IsDisabled */
|
||||
|
||||
/**
|
||||
* Test that DevTools can be open with another keyboard shortcut than F12.
|
||||
* The enable-devtools popup should not be displayed.
|
||||
*/
|
||||
async function openDevToolsWithInspectorKey(tab) {
|
||||
unwrapEnableDevToolsPopup(tab);
|
||||
|
||||
info("Open DevTools via another shortcut (only F12 should be disabled)");
|
||||
const popup = tab.ownerDocument.getElementById("enable-devtools-popup");
|
||||
|
||||
// We are going to use F12 but the popup should never show up.
|
||||
const failOnPopupShown = () => {
|
||||
ok(false, "The enable devtools popup should not be displayed");
|
||||
};
|
||||
popup.addEventListener("popupshown", failOnPopupShown);
|
||||
|
||||
const toolbox = await openDevToolsWithKey("I", {
|
||||
accelKey: true,
|
||||
shiftKey: !navigator.userAgent.match(/Mac/),
|
||||
altKey: navigator.userAgent.match(/Mac/),
|
||||
});
|
||||
|
||||
is(popup.state, "closed", "The enable devtools popup is still hidden");
|
||||
popup.removeEventListener("popupshown", failOnPopupShown);
|
||||
|
||||
return toolbox;
|
||||
}
|
||||
/* exported openDevToolsWithInspectorKey */
|
||||
|
||||
/**
|
||||
* Test that the toolbox can be closed with F12, without triggering the popup.
|
||||
*/
|
||||
async function closeDevToolsWithF12(tab, toolbox) {
|
||||
unwrapEnableDevToolsPopup(tab);
|
||||
|
||||
const popup = tab.ownerDocument.getElementById("enable-devtools-popup");
|
||||
|
||||
// We are going to use F12 but the popup should never show up.
|
||||
const failOnPopupShown = () => {
|
||||
ok(false, "The enable devtools popup should not be displayed");
|
||||
};
|
||||
popup.addEventListener("popupshown", failOnPopupShown);
|
||||
|
||||
info("Press F12 and wait for the toolbox to be destroyed");
|
||||
await closeDevToolsWithKey(toolbox, "VK_F12");
|
||||
is(popup.state, "closed", "The enable devtools popup is still hidden");
|
||||
|
||||
popup.removeEventListener("popupshown", failOnPopupShown);
|
||||
}
|
||||
/* exported closeDevToolsWithF12 */
|
||||
|
||||
/**
|
||||
* Test if F12 is enabled:
|
||||
* - press F12 -> toolbox opens
|
||||
* - press F12 -> toolbox closes
|
||||
* - no enable devtools popup was opened during the process
|
||||
*/
|
||||
async function checkF12IsEnabled(tab) {
|
||||
unwrapEnableDevToolsPopup(tab);
|
||||
|
||||
const popup = tab.ownerDocument.getElementById("enable-devtools-popup");
|
||||
|
||||
// We are going to use F12 several times, but the popup should never show up.
|
||||
// Add a listener on popupshown to make sure this doesn't happen
|
||||
const failOnPopupShown = () => {
|
||||
ok(false, "The enable devtools popup should not be displayed");
|
||||
};
|
||||
popup.addEventListener("popupshown", failOnPopupShown);
|
||||
|
||||
info("Check that F12 can now open the toolbox.");
|
||||
const toolbox = await openDevToolsWithKey("VK_F12");
|
||||
is(popup.state, "closed", "The enable devtools popup is still hidden");
|
||||
|
||||
info("Press F12 and wait for the toolbox to be destroyed");
|
||||
await closeDevToolsWithKey(toolbox, "VK_F12");
|
||||
is(popup.state, "closed", "The enable devtools popup is still hidden");
|
||||
|
||||
// cleanup
|
||||
popup.removeEventListener("popupshown", failOnPopupShown);
|
||||
}
|
||||
/* exported checkF12IsEnabled */
|
|
@ -205,8 +205,6 @@ loader.lazyRequireGetter(
|
|||
true
|
||||
);
|
||||
|
||||
const DEVTOOLS_F12_DISABLED_PREF = "devtools.experiment.f12.shortcut_disabled";
|
||||
|
||||
/**
|
||||
* A "Toolbox" is the component that holds all the tools for one specific
|
||||
* target. Visually, it's a document that includes the tools tabs and all
|
||||
|
@ -239,14 +237,6 @@ function Toolbox(commands, selectedTool, hostType, contentWindow, frameId) {
|
|||
this.commands = commands;
|
||||
this._descriptorFront = commands.descriptorFront;
|
||||
|
||||
// If the user opened the toolbox, we can now enable the F12 shortcut.
|
||||
if (Services.prefs.getBoolPref(DEVTOOLS_F12_DISABLED_PREF, false)) {
|
||||
// If the toolbox is opening while F12 was disabled, the user might have
|
||||
// pressed F12 and seen the "enable devtools" notification.
|
||||
// Flip the preference.
|
||||
Services.prefs.setBoolPref(DEVTOOLS_F12_DISABLED_PREF, false);
|
||||
}
|
||||
|
||||
// Map of the available DevTools WebExtensions:
|
||||
// Map<extensionUUID, extensionName>
|
||||
this._webExtensions = new Map();
|
||||
|
|
|
@ -25,8 +25,6 @@ const kDebuggerPrefs = [
|
|||
"devtools.chrome.enabled",
|
||||
];
|
||||
|
||||
const DEVTOOLS_F12_DISABLED_PREF = "devtools.experiment.f12.shortcut_disabled";
|
||||
|
||||
const DEVTOOLS_POLICY_DISABLED_PREF = "devtools.policy.disabled";
|
||||
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
@ -350,13 +348,6 @@ DevToolsStartup.prototype = {
|
|||
const isInitialLaunch =
|
||||
cmdLine.state == Ci.nsICommandLine.STATE_INITIAL_LAUNCH;
|
||||
if (isInitialLaunch) {
|
||||
// The F12 shortcut might be disabled to avoid accidental usage.
|
||||
// Users who are already considered as devtools users should not be
|
||||
// impacted.
|
||||
if (this.isDevToolsUser()) {
|
||||
Services.prefs.setBoolPref(DEVTOOLS_F12_DISABLED_PREF, false);
|
||||
}
|
||||
|
||||
// Store devtoolsFlag to check it later in onWindowReady.
|
||||
this.devtoolsFlag = flags.devtools;
|
||||
|
||||
|
|
|
@ -4117,9 +4117,6 @@ pref("devtools.remote.adb.extensionURL", "https://ftp.mozilla.org/pub/labs/devto
|
|||
// Enable Inactive CSS detection; used both by the client and the server.
|
||||
pref("devtools.inspector.inactive.css.enabled", true);
|
||||
|
||||
// The F12 experiment aims at disabling f12 on selected profiles.
|
||||
pref("devtools.experiment.f12.shortcut_disabled", false);
|
||||
|
||||
#if defined(NIGHTLY_BUILD) || defined(MOZ_DEV_EDITION)
|
||||
// Define in StaticPrefList.yaml and override here since StaticPrefList.yaml
|
||||
// doesn't provide a way to lock the pref
|
||||
|
|
Загрузка…
Ссылка в новой задаче