Bug 1791640 - [devtools] Do not use custom zoom keys when the toolbox is hosted in a tab r=ochameau

Differential Revision: https://phabricator.services.mozilla.com/D157830
This commit is contained in:
Julian Descottes 2022-09-21 17:49:38 +00:00
Родитель a3bbbf281f
Коммит ee708d7ab9
3 изменённых файлов: 69 добавлений и 1 удалений

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

@ -98,6 +98,7 @@ skip-if =
debug
asan # This test leaks. See bug 1529005
[browser_aboutdebugging_devtoolstoolbox_tooltip_markupview.js]
[browser_aboutdebugging_devtoolstoolbox_zoom.js]
[browser_aboutdebugging_fenix_runtime_display.js]
[browser_aboutdebugging_fenix_runtime_node_picker.js]
[browser_aboutdebugging_message_close.js]

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

@ -0,0 +1,65 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from helper-collapsibilities.js */
Services.scriptloader.loadSubScript(
CHROME_URL_ROOT + "helper-collapsibilities.js",
this
);
const { LocalizationHelper } = require("devtools/shared/l10n");
const L10N = new LocalizationHelper(
"devtools/client/locales/toolbox.properties"
);
// Check that the about:devtools-toolbox tab can be zoomed in and that the zoom
// persists after switching tabs.
add_task(async function() {
info("Force all debug target panes to be expanded");
prepareCollapsibilitiesTest();
const { document, tab, window } = await openAboutDebugging();
await selectThisFirefoxPage(document, window.AboutDebugging.store);
const { devtoolsTab, devtoolsWindow } = await openAboutDevtoolsToolbox(
document,
tab,
window
);
is(getZoom(devtoolsWindow), 1, "default zoom level correct");
info("Increase the zoom level");
// Note that we read the shortcut from the toolbox properties, but that should
// match the default browser shortcut `full-zoom-enlarge-shortcut`.
synthesizeKeyShortcut(L10N.getStr("toolbox.zoomIn.key"));
await waitFor(() => getZoom(devtoolsWindow) > 1);
is(getZoom(devtoolsWindow).toFixed(2), "1.09", "zoom level increased");
info("Switch tabs between about:debugging and the toolbox tab");
gBrowser.selectedTab = tab;
gBrowser.selectedTab = devtoolsTab;
info("Wait for the browser to reapply the zoom");
await wait(500);
is(
getZoom(devtoolsWindow).toFixed(2),
"1.09",
"zoom level was restored after switching tabs"
);
info("Restore the default zoom level");
synthesizeKeyShortcut(L10N.getStr("toolbox.zoomReset.key"));
await waitFor(() => getZoom(devtoolsWindow) === 1);
is(getZoom(devtoolsWindow), 1, "default zoom level restored");
await closeAboutDevtoolsToolbox(document, devtoolsTab, window);
await removeTab(tab);
});
function getZoom(win) {
return win.windowUtils.fullZoom;
}

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

@ -1204,7 +1204,9 @@ Toolbox.prototype = {
}
// Add zoom-related shortcuts.
if (!this._hostOptions || this._hostOptions.zoom === true) {
if (this.hostType != Toolbox.HostType.PAGE) {
// When the toolbox is rendered in a tab (ie host type is PAGE), the
// zoom should be handled by the default browser shortcuts.
ZoomKeys.register(this.win, this.shortcuts);
}
},