Bug 1763961 [devtools] Make unchecking "Pick an element from the page" in "Available Toolbox Buttons" disable hotkey for opening element picker/inspector r=jdescottes,devtools-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D203948
This commit is contained in:
artem manushenkov 2024-03-13 12:47:28 +00:00
Родитель f9672884e8
Коммит ca9371a138
2 изменённых файлов: 32 добавлений и 1 удалений

Просмотреть файл

@ -161,7 +161,11 @@ Tools.inspector = {
// that trigger the element picker.
preventRaisingOnKey: true,
onkey(panel, toolbox) {
toolbox.nodePicker.togglePicker();
if (
Services.prefs.getBoolPref("devtools.command-button-pick.enabled", false)
) {
toolbox.nodePicker.togglePicker();
}
},
isToolSupported(toolbox) {

Просмотреть файл

@ -97,6 +97,33 @@ add_task(async function () {
key.synthesizeKey();
await onPickerStop;
ok(true, "picker-stopped event received, highlighter stopped");
info(
`Run the keyboard shortcut for ${test.id} with picker shortcut disabled`
);
await pushPref("devtools.command-button-pick.enabled", false);
// Switch to another panel to assure the hotkey still opens inspector
await toolbox.selectTool("webconsole");
await waitUntil(() => toolbox.currentToolId === "webconsole");
// Check if picker event times out
const onHasPickerStarted = Promise.race([
toolbox.nodePicker.once("picker-started").then(() => true),
wait(100).then(() => false),
]);
key.synthesizeKey();
const hasPickerStarted = await onHasPickerStarted;
ok(!hasPickerStarted, "picker was not started on shortcut");
is(
toolbox.currentToolId,
"inspector",
"shortcut still switches tab to inspector"
);
await pushPref("devtools.command-button-pick.enabled", true);
}
await onSelectTool;