Bug 1396823 - Added tests for special keys that use multiple codepoints draft
authorGreg Fraley <gsfraley@gmail.com>
Mon, 05 Mar 2018 16:02:38 -0500
changeset 763353 3f8dcfc7d84c
parent 763352 827a7dba4798
push id101426
push userbmo:gsfraley@gmail.com
push dateMon, 05 Mar 2018 21:03:25 +0000
bugs1396823
milestone60.0a1
Bug 1396823 - Added tests for special keys that use multiple codepoints MozReview-Commit-ID: G3SCO5kIap
testing/web-platform/tests/webdriver/tests/actions/special_keys.py
--- a/testing/web-platform/tests/webdriver/tests/actions/special_keys.py
+++ b/testing/web-platform/tests/webdriver/tests/actions/special_keys.py
@@ -1,16 +1,16 @@
 # META: timeout=long
 
 import pytest
 import time
+from webdriver import InvalidArgumentException
 from tests.actions.support.keys import ALL_EVENTS, Keys
 from tests.actions.support.refine import filter_dict, get_keys, get_events
 
-
 @pytest.mark.parametrize("name,expected", ALL_EVENTS.items())
 def test_webdriver_special_key_sends_keydown(session,
                                              key_reporter,
                                              key_chain,
                                              name,
                                              expected):
     if name.startswith("F"):
         # Prevent default behavior for F1, etc., but only after keydown
@@ -38,8 +38,34 @@ def test_webdriver_special_key_sends_key
         del expected["code"]
     assert first_event == 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
+
+
+@pytest.mark.parametrize("value,valid", [
+    (u"f", True),
+    (u"fa", False),
+    (u"\u0BA8\u0BBF", True),
+    (u"\u0BA8\u0BBFb", False),
+    (u"\u0BA8\u0BBF\u0BA8", False),
+    (u"\u1100\u1161\u11A8", True),
+    (u"\u1100\u1161\u11A8c", False)
+])
+def test_multiple_codepoint_keys_behave_correctly(session,
+                                                  key_reporter,
+                                                  key_chain,
+                                                  value,
+                                                  valid):
+    try:
+        key_chain \
+            .key_down(value) \
+            .key_up(value) \
+            .perform()
+        
+        assert valid
+        assert get_keys(key_reporter) == value
+    except InvalidArgumentException:
+        assert not valid
\ No newline at end of file