Changeset 269035 in webkit


Ignore:
Timestamp:
Oct 27, 2020 6:26:48 AM (21 months ago)
Author:
Carlos Garcia Campos
Message:

WebDriver: sequence of char key press is not supported
https://bugs.webkit.org/show_bug.cgi?id=217951

Reviewed by Brian Burg.

Source/WebKit:

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):

WebDriverTests:

Remove expectations for test that is now passing.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r269027 r269035  
     12020-10-27  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebDriver: sequence of char key press is not supported
     4        https://bugs.webkit.org/show_bug.cgi?id=217951
     5
     6        Reviewed by Brian Burg.
     7
     8        We are assuming there can be only one char key pressed at a time. Use a HashSet to store the currently pressed
     9        char keys and the handle them the same way we do with virtual keys.
     10
     11        Fixes: imported/w3c/webdriver/tests/perform_actions/key_events.py::test_sequence_of_keydown_printable_keys_sends_events
     12
     13        * UIProcess/Automation/SimulatedInputDispatcher.cpp:
     14        (WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
     15        * UIProcess/Automation/SimulatedInputDispatcher.h:
     16        * UIProcess/Automation/WebAutomationSession.cpp:
     17        (WebKit::WebAutomationSession::performInteractionSequence):
     18
    1192020-10-27  Tetsuharu Ohzeki  <tetsuharu.ohzeki@gmail.com>
    220
  • trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp

    r268793 r269035  
    340340        break;
    341341    }
    342     case SimulatedInputSourceType::Keyboard:
     342    case SimulatedInputSourceType::Keyboard: {
    343343#if !ENABLE(WEBDRIVER_KEYBOARD_INTERACTIONS)
    344344        RELEASE_ASSERT_NOT_REACHED();
    345345#else
     346        auto comparePressedCharKeys = [](const auto& a, const auto& b) {
     347            if (a.size() != b.size())
     348                return false;
     349            for (const auto& charKey : a) {
     350                if (!b.contains(charKey))
     351                    return false;
     352            }
     353            return true;
     354        };
     355
    346356        // The "dispatch a key{Down,Up} action" algorithms (§17.4 Dispatching Actions).
    347         if (!a.pressedCharKey && b.pressedCharKey) {
    348             LOG(Automation, "SimulatedInputDispatcher[%p]: simulating KeyPress[key=%c] for transition to %d.%d", this, b.pressedCharKey.value(), m_keyframeIndex, m_inputSourceStateIndex);
    349             m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyPress, b.pressedCharKey.value(), WTFMove(eventDispatchFinished));
    350         } else if (a.pressedCharKey && !b.pressedCharKey) {
    351             LOG(Automation, "SimulatedInputDispatcher[%p]: simulating KeyRelease[key=%c] for transition to %d.%d", this, a.pressedCharKey.value(), m_keyframeIndex, m_inputSourceStateIndex);
    352             m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyRelease, a.pressedCharKey.value(), WTFMove(eventDispatchFinished));
     357        if (!comparePressedCharKeys(a.pressedCharKeys, b.pressedCharKeys)) {
     358            bool simulatedAnInteraction = false;
     359            for (auto charKey : b.pressedCharKeys) {
     360                if (!a.pressedCharKeys.contains(charKey)) {
     361                    ASSERT_WITH_MESSAGE(!simulatedAnInteraction, "Only one CharKey may differ at a time between two input source states.");
     362                    if (simulatedAnInteraction)
     363                        continue;
     364                    simulatedAnInteraction = true;
     365
     366                    LOG(Automation, "SimulatedInputDispatcher[%p]: simulating KeyPress[key=%c] for transition to %d.%d", this, charKey, m_keyframeIndex, m_inputSourceStateIndex);
     367                    m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyPress, charKey, WTFMove(eventDispatchFinished));
     368                }
     369            }
     370
     371            for (auto charKey : a.pressedCharKeys) {
     372                if (!b.pressedCharKeys.contains(charKey)) {
     373                    ASSERT_WITH_MESSAGE(!simulatedAnInteraction, "Only one CharKey may differ at a time between two input source states.");
     374                    if (simulatedAnInteraction)
     375                        continue;
     376                    simulatedAnInteraction = true;
     377
     378                    LOG(Automation, "SimulatedInputDispatcher[%p]: simulating KeyRelease[key=%c] for transition to %d.%d", this, charKey, m_keyframeIndex, m_inputSourceStateIndex);
     379                    m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyRelease, charKey, WTFMove(eventDispatchFinished));
     380                }
     381            }
    353382        } else if (a.pressedVirtualKeys != b.pressedVirtualKeys) {
    354383            bool simulatedAnInteraction = false;
     
    384413#endif // !ENABLE(WEBDRIVER_KEYBOARD_INTERACTIONS)
    385414        break;
     415    }
    386416    case SimulatedInputSourceType::Wheel:
    387417#if !ENABLE(WEBDRIVER_WHEEL_INTERACTIONS)
  • trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h

    r268858 r269035  
    3333#include <wtf/CompletionHandler.h>
    3434#include <wtf/HashSet.h>
     35#include <wtf/ListHashSet.h>
    3536#include <wtf/Optional.h>
    3637#include <wtf/RefCounted.h>
     
    6061using VirtualKeyMap = HashMap<VirtualKey, VirtualKey, WTF::IntHash<VirtualKey>, WTF::StrongEnumHashTraits<VirtualKey>>;
    6162using CharKey = UChar32;
     63using CharKeySet = ListHashSet<CharKey>;
    6264using MouseButton = Inspector::Protocol::Automation::MouseButton;
    6365using MouseInteraction = Inspector::Protocol::Automation::MouseInteraction;
     
    7981
    8082struct SimulatedInputSourceState {
    81     Optional<CharKey> pressedCharKey;
     83    CharKeySet pressedCharKeys;
    8284    VirtualKeyMap pressedVirtualKeys;
    8385    Optional<MouseButton> pressedMouseButton;
  • trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp

    r268793 r269035  
    20862086            auto pressedCharKeyString = stateObject->getString("pressedCharKey"_s);
    20872087            if (!!pressedCharKeyString)
    2088                 sourceState.pressedCharKey = pressedCharKeyString.characterAt(0);
     2088                sourceState.pressedCharKeys.add(pressedCharKeyString.characterAt(0));
    20892089
    20902090            if (auto pressedVirtualKeysArray = stateObject->getArray("pressedVirtualKeys"_s)) {
  • trunk/WebDriverTests/ChangeLog

    r268858 r269035  
     12020-10-27  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebDriver: sequence of char key press is not supported
     4        https://bugs.webkit.org/show_bug.cgi?id=217951
     5
     6        Reviewed by Brian Burg.
     7
     8        Remove expectations for test that is now passing.
     9
     10        * TestExpectations.json:
     11
    1122020-10-22  Carlos Garcia Campos  <cgarcia@igalia.com>
    213
  • trunk/WebDriverTests/TestExpectations.json

    r268858 r269035  
    389389            "test_special_key_sends_keydown[SEPARATOR-expected63]": {
    390390                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/184967"}}
    391             },
    392             "test_sequence_of_keydown_printable_keys_sends_events": {
    393                 "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/184967"}}
    394391            }
    395392        }
Note: See TracChangeset for help on using the changeset viewer.