Bug 1417955 - Ensure we get the correct keyCode for a space character, r=marionette-reviewers,maja_zf
authorJames Graham <james@hoppipolla.co.uk>
Wed, 25 Mar 2020 19:36:54 +0000
changeset 520435 979782ad22dedfc002f9840dd0c86506a8916c54
parent 520434 9b5868b12da47026db8ea79ab4543e24a3677724
child 520436 f7beaca4d787e4994451f3ecb748cf67d09e2959
push id37250
push userdvarga@mozilla.com
push dateThu, 26 Mar 2020 04:04:15 +0000
treeherdermozilla-central@85bae8580dde [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarionette-reviewers, maja_zf
bugs1417955
milestone76.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 1417955 - Ensure we get the correct keyCode for a space character, r=marionette-reviewers,maja_zf Differential Revision: https://phabricator.services.mozilla.com/D68199
testing/marionette/action.js
testing/marionette/event.js
testing/web-platform/tests/webdriver/tests/perform_actions/key_events.py
--- a/testing/marionette/action.js
+++ b/testing/marionette/action.js
@@ -329,17 +329,17 @@ const KEY_CODE_LOOKUP = {
   "'": "Quote",
   ":": "Semicolon",
   ";": "Semicolon",
   "\uE008": "ShiftLeft",
   "\uE050": "ShiftRight",
   "/": "Slash",
   "?": "Slash",
   "\uE00D": "Space",
-  "  ": "Space",
+  " ": "Space",
   "\uE004": "Tab",
 };
 
 /** Represents possible values for a pointer-move origin. */
 action.PointerOrigin = {
   Viewport: "viewport",
   Pointer: "pointer",
 };
--- a/testing/marionette/event.js
+++ b/testing/marionette/event.js
@@ -323,16 +323,19 @@ function computeKeyCodeFromChar_(char, w
 
     case "?":
     case "/":
       return KeyboardEvent.DOM_VK_SLASH;
 
     case "\n":
       return KeyboardEvent.DOM_VK_RETURN;
 
+    case " ":
+      return KeyboardEvent.DOM_VK_SPACE;
+
     default:
       return 0;
   }
 }
 /* eslint-enable */
 /* eslint-disable no-restricted-globals */
 
 /**
--- a/testing/web-platform/tests/webdriver/tests/perform_actions/key_events.py
+++ b/testing/web-platform/tests/webdriver/tests/perform_actions/key_events.py
@@ -1,12 +1,13 @@
 # META: timeout=long
+import copy
+from collections import defaultdict
 
 import pytest
-import copy
 
 from tests.perform_actions.support.keys import ALL_EVENTS, Keys, ALTERNATIVE_KEY_NAMES
 from tests.perform_actions.support.refine import filter_dict, get_events, get_keys
 
 
 def test_keyup_only_sends_no_events(session, key_reporter, key_chain):
     key_chain.key_up("a").perform()
 
@@ -216,8 +217,26 @@ def test_special_key_sends_keydown(sessi
         del alt_expected["code"]
     assert first_event == expected or first_event == alt_expected
     # only printable characters should be recorded in input field
     entered_keys = get_keys(key_reporter)
     if len(expected["key"]) == 1:
         assert entered_keys == expected["key"]
     else:
         assert len(entered_keys) == 0
+
+
+def test_space_char_equals_pua(session, key_reporter, key_chain):
+    key_chain \
+        .key_down(Keys.SPACE) \
+        .key_up(Keys.SPACE) \
+        .key_down(" ") \
+        .key_up(" ") \
+        .perform()
+    all_events = get_events(session)
+    by_type = defaultdict(list)
+    for event in all_events:
+        by_type[event["type"]].append(event)
+
+    for event_type in by_type:
+        events = by_type[event_type]
+        assert len(events) == 2
+        assert events[0] == events[1]