diff options
-rw-r--r-- | qutebrowser/browser/commands.py | 34 | ||||
-rw-r--r-- | tests/end2end/features/caret.feature | 4 | ||||
-rw-r--r-- | tests/end2end/features/keyinput.feature | 3 |
3 files changed, 17 insertions, 24 deletions
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 4ce677caa..83a846b85 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -10,7 +10,7 @@ import functools from typing import cast, Callable, Dict, Union, Optional from qutebrowser.qt.widgets import QApplication, QTabBar -from qutebrowser.qt.core import Qt, QUrl, QEvent, QUrlQuery, QTimer +from qutebrowser.qt.core import Qt, QUrl, QEvent, QUrlQuery from qutebrowser.commands import userscripts, runners from qutebrowser.api import cmdutils @@ -1790,26 +1790,20 @@ class CommandDispatcher: except keyutils.KeyParseError as e: raise cmdutils.CommandError(str(e)) - events = [] for keyinfo in sequence: - events.append(keyinfo.to_event(QEvent.Type.KeyPress)) - events.append(keyinfo.to_event(QEvent.Type.KeyRelease)) - - if global_: - window = QApplication.focusWindow() - if window is None: - raise cmdutils.CommandError("No focused window!") - for event in events: - QApplication.postEvent(window, event) - else: - tab = self._current_widget() - - def _send_fake_key_after_delay(): - """Delay events to workaround timing issue in e2e tests on 6.7.""" - for event in events: - tab.send_event(event) - - QTimer.singleShot(10, _send_fake_key_after_delay) + press_event = keyinfo.to_event(QEvent.Type.KeyPress) + release_event = keyinfo.to_event(QEvent.Type.KeyRelease) + + if global_: + window = QApplication.focusWindow() + if window is None: + raise cmdutils.CommandError("No focused window!") + QApplication.postEvent(window, press_event) + QApplication.postEvent(window, release_event) + else: + tab = self._current_widget() + tab.send_event(press_event) + tab.send_event(release_event) @cmdutils.register(instance='command-dispatcher', scope='window', debug=True, backend=usertypes.Backend.QtWebKit) diff --git a/tests/end2end/features/caret.feature b/tests/end2end/features/caret.feature index 44df60c03..d6e65440c 100644 --- a/tests/end2end/features/caret.feature +++ b/tests/end2end/features/caret.feature @@ -74,7 +74,6 @@ Feature: Caret mode And I run :mode-leave And I run :jseval document.activeElement.blur(); And I run :fake-key <tab> - And I wait for "* Got key: <qutebrowser.keyinput.keyutils.KeyInfo key='Key_Tab' modifiers='NoModifier' text='<Tab>'> (dry_run True)" in the log And I run :selection-follow Then data/hello.txt should be loaded @@ -84,7 +83,6 @@ Feature: Caret mode And I run :mode-leave And I run :jseval document.activeElement.blur(); And I run :fake-key <tab> - And I wait for "* Got key: <qutebrowser.keyinput.keyutils.KeyInfo key='Key_Tab' modifiers='NoModifier' text='<Tab>'> (dry_run True)" in the log And I run :selection-follow Then data/hello.txt should be loaded @@ -94,7 +92,6 @@ Feature: Caret mode And I run :mode-leave And I run :jseval document.activeElement.blur(); And I run :fake-key <tab> - And I wait for "* Got key: <qutebrowser.keyinput.keyutils.KeyInfo key='Key_Tab' modifiers='NoModifier' text='<Tab>'> (dry_run True)" in the log And I run :selection-follow --tab Then data/hello.txt should be loaded @@ -104,6 +101,5 @@ Feature: Caret mode And I run :mode-leave And I run :jseval document.activeElement.blur(); And I run :fake-key <tab> - And I wait for "* Got key: <qutebrowser.keyinput.keyutils.KeyInfo key='Key_Tab' modifiers='NoModifier' text='<Tab>'> (dry_run True)" in the log And I run :selection-follow --tab Then data/hello.txt should be loaded diff --git a/tests/end2end/features/keyinput.feature b/tests/end2end/features/keyinput.feature index 3ab5d2434..f7f354def 100644 --- a/tests/end2end/features/keyinput.feature +++ b/tests/end2end/features/keyinput.feature @@ -32,6 +32,7 @@ Feature: Keyboard input Scenario: :fake-key sending key to the website When I open data/keyinput/log.html + And I wait 0.01s And I run :fake-key x Then the javascript message "key press: 88" should be logged And the javascript message "key release: 88" should be logged @@ -48,12 +49,14 @@ Feature: Keyboard input Scenario: :fake-key sending special key to the website When I open data/keyinput/log.html + And I wait 0.01s And I run :fake-key <Escape> Then the javascript message "key press: 27" should be logged And the javascript message "key release: 27" should be logged Scenario: :fake-key sending keychain to the website When I open data/keyinput/log.html + And I wait 0.01s And I run :fake-key x<greater>y<less>" " Then the javascript message "key press: 88" should be logged And the javascript message "key release: 88" should be logged |