Changeset 254424 in webkit


Ignore:
Timestamp:
Jan 13, 2020 1:31:24 AM (4 years ago)
Author:
Carlos Garcia Campos
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):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebDriver/ChangeLog

    r254329 r254424  
     12020-01-13  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebDriver: pressed virtual keys not correctly handled in action sequences
     4        https://bugs.webkit.org/show_bug.cgi?id=205997
     5
     6        Reviewed by Brian Burg.
     7
     8        We are assuming that only one virtual key can be pressed and that a key up always releases the pressed virtual
     9        key if any. We should keep a list of pressed keys and remove them from the list when key up happens for them.
     10
     11        Fixes: imported/w3c/webdriver/tests/perform_actions/key_modifiers.py::test_shift_modifier_generates_capital_letters[\ue008]
     12               imported/w3c/webdriver/tests/perform_actions/key_modifiers.py::test_shift_modifier_generates_capital_letters[\ue050]
     13
     14        * Session.cpp:
     15        (WebDriver::Session::performActions):
     16        * Session.h:
     17
    1182020-01-10  Carlos Garcia Campos  <cgarcia@igalia.com>
    219
  • trunk/Source/WebDriver/Session.cpp

    r254329 r254424  
    25772577                case Action::Type::Key:
    25782578                    switch (action.subtype) {
    2579                     case Action::Subtype::KeyUp:
    2580                         if (currentState.pressedVirtualKey)
    2581                             currentState.pressedVirtualKey = WTF::nullopt;
     2579                    case Action::Subtype::KeyUp: {
     2580                        KeyModifier modifier;
     2581                        auto virtualKey = virtualKeyForKey(action.key.value()[0], modifier);
     2582                        if (!virtualKey.isNull())
     2583                            currentState.pressedVirtualKeys.remove(virtualKey);
    25822584                        else
    25832585                            currentState.pressedKey = WTF::nullopt;
    25842586                        break;
     2587                    }
    25852588                    case Action::Subtype::KeyDown: {
    25862589                        KeyModifier modifier;
    25872590                        auto virtualKey = virtualKeyForKey(action.key.value()[0], modifier);
    25882591                        if (!virtualKey.isNull())
    2589                             currentState.pressedVirtualKey = virtualKey;
     2592                            currentState.pressedVirtualKeys.add(virtualKey);
    25902593                        else
    25912594                            currentState.pressedKey = action.key.value();
     
    26042607                    if (currentState.pressedKey)
    26052608                        state->setString("pressedCharKey"_s, currentState.pressedKey.value());
    2606                     if (currentState.pressedVirtualKey) {
     2609                    if (!currentState.pressedVirtualKeys.isEmpty()) {
    26072610                        // FIXME: support parsing and tracking multiple virtual keys.
    26082611                        Ref<JSON::Array> virtualKeys = JSON::Array::create();
    2609                         virtualKeys->pushString(currentState.pressedVirtualKey.value());
     2612                        for (const auto& virtualKey : currentState.pressedVirtualKeys)
     2613                            virtualKeys->pushString(virtualKey);
    26102614                        state->setArray("pressedVirtualKeys"_s, WTFMove(virtualKeys));
    26112615                    }
  • trunk/Source/WebDriver/Session.h

    r253883 r254424  
    3030#include <wtf/Forward.h>
    3131#include <wtf/Function.h>
     32#include <wtf/HashSet.h>
    3233#include <wtf/JSONValues.h>
    3334#include <wtf/OptionSet.h>
     
    203204        Optional<MouseButton> pressedButton;
    204205        Optional<String> pressedKey;
    205         Optional<String> pressedVirtualKey;
     206        HashSet<String> pressedVirtualKeys;
    206207    };
    207208    InputSourceState& inputSourceState(const String& id);
  • trunk/Source/WebKit/ChangeLog

    r254423 r254424  
     12020-01-13  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebDriver: pressed virtual keys not correctly handled in action sequences
     4        https://bugs.webkit.org/show_bug.cgi?id=205997
     5
     6        Reviewed by Brian Burg.
     7
     8        When modifiers are present we need to translate the keys that might be affected by the modifiers.
     9
     10        * UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp:
     11        (WebKit::doKeyStrokeEvent):
     12
    1132020-01-13  Carlos Garcia Campos  <cgarcia@igalia.com>
    214
  • trunk/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp

    r250818 r254424  
    155155    if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(), keyVal, &keys.outPtr(), &keysCount) && keysCount)
    156156        event->key.hardware_keycode = keys.get()[0].keycode;
     157
     158    if (state) {
     159        gdk_keymap_translate_keyboard_state(gdk_keymap_get_default(), event->key.hardware_keycode, static_cast<GdkModifierType>(state),
     160            0, &event->key.keyval, nullptr, nullptr, nullptr);
     161    }
    157162
    158163    gtk_main_do_event(event.get());
Note: See TracChangeset for help on using the changeset viewer.