forked from mirrors/gecko-dev
`GlobalKeyListener` try to match shortcut keys with exactly checking `Shift` state, but for the cases which do not match localized language and active keyboard layout location, it scans another shortcut keys with ignoring `Shift` state if no handler is available. `<command>` elements and `<key>` elements may be disabled conditionally. E.g., Zoom-in/Zoom-out are disabled when current zoom level is max/min value. In this case, it's odd that another shortcut key which does not exactly match the modifiers works. Therefore, this patch makes `GlobalKeyListener` does not try to scan handlers with ignoring `Shift` state if it has already found a disabled handler which exactly matches with the modifiers. Differential Revision: https://phabricator.services.mozilla.com/D184789
84 lines
2.5 KiB
JavaScript
84 lines
2.5 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
|
|
add_task(async function () {
|
|
let tabs = [];
|
|
for (let i = 0; i < 10; i++) {
|
|
const tab = BrowserTestUtils.addTab(gBrowser);
|
|
tabs.push(tab);
|
|
}
|
|
const kIsMac = AppConstants.platform == "macosx";
|
|
|
|
await BrowserTestUtils.withNewTab(
|
|
"https://example.com/browser/toolkit/content/tests/browser/file_empty.html",
|
|
async function (browser) {
|
|
let NativeKeyConstants = {};
|
|
Services.scriptloader.loadSubScript(
|
|
"chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js",
|
|
NativeKeyConstants
|
|
);
|
|
|
|
function promiseSynthesizeAccelHyphenMinusWithAZERTY() {
|
|
return new Promise(resolve =>
|
|
EventUtils.synthesizeNativeKey(
|
|
EventUtils.KEYBOARD_LAYOUT_FRENCH_PC,
|
|
kIsMac
|
|
? NativeKeyConstants.MAC_VK_ANSI_6
|
|
: NativeKeyConstants.WIN_VK_6,
|
|
{ accelKey: true },
|
|
kIsMac ? "-" : "",
|
|
kIsMac ? "-" : "",
|
|
resolve
|
|
)
|
|
);
|
|
}
|
|
|
|
async function waitForCondition(aFunc) {
|
|
for (let i = 0; i < 60; i++) {
|
|
await new Promise(resolve =>
|
|
requestAnimationFrame(() => requestAnimationFrame(resolve))
|
|
);
|
|
if (aFunc(ZoomManager.getFullZoomForBrowser(browser))) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
const minZoomLevel = ZoomManager.MIN;
|
|
while (true) {
|
|
const currentZoom = ZoomManager.getFullZoomForBrowser(browser);
|
|
if (minZoomLevel == currentZoom) {
|
|
break;
|
|
}
|
|
info(`Trying to zoom out: ${currentZoom}`);
|
|
await promiseSynthesizeAccelHyphenMinusWithAZERTY();
|
|
if (!(await waitForCondition(aZoomLevel => aZoomLevel < currentZoom))) {
|
|
ok(false, `Failed to zoom out from ${currentZoom}`);
|
|
return;
|
|
}
|
|
}
|
|
|
|
await promiseSynthesizeAccelHyphenMinusWithAZERTY();
|
|
await waitForCondition(() => false);
|
|
is(
|
|
gBrowser.selectedBrowser,
|
|
browser,
|
|
"Tab shouldn't be changed by Ctrl+- of AZERTY keyboard layout"
|
|
);
|
|
// Reset the zoom before going to the next test.
|
|
EventUtils.synthesizeKey("0", { accelKey: true });
|
|
await waitForCondition(aZoomLevel => aZoomLevel == 1);
|
|
}
|
|
);
|
|
|
|
while (tabs.length) {
|
|
await new Promise(resolve => {
|
|
const tab = tabs.shift();
|
|
BrowserTestUtils.waitForTabClosing(tab).then(resolve);
|
|
BrowserTestUtils.removeTab(tab);
|
|
});
|
|
}
|
|
});
|