summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoofar <toofar@spalge.com>2024-04-27 17:52:43 +1200
committertoofar <toofar@spalge.com>2024-04-27 18:05:44 +1200
commit817091c61d12bf41c45008ae714db1c317c3d24e (patch)
tree0f19c41e65bfaf90bf176114ccbb0daab59aa089
parentd47d247941c4b1fe3adac0dae8be301b36aec85b (diff)
downloadqutebrowser-817091c61d12bf41c45008ae714db1c317c3d24e.tar.gz
qutebrowser-817091c61d12bf41c45008ae714db1c317c3d24e.zip
Revert "delay fake-key" and add waits in e2e tests instead
Previously (a209c86c55a4) I've added a delay in browser code before sending events to the page to account with a race condition where events weren't processed after navigating. Then I had to add extra checks to tests that had tight timing requirements. That was for click-element, this commit reverts an attempt at the same strategy for fake-key and instead adds wait statements in the tests that where hitting the original race condition (sending events "too soon" after a navigation). The reason for the different approach here is that after adding the delay in fake-key I had to add an extra "wait for log line" message to a few tests with tight timing requirements to watch for a Tab key press. That worked great for webengine but it made some tests start failing on webkit. We don't seem to get that log message on webkit. I've got no-idea why and frankly think I've spent way too much time on just a handful of tests already. It's unfortunate we have to add manually delays in the e2e tests. It makes me think if anyone else adds a test in the future with this combination of steps (open page, run fake-key) they'll run into the same issue and it'll be hard to spot. Oh well, we'll deal with that when it comes up. The tests that where failing on webkit are the ones in caret.feature touched in this commit. Reverts included in this commit: Revert "Delay fake-key events by 10ms" This reverts commit 9f050c7460c42f317ceaa20b320e97d371a2c0a0. Revert "Wait for evidence of Tab key press in tests before proceeding" This reverts commit d47d247941c4b1fe3adac0dae8be301b36aec85b.
-rw-r--r--qutebrowser/browser/commands.py34
-rw-r--r--tests/end2end/features/caret.feature4
-rw-r--r--tests/end2end/features/keyinput.feature3
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