Bug 1482968 Part 2: Add a test of modifier key clicks and drags on input elements. r=smaug!
authorBrad Werth <bwerth@mozilla.com>
Fri, 17 Aug 2018 18:59:36 +0000
changeset 487298 765311be9111caa8c14db72f0652a0b5a384916c
parent 487297 b42785b1186cb24c42e6e8fb56342fbe40867b07
child 487299 c75f6fed5d90fc3345f4ba5aa6779d40dc1248b3
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1482968
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/html/test/forms/test_input_number_mouse_events.html
dom/html/test/forms/test_input_range_mouse_and_touch_events.html
--- a/dom/html/test/forms/test_input_number_mouse_events.html
+++ b/dom/html/test/forms/test_input_number_mouse_events.html
@@ -58,16 +58,38 @@ function test() {
   is(input.value, "1", "Test mouseup on spin-up button");
 
   // Test click on spin-down button:
   synthesizeMouse(input, SPIN_DOWN_X, SPIN_DOWN_Y, { type: "mousedown" });
   is(input.value, "0", "Test step-down on mousedown on spin-down button");
   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;
   input.step = "any";
   synthesizeMouse(input, SPIN_UP_X, SPIN_UP_Y, { type: "mousedown" });
   is(input.value, "1", "Test step-up on mousedown on spin-up button with step='any'");
   synthesizeMouse(input, SPIN_UP_X, SPIN_UP_Y, { type: "mouseup" });
   is(input.value, "1", "Test mouseup on spin-up button with step='any'");
--- a/dom/html/test/forms/test_input_range_mouse_and_touch_events.html
+++ b/dom/html/test/forms/test_input_range_mouse_and_touch_events.html
@@ -129,26 +129,36 @@ function test(synthesizeFunc, clickOrTap
   is(elem.value, MINIMUM_OF_RANGE, "Test dragging of range to position outside range (" + moveName + ")");
 
   synthesizeFunc(elem, maxX+100, midY, { type: endName });
   is(elem.value, MINIMUM_OF_RANGE, "Test dragging of range to position outside range (" + 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;
     synthesizeFunc(elem, midX, midY, eventParams);
     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();
   }
   elem.value = QUARTER_OF_RANGE;
   elem.addEventListener(startName, preventDefault);
   synthesizeFunc(elem, midX, midY, {});
   is(elem.value, QUARTER_OF_RANGE, "Test that preventDefault() works");