Diff
Modified: trunk/Source/WebKit/ChangeLog (269034 => 269035)
--- trunk/Source/WebKit/ChangeLog 2020-10-27 13:01:12 UTC (rev 269034)
+++ trunk/Source/WebKit/ChangeLog 2020-10-27 13:26:48 UTC (rev 269035)
@@ -1,3 +1,21 @@
+2020-10-27 Carlos Garcia Campos <[email protected]>
+
+ WebDriver: sequence of char key press is not supported
+ https://bugs.webkit.org/show_bug.cgi?id=217951
+
+ Reviewed by Brian Burg.
+
+ We are assuming there can be only one char key pressed at a time. Use a HashSet to store the currently pressed
+ char keys and the handle them the same way we do with virtual keys.
+
+ Fixes: imported/w3c/webdriver/tests/perform_actions/key_events.py::test_sequence_of_keydown_printable_keys_sends_events
+
+ * UIProcess/Automation/SimulatedInputDispatcher.cpp:
+ (WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
+ * UIProcess/Automation/SimulatedInputDispatcher.h:
+ * UIProcess/Automation/WebAutomationSession.cpp:
+ (WebKit::WebAutomationSession::performInteractionSequence):
+
2020-10-27 Tetsuharu Ohzeki <[email protected]>
Make WebCore::FocusDirection to enum class
Modified: trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp (269034 => 269035)
--- trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp 2020-10-27 13:01:12 UTC (rev 269034)
+++ trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp 2020-10-27 13:26:48 UTC (rev 269035)
@@ -339,17 +339,46 @@
#endif // !ENABLE(WEBDRIVER_TOUCH_INTERACTIONS)
break;
}
- case SimulatedInputSourceType::Keyboard:
+ case SimulatedInputSourceType::Keyboard: {
#if !ENABLE(WEBDRIVER_KEYBOARD_INTERACTIONS)
RELEASE_ASSERT_NOT_REACHED();
#else
+ auto comparePressedCharKeys = [](const auto& a, const auto& b) {
+ if (a.size() != b.size())
+ return false;
+ for (const auto& charKey : a) {
+ if (!b.contains(charKey))
+ return false;
+ }
+ return true;
+ };
+
// The "dispatch a key{Down,Up} action" algorithms (ยง17.4 Dispatching Actions).
- if (!a.pressedCharKey && b.pressedCharKey) {
- LOG(Automation, "SimulatedInputDispatcher[%p]: simulating KeyPress[key=%c] for transition to %d.%d", this, b.pressedCharKey.value(), m_keyframeIndex, m_inputSourceStateIndex);
- m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyPress, b.pressedCharKey.value(), WTFMove(eventDispatchFinished));
- } else if (a.pressedCharKey && !b.pressedCharKey) {
- LOG(Automation, "SimulatedInputDispatcher[%p]: simulating KeyRelease[key=%c] for transition to %d.%d", this, a.pressedCharKey.value(), m_keyframeIndex, m_inputSourceStateIndex);
- m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyRelease, a.pressedCharKey.value(), WTFMove(eventDispatchFinished));
+ if (!comparePressedCharKeys(a.pressedCharKeys, b.pressedCharKeys)) {
+ bool simulatedAnInteraction = false;
+ for (auto charKey : b.pressedCharKeys) {
+ if (!a.pressedCharKeys.contains(charKey)) {
+ ASSERT_WITH_MESSAGE(!simulatedAnInteraction, "Only one CharKey may differ at a time between two input source states.");
+ if (simulatedAnInteraction)
+ continue;
+ simulatedAnInteraction = true;
+
+ LOG(Automation, "SimulatedInputDispatcher[%p]: simulating KeyPress[key=%c] for transition to %d.%d", this, charKey, m_keyframeIndex, m_inputSourceStateIndex);
+ m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyPress, charKey, WTFMove(eventDispatchFinished));
+ }
+ }
+
+ for (auto charKey : a.pressedCharKeys) {
+ if (!b.pressedCharKeys.contains(charKey)) {
+ ASSERT_WITH_MESSAGE(!simulatedAnInteraction, "Only one CharKey may differ at a time between two input source states.");
+ if (simulatedAnInteraction)
+ continue;
+ simulatedAnInteraction = true;
+
+ LOG(Automation, "SimulatedInputDispatcher[%p]: simulating KeyRelease[key=%c] for transition to %d.%d", this, charKey, m_keyframeIndex, m_inputSourceStateIndex);
+ m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyRelease, charKey, WTFMove(eventDispatchFinished));
+ }
+ }
} else if (a.pressedVirtualKeys != b.pressedVirtualKeys) {
bool simulatedAnInteraction = false;
for (const auto& iter : b.pressedVirtualKeys) {
@@ -383,6 +412,7 @@
eventDispatchFinished(WTF::nullopt);
#endif // !ENABLE(WEBDRIVER_KEYBOARD_INTERACTIONS)
break;
+ }
case SimulatedInputSourceType::Wheel:
#if !ENABLE(WEBDRIVER_WHEEL_INTERACTIONS)
RELEASE_ASSERT_NOT_REACHED();
Modified: trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h (269034 => 269035)
--- trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h 2020-10-27 13:01:12 UTC (rev 269034)
+++ trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h 2020-10-27 13:26:48 UTC (rev 269035)
@@ -32,6 +32,7 @@
#include <WebCore/IntSize.h>
#include <wtf/CompletionHandler.h>
#include <wtf/HashSet.h>
+#include <wtf/ListHashSet.h>
#include <wtf/Optional.h>
#include <wtf/RefCounted.h>
#include <wtf/RunLoop.h>
@@ -59,6 +60,7 @@
using VirtualKey = Inspector::Protocol::Automation::VirtualKey;
using VirtualKeyMap = HashMap<VirtualKey, VirtualKey, WTF::IntHash<VirtualKey>, WTF::StrongEnumHashTraits<VirtualKey>>;
using CharKey = UChar32;
+using CharKeySet = ListHashSet<CharKey>;
using MouseButton = Inspector::Protocol::Automation::MouseButton;
using MouseInteraction = Inspector::Protocol::Automation::MouseInteraction;
using MouseMoveOrigin = Inspector::Protocol::Automation::MouseMoveOrigin;
@@ -78,7 +80,7 @@
};
struct SimulatedInputSourceState {
- Optional<CharKey> pressedCharKey;
+ CharKeySet pressedCharKeys;
VirtualKeyMap pressedVirtualKeys;
Optional<MouseButton> pressedMouseButton;
Optional<MouseMoveOrigin> origin;
Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp (269034 => 269035)
--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp 2020-10-27 13:01:12 UTC (rev 269034)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp 2020-10-27 13:26:48 UTC (rev 269035)
@@ -2085,7 +2085,7 @@
auto pressedCharKeyString = stateObject->getString("pressedCharKey"_s);
if (!!pressedCharKeyString)
- sourceState.pressedCharKey = pressedCharKeyString.characterAt(0);
+ sourceState.pressedCharKeys.add(pressedCharKeyString.characterAt(0));
if (auto pressedVirtualKeysArray = stateObject->getArray("pressedVirtualKeys"_s)) {
VirtualKeyMap pressedVirtualKeys;
Modified: trunk/WebDriverTests/ChangeLog (269034 => 269035)
--- trunk/WebDriverTests/ChangeLog 2020-10-27 13:01:12 UTC (rev 269034)
+++ trunk/WebDriverTests/ChangeLog 2020-10-27 13:26:48 UTC (rev 269035)
@@ -1,3 +1,14 @@
+2020-10-27 Carlos Garcia Campos <[email protected]>
+
+ WebDriver: sequence of char key press is not supported
+ https://bugs.webkit.org/show_bug.cgi?id=217951
+
+ Reviewed by Brian Burg.
+
+ Remove expectations for test that is now passing.
+
+ * TestExpectations.json:
+
2020-10-22 Carlos Garcia Campos <[email protected]>
WebDriver: handle key events with non-ASCII unicode code point
Modified: trunk/WebDriverTests/TestExpectations.json (269034 => 269035)
--- trunk/WebDriverTests/TestExpectations.json 2020-10-27 13:01:12 UTC (rev 269034)
+++ trunk/WebDriverTests/TestExpectations.json 2020-10-27 13:26:48 UTC (rev 269035)
@@ -388,9 +388,6 @@
},
"test_special_key_sends_keydown[SEPARATOR-expected63]": {
"expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/184967"}}
- },
- "test_sequence_of_keydown_printable_keys_sends_events": {
- "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/184967"}}
}
}
},