Title: [272651] trunk/LayoutTests
Revision
272651
Author
r...@igalia.com
Date
2021-02-10 07:19:02 -0800 (Wed, 10 Feb 2021)

Log Message

Add support for modifier keys in test_driver.send_keys()
https://bugs.webkit.org/show_bug.cgi?id=221465

Reviewed by Carlos Garcia Campos.

LayoutTests/imported/w3c:

Allow to send modifier keys combinations, like "Ctrl + y" through test_driver.send_keys().

* web-platform-tests/resources/testdriver-vendor.js:
(convertSeleniumKeyCode):
(window.test_driver_internal.send_keys):
* web-platform-tests/uievents/keyboard/modifier-keys-combinations-expected.txt: Added.
* web-platform-tests/uievents/keyboard/modifier-keys-combinations.html: Added.

LayoutTests:

Add specific -expected.txt file for Mac platform. Meta key is detected differently than in other platforms.

* platform/ios/TestExpectations: Skip test as it's timing out on iOS.
* platform/mac/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-combinations-expected.txt: Added.
* platform/mac/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-expected.txt: Update expectations as it nows mostly passes.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (272650 => 272651)


--- trunk/LayoutTests/ChangeLog	2021-02-10 15:04:17 UTC (rev 272650)
+++ trunk/LayoutTests/ChangeLog	2021-02-10 15:19:02 UTC (rev 272651)
@@ -1,3 +1,16 @@
+2021-02-10  Manuel Rego Casasnovas  <r...@igalia.com>
+
+        Add support for modifier keys in test_driver.send_keys()
+        https://bugs.webkit.org/show_bug.cgi?id=221465
+
+        Reviewed by Carlos Garcia Campos.
+
+        Add specific -expected.txt file for Mac platform. Meta key is detected differently than in other platforms.
+
+        * platform/ios/TestExpectations: Skip test as it's timing out on iOS.
+        * platform/mac/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-combinations-expected.txt: Added.
+        * platform/mac/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-expected.txt: Update expectations as it nows mostly passes.
+
 2021-02-10  Zalan Bujtas  <za...@apple.com>
 
         [LFC][IFC] Pass in sane content width values to InlineContentBreaker

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (272650 => 272651)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-02-10 15:04:17 UTC (rev 272650)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-02-10 15:19:02 UTC (rev 272651)
@@ -1,3 +1,18 @@
+2021-02-10  Manuel Rego Casasnovas  <r...@igalia.com>
+
+        Add support for modifier keys in test_driver.send_keys()
+        https://bugs.webkit.org/show_bug.cgi?id=221465
+
+        Reviewed by Carlos Garcia Campos.
+
+        Allow to send modifier keys combinations, like "Ctrl + y" through test_driver.send_keys().
+
+        * web-platform-tests/resources/testdriver-vendor.js:
+        (convertSeleniumKeyCode):
+        (window.test_driver_internal.send_keys):
+        * web-platform-tests/uievents/keyboard/modifier-keys-combinations-expected.txt: Added.
+        * web-platform-tests/uievents/keyboard/modifier-keys-combinations.html: Added.
+
 2021-02-10  Sergio Villar Senin  <svil...@igalia.com>
 
         [css-flexbox] Import & update latest WPT flexbox tests

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/resources/testdriver-vendor.js (272650 => 272651)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/resources/testdriver-vendor.js	2021-02-10 15:04:17 UTC (rev 272650)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/resources/testdriver-vendor.js	2021-02-10 15:19:02 UTC (rev 272651)
@@ -155,30 +155,34 @@
 
     // https://seleniumhq.github.io/selenium/docs/api/py/webdriver/selenium.webdriver.common.keys.html
     // FIXME: Add more cases.
-    // FIXME: Add the support for modifier keys.
     const SeleniumCharCodeToEventSenderKey = {
-        0xE003: 'delete',
-        0xE004: '\t',
-        0xE00D: ' ',
-        0xE012: 'leftArrow',
-        0xE013: 'upArrow',
-        0xE014: 'rightArrow',
-        0xE015: 'downArrow',
-        0xE008: 'leftShift',
-        0xE009: 'leftControl',
-        0xE00A: 'leftAlt',
-        0xE03D: 'leftMeta',
+        0xE003: { key: 'delete' },
+        0xE004: { key: '\t' },
+        0xE00D: { key: ' ' },
+        0xE012: { key: 'leftArrow' },
+        0xE013: { key: 'upArrow' },
+        0xE014: { key: 'rightArrow' },
+        0xE015: { key: 'downArrow' },
+        0xE008: { key: 'leftShift', modifier: 'shiftKey' },
+        0xE009: { key: 'leftControl', modifier: 'ctrlKey' },
+        0xE00A: { key: 'leftAlt', modifier: 'altKey' },
+        0xE03D: { key: 'leftMeta', modifier: 'metaKey' },
     };
 
     function convertSeleniumKeyCode(key)
     {
         const code = key.charCodeAt(0);
-        return SeleniumCharCodeToEventSenderKey[code] || key;
+        return SeleniumCharCodeToEventSenderKey[code] || { key: key };
     }
 
     const keyList = [];
