summaryrefslogtreecommitdiff
path: root/qutebrowser
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2024-03-27 12:34:30 +0100
committerFlorian Bruhin <me@the-compiler.org>2024-03-27 12:34:30 +0100
commit982b8bdcecfba6fc1687a6a4942b9e3ab3221eb7 (patch)
tree18b5ae22aaa67b288e01cf5504e260e0f24bb78a /qutebrowser
parent0b220117e2c26dd3ca7639a7bda78a44c8959fbf (diff)
downloadqutebrowser-982b8bdcecfba6fc1687a6a4942b9e3ab3221eb7.tar.gz
qutebrowser-982b8bdcecfba6fc1687a6a4942b9e3ab3221eb7.zip
Fix input.insert_mode.auto_load race / test_auto_load flakiness
Fixes #8145, see #5390. As long as we don't have a solution to get notified about focus happening (#2471 possibly?), it looks like there is no better way to get notified about this, so a delay will need to do for now.
Diffstat (limited to 'qutebrowser')
-rw-r--r--qutebrowser/browser/browsertab.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py
index 4d14c9cd7..625046a9c 100644
--- a/qutebrowser/browser/browsertab.py
+++ b/qutebrowser/browser/browsertab.py
@@ -14,7 +14,7 @@ from typing import (cast, TYPE_CHECKING, Any, Callable, Iterable, List, Optional
from qutebrowser.qt import machinery
from qutebrowser.qt.core import (pyqtSignal, pyqtSlot, QUrl, QObject, QSizeF, Qt,
- QEvent, QPoint, QRect)
+ QEvent, QPoint, QRect, QTimer)
from qutebrowser.qt.gui import QKeyEvent, QIcon, QPixmap
from qutebrowser.qt.widgets import QApplication, QWidget
from qutebrowser.qt.printsupport import QPrintDialog, QPrinter
@@ -902,7 +902,13 @@ class AbstractTabPrivate:
modeman.enter(self._tab.win_id, usertypes.KeyMode.insert,
'load finished', only_if_normal=True)
- self._tab.elements.find_focused(_auto_insert_mode_cb)
+ # There seems to be a race between loadFinished being called,
+ # and the autoload attribute on websites actually focusing anything.
+ # Thus, we delay this by a bit. Locally, a delay of 13ms caused no races
+ # with 5000 test reruns (even with simultaneous CPU stress testing),
+ # so 65ms should be a safe bet and still not be too noticeable.
+ QTimer.singleShot(
+ 65, lambda: self._tab.elements.find_focused(_auto_insert_mode_cb))
def clear_ssl_errors(self) -> None:
raise NotImplementedError