summaryrefslogtreecommitdiff
path: root/qutebrowser
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 /qutebrowser
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.
Diffstat (limited to 'qutebrowser')
-rw-r--r--qutebrowser/browser/commands.py34
1 files changed, 14 insertions, 20 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)