Files
firefox/devtools/client/framework/test/browser_keybindings_02.js
T
Alexandre Poirot c42905da36 Bug 1838443 - [devtools] Move preview data from redux store to react state. r=devtools-reviewers,perftest-reviewers,sparky,bomsy
This data is transient and only specific to the Editor's index react component.
There is no need to share nor persist this data in Redux,
this would avoid unecessary complexity/layers and avoid a few state updates.

Note that the target.match(:hover) was probably a poorly documented way to prevent
rending preview for token that are no longer hovered (the comment about whitespace sounds weird).

Also tweak waitForSelectedSource to also wait for CodeMirror to be updated.
Otherwise, we might try to hover tokens while CodeMirror is still udpating...
While doing that, use the L10N string instead of the final localized string.

Differential Revision: https://phabricator.services.mozilla.com/D180992
2023-06-19 17:18:27 +00:00

67 lines
1.8 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that the toolbox keybindings still work after the host is changed.
const URL = "data:text/html;charset=utf8,test page";
var { Toolbox } = require("resource://devtools/client/framework/toolbox.js");
const L10N = new LocalizationHelper(
"devtools/client/locales/toolbox.properties"
);
function getZoomValue() {
return parseFloat(Services.prefs.getCharPref("devtools.toolbox.zoomValue"));
}
add_task(async function () {
info("Create a test tab and open the toolbox");
const tab = await addTab(URL);
const toolbox = await gDevTools.showToolboxForTab(tab, "webconsole");
const { RIGHT, BOTTOM } = Toolbox.HostType;
for (const type of [RIGHT, BOTTOM, RIGHT]) {
info("Switch to host type " + type);
await toolbox.switchHost(type);
info("Try to use the toolbox shortcuts");
await checkKeyBindings(toolbox);
}
Services.prefs.clearUserPref("devtools.toolbox.zoomValue");
Services.prefs.setCharPref("devtools.toolbox.host", BOTTOM);
await toolbox.destroy();
gBrowser.removeCurrentTab();
});
function zoomWithKey(toolbox, key) {
const shortcut = L10N.getStr(key);
if (!shortcut) {
info("Key was empty, skipping zoomWithKey");
return;
}
info("Zooming with key: " + key);
const currentZoom = getZoomValue();
synthesizeKeyShortcut(shortcut, toolbox.win);
isnot(
getZoomValue(),
currentZoom,
"The zoom level was changed in the toolbox"
);
}
function checkKeyBindings(toolbox) {
zoomWithKey(toolbox, "toolbox.zoomIn.key");
zoomWithKey(toolbox, "toolbox.zoomIn2.key");
zoomWithKey(toolbox, "toolbox.zoomReset.key");
zoomWithKey(toolbox, "toolbox.zoomOut.key");
zoomWithKey(toolbox, "toolbox.zoomOut2.key");
zoomWithKey(toolbox, "toolbox.zoomReset2.key");
}