Title: [254424] trunk/Source
- Revision
- 254424
- Author
- [email protected]
- Date
- 2020-01-13 01:31:24 -0800 (Mon, 13 Jan 2020)
Log Message
WebDriver: pressed virtual keys not correctly handled in action sequences
https://bugs.webkit.org/show_bug.cgi?id=205997
Reviewed by Brian Burg.
Source/WebDriver:
We are assuming that only one virtual key can be pressed and that a key up always releases the pressed virtual
key if any. We should keep a list of pressed keys and remove them from the list when key up happens for them.
Fixes: imported/w3c/webdriver/tests/perform_actions/key_modifiers.py::test_shift_modifier_generates_capital_letters[\ue008]
imported/w3c/webdriver/tests/perform_actions/key_modifiers.py::test_shift_modifier_generates_capital_letters[\ue050]
* Session.cpp:
(WebDriver::Session::performActions):
* Session.h:
Source/WebKit:
When modifiers are present we need to translate the keys that might be affected by the modifiers.
* UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp:
(WebKit::doKeyStrokeEvent):
Modified Paths
Diff
Modified: trunk/Source/WebDriver/ChangeLog (254423 => 254424)
--- trunk/Source/WebDriver/ChangeLog 2020-01-13 09:27:41 UTC (rev 254423)
+++ trunk/Source/WebDriver/ChangeLog 2020-01-13 09:31:24 UTC (rev 254424)
@@ -1,3 +1,20 @@
+2020-01-13 Carlos Garcia Campos <[email protected]>
+
+ WebDriver: pressed virtual keys not correctly handled in action sequences
+ https://bugs.webkit.org/show_bug.cgi?id=205997
+
+ Reviewed by Brian Burg.
+
+ We are assuming that only one virtual key can be pressed and that a key up always releases the pressed virtual
+ key if any. We should keep a list of pressed keys and remove them from the list when key up happens for them.
+
+ Fixes: imported/w3c/webdriver/tests/perform_actions/key_modifiers.py::test_shift_modifier_generates_capital_letters[\ue008]
+ imported/w3c/webdriver/tests/perform_actions/key_modifiers.py::test_shift_modifier_generates_capital_letters[\ue050]
+
+ * Session.cpp:
+ (WebDriver::Session::performActions):
+ * Session.h:
+
2020-01-10 Carlos Garcia Campos <[email protected]>
Automation: evaluateJavaScriptFunction should use Promises
Modified: trunk/Source/WebDriver/Session.cpp (254423 => 254424)
--- trunk/Source/WebDriver/Session.cpp 2020-01-13 09:27:41 UTC (rev 254423)
+++ trunk/Source/WebDriver/Session.cpp 2020-01-13 09:31:24 UTC (rev 254424)
@@ -2576,17 +2576,20 @@
}
case Action::Type::Key:
switch (action.subtype) {
- case Action::Subtype::KeyUp:
- if (currentState.pressedVirtualKey)
- currentState.pressedVirtualKey = WTF::nullopt;
+ case Action::Subtype::KeyUp: {
+ KeyModifier modifier;
+ auto virtualKey = virtualKeyForKey(action.key.value()[0], modifier);
+ if (!virtualKey.isNull())
+ currentState.pressedVirtualKeys.remove(virtualKey);
else
currentState.pressedKey = WTF::nullopt;
break;
+ }
case Action::Subtype::KeyDown: {
KeyModifier modifier;
auto virtualKey = virtualKeyForKey(action.key.value()[0], modifier);
if (!virtualKey.isNull())
- currentState.pressedVirtualKey = virtualKey;
+ currentState.pressedVirtualKeys.add(virtualKey);
else
currentState.pressedKey = action.key.value();
break;
@@ -2603,10 +2606,11 @@
}
if (currentState.pressedKey)
state->setString("pressedCharKey"_s, currentState.pressedKey.value());
- if (currentState.pressedVirtualKey) {
+ if (!currentState.pressedVirtualKeys.isEmpty()) {
// FIXME: support parsing and tracking multiple virtual keys.
Ref<JSON::Array> virtualKeys = JSON::Array::create();
- virtualKeys->pushString(currentState.pressedVirtualKey.value());
+ for (const auto& virtualKey : currentState.pressedVirtualKeys)
+ virtualKeys->pushString(virtualKey);
state->setArray("pressedVirtualKeys"_s, WTFMove(virtualKeys));
}
break;
Modified: trunk/Source/WebDriver/Session.h (254423 => 254424)
--- trunk/Source/WebDriver/Session.h 2020-01-13 09:27:41 UTC (rev 254423)
+++ trunk/Source/WebDriver/Session.h 2020-01-13 09:31:24 UTC (rev 254424)
@@ -29,6 +29,7 @@
#include "Capabilities.h"
#include <wtf/Forward.h>
#include <wtf/Function.h>
+#include <wtf/HashSet.h>
#include <wtf/JSONValues.h>
#include <wtf/OptionSet.h>
#include <wtf/RefCounted.h>
@@ -202,7 +203,7 @@
String subtype;
Optional<MouseButton> pressedButton;
Optional<String> pressedKey;
- Optional<String> pressedVirtualKey;
+ HashSet<String> pressedVirtualKeys;
};
InputSourceState& inputSourceState(const String& id);
Modified: trunk/Source/WebKit/ChangeLog (254423 => 254424)
--- trunk/Source/WebKit/ChangeLog 2020-01-13 09:27:41 UTC (rev 254423)
+++ trunk/Source/WebKit/ChangeLog 2020-01-13 09:31:24 UTC (rev 254424)
@@ -1,5 +1,17 @@
2020-01-13 Carlos Garcia Campos <[email protected]>
+ WebDriver: pressed virtual keys not correctly handled in action sequences
+ https://bugs.webkit.org/show_bug.cgi?id=205997
+
+ Reviewed by Brian Burg.
+
+ When modifiers are present we need to translate the keys that might be affected by the modifiers.
+
+ * UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp:
+ (WebKit::doKeyStrokeEvent):
+
+2020-01-13 Carlos Garcia Campos <[email protected]>
+
Unreviewed. [GTK][WPE] Add missing autocleanup definition for WebKitInputMethodContext
I forgot to add it in r253749.
Modified: trunk/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp (254423 => 254424)
--- trunk/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp 2020-01-13 09:27:41 UTC (rev 254423)
+++ trunk/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp 2020-01-13 09:31:24 UTC (rev 254424)
@@ -155,6 +155,11 @@
if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(), keyVal, &keys.outPtr(), &keysCount) && keysCount)
event->key.hardware_keycode = keys.get()[0].keycode;
+ if (state) {
+ gdk_keymap_translate_keyboard_state(gdk_keymap_get_default(), event->key.hardware_keycode, static_cast<GdkModifierType>(state),
+ 0, &event->key.keyval, nullptr, nullptr, nullptr);
+ }
+
gtk_main_do_event(event.get());
if (doReleaseAfterPress) {
ASSERT(type == GDK_KEY_PRESS);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes