Bug 1482968 Part 2: Add a test of modifier key clicks and drags on input elements. r=smaug!

Depends on D3450

Differential Revision: https://phabricator.services.mozilla.com/D3451

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brad Werth 2018-08-17 18:59:36 +00:00
Родитель 50cab3e9c8
Коммит bac3e2671c
2 изменённых файлов: 35 добавлений и 3 удалений

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

@ -63,6 +63,28 @@ function test() {
synthesizeMouse(input, SPIN_DOWN_X, SPIN_DOWN_Y, { type: "mouseup" });
is(input.value, "0", "Test mouseup on spin-down button");
// Test clicks with modifiers that mean we should ignore the click:
var modifiersIgnore = ["altGrKey", "fnKey", "osKey"];
for (var modifier of modifiersIgnore) {
input.value = 0;
var eventParams = { type: "mousedown" };
eventParams[modifier] = true;
synthesizeMouse(input, SPIN_UP_X, SPIN_UP_Y, eventParams);
is(input.value, "0", "We should ignore mousedown on spin-up button with modifier " + modifier);
synthesizeMouse(input, SPIN_UP_X, SPIN_UP_Y, { type: "mouseup" });
}
// Test clicks with modifiers that mean we should allow the click:
var modifiersAllow = ["shiftKey", "ctrlKey", "altKey", "metaKey"];
for (var modifier of modifiersAllow) {
input.value = 0;
var eventParams = { type: "mousedown" };
eventParams[modifier] = true;
synthesizeMouse(input, SPIN_UP_X, SPIN_UP_Y, eventParams);
is(input.value, "1", "We should allow mousedown on spin-up button with modifier " + modifier);
synthesizeMouse(input, SPIN_UP_X, SPIN_UP_Y, { type: "mouseup" });
}
// Test step="any" behavior:
input.value = 0;
var oldStep = input.step;

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

@ -134,9 +134,9 @@ function test(synthesizeFunc, clickOrTap, startName, moveName, endName) {
elem.style.direction = "ltr"; // reset direction
flush();
// Test mouse/touch events with modifiers are ignored:
var modifiers = ["shiftKey", "ctrlKey", "altKey", "metaKey", "accelKey", "altGrKey", "fnKey", "osKey"];
for (var modifier of modifiers) {
// Test mouse/touch events with certain modifiers are ignored:
var modifiersIgnore = ["ctrlKey", "altGrKey", "fnKey", "osKey"];
for (var modifier of modifiersIgnore) {
elem.value = QUARTER_OF_RANGE;
var eventParams = {};
eventParams[modifier] = true;
@ -144,6 +144,16 @@ function test(synthesizeFunc, clickOrTap, startName, moveName, endName) {
is(elem.value, QUARTER_OF_RANGE, "Test " + clickOrTap + " in the middle of range with " + modifier + " modifier key is ignored");
}
// Test mouse/touch events with certain modifiers are allowed:
var modifiersAllow = ["shiftKey", "altKey", "metaKey"];
for (var modifier of modifiersAllow) {
elem.value = QUARTER_OF_RANGE;
var eventParams = {};
eventParams[modifier] = true;
synthesizeFunc(elem, midX, midY, eventParams);
is(elem.value, MIDDLE_OF_RANGE, "Test " + clickOrTap + " in the middle of range with " + modifier + " modifier key is allowed");
}
// Test that preventDefault() works:
function preventDefault(e) {
e.preventDefault();