Bug 1530220 - part2 : modify test in order to test different kinds of keycode. r=cpearce
authorAlastor Wu <alwu@mozilla.com>
Tue, 05 Mar 2019 02:09:50 +0000
changeset 520207 f706441a86b530d30be4fba47bff43f96ade97cb
parent 520206 7c1b053e161b0795c83fc39289a8d4335b146127
child 520208 9ce43f1e7bc080fe10b9b631c7501bc95cd87939
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1530220
milestone67.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 1530220 - part2 : modify test in order to test different kinds of keycode. r=cpearce Except printable keys, we would treat `carriage return` and `space` as supported user gesture inputs for activating document. Other keys won't activate document. Differential Revision: https://phabricator.services.mozilla.com/D21255
toolkit/content/tests/browser/browser_autoplay_policy_user_gestures.js
--- a/toolkit/content/tests/browser/browser_autoplay_policy_user_gestures.js
+++ b/toolkit/content/tests/browser/browser_autoplay_policy_user_gestures.js
@@ -6,17 +6,22 @@ var UserGestures = {
   MOUSE_CLICK: "mouse-click",
   MOUSE_MOVE: "mouse-move",
   KEYBOARD_PRESS: "keyboard-press",
 };
 
 var UserGestureTests = [
   {type: UserGestures.MOUSE_CLICK, isActivationGesture: true},
   {type: UserGestures.MOUSE_MOVE, isActivationGesture: false},
-  {type: UserGestures.KEYBOARD_PRESS, isActivationGesture: true},
+  // test different keycode here. printable key, non-printable key and other
+  // special keys.
+  {type: UserGestures.KEYBOARD_PRESS, isActivationGesture: true, keyCode: "a"},
+  {type: UserGestures.KEYBOARD_PRESS, isActivationGesture: false, keyCode: "VK_ESCAPE"},
+  {type: UserGestures.KEYBOARD_PRESS, isActivationGesture: true, keyCode: "VK_RETURN"},
+  {type: UserGestures.KEYBOARD_PRESS, isActivationGesture: true, keyCode: "VK_SPACE"},
 ];
 
 function setup_test_preference() {
   return SpecialPowers.pushPrefEnv({"set": [
     ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED],
     ["media.autoplay.enabled.user-gestures-needed", true],
     ["media.autoplay.block-webaudio", true],
     ["media.navigator.permission.fake", true],
@@ -28,17 +33,17 @@ function simulateUserGesture(gesture, ta
   switch (gesture.type) {
     case UserGestures.MOUSE_CLICK:
       return BrowserTestUtils.synthesizeMouseAtCenter("body", {button: 0},
                                                       targetBrowser);
     case UserGestures.MOUSE_MOVE:
       return BrowserTestUtils.synthesizeMouseAtCenter("body", {type: "mousemove"},
                                                       targetBrowser);
     case UserGestures.KEYBOARD_PRESS:
-      return BrowserTestUtils.sendChar("a", targetBrowser);
+      return BrowserTestUtils.synthesizeKey(gesture.keyCode, {}, targetBrowser);
     default:
       ok(false, "undefined user gesture");
       return false;
   }
 }
 
 async function test_play_without_user_gesture() {
   info("- open new tab -");