-    for (const key of keys)
-        keyList.push(convertSeleniumKeyCode(key));
+    const modifiers = [];
+    for (const key of keys) {
+        let convertedKey = convertSeleniumKeyCode(key);
+        keyList.push(convertedKey.key);
+        if (convertedKey.modifier)
+          modifiers.push(convertedKey.modifier);
+    }
 
     if (testRunner.isIOSFamily && testRunner.isWebKit2) {
         return new Promise((resolve) => {
@@ -185,12 +189,12 @@
             testRunner.runUIScript(`
                 const keyList = JSON.parse('${JSON.stringify(keyList)}');
                 for (const key of keyList)
-                    uiController.keyDown(key);`, resolve);
+                    uiController.keyDown(key, modifiers);`, resolve);
         });
     }
 
     for (const key of keyList)
-        eventSender.keyDown(key);
+        eventSender.keyDown(key, modifiers);
     return Promise.resolve();
 }
 

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-combinations-expected.txt (0 => 272651)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-combinations-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-combinations-expected.txt	2021-02-10 15:19:02 UTC (rev 272651)
@@ -0,0 +1,7 @@
+Target
+
+PASS Check sending "Shift + y" key combination
+PASS Check sending "Control + y" key combination
+PASS Check sending "Alt + y" key combination
+PASS Check sending "Meta + y" key combination
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-combinations.html (0 => 272651)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-combinations.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-combinations.html	2021-02-10 15:19:02 UTC (rev 272651)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<meta charset="utf-8" />
+<title>UI Events Test: Modifier keys combinations</title>
+<link rel="author" title="Manuel Rego Casasnovas" href=""
+<link rel="help" href="" />
+<meta name="assert" content="This test checks that modifier keys combinations are properly detected in 'keydown' event.">
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<div id="target" tabindex="0">Target</div>
+<script>
+  const keys = {
+    "Shift": '\uE008' + 'y',
+    "Control": '\uE009' + 'y',
+    "Alt": '\uE00A' + 'y',
+    "Meta": '\uE03D' + 'y',
+  };
+
+  target.focus();
+  for (const [key, code] of Object.entries(keys)) {
+    promise_test(() => {
+      return new Promise(resolve => {
+        target.addEventListener("keydown", (event) => {
+          if (event.key != key)
+              resolve(event);
+        });
+        test_driver.send_keys(target, code);
+      }).then((event) => {
+        if (event.shiftKey) {
+          // Shift + y will send a "Y" keydown event on Chromium and Firefox, but a "y" one on WebKit.
+          assert_true(event.key == "y" || event.key == "Y");
+        } else {
+          assert_equals(event.key, "y");
+        }
+        assert_equals(event.shiftKey, key === "Shift");
+        assert_equals(event.ctrlKey, key === "Control");
+        assert_equals(event.altKey, key === "Alt");
+        assert_equals(event.metaKey, key === "Meta");
+      });
+    }, `Check sending "${key} + y" key combination`);
+  }
+</script>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (272650 => 272651)


--- trunk/LayoutTests/platform/ios/TestExpectations	2021-02-10 15:04:17 UTC (rev 272650)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2021-02-10 15:19:02 UTC (rev 272651)
@@ -3504,3 +3504,4 @@
 webkit.org/b/221486 imported/w3c/web-platform-tests/shadow-dom/nested-slot-remove-crash.html [ Skip ]
 
 webkit.org/b/221466 imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys.html [ Skip ]
+webkit.org/b/221465 imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-combinations.html [ Skip ]

Added: trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-combinations-expected.txt (0 => 272651)


--- trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-combinations-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-combinations-expected.txt	2021-02-10 15:19:02 UTC (rev 272651)
@@ -0,0 +1,7 @@
+Target
+
+PASS Check sending "Shift + y" key combination
+PASS Check sending "Control + y" key combination
+PASS Check sending "Alt + y" key combination
+FAIL Check sending "Meta + y" key combination assert_equals: expected "y" but got "leftMeta"
+

Modified: trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-expected.txt (272650 => 272651)


--- trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-expected.txt	2021-02-10 15:04:17 UTC (rev 272650)
+++ trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/uievents/keyboard/modifier-keys-expected.txt	2021-02-10 15:19:02 UTC (rev 272651)
@@ -1,7 +1,7 @@
 Target
 
-FAIL Check sending Shift key assert_equals: expected true but got false
-FAIL Check sending Control key assert_equals: expected true but got false
-FAIL Check sending Alt key assert_equals: expected true but got false
+PASS Check sending Shift key
+PASS Check sending Control key
+PASS Check sending Alt key
 FAIL Check sending Meta key assert_equals: expected "Meta" but got "leftMeta"
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to