diff options
author | Florian Bruhin <me@the-compiler.org> | 2022-01-05 16:33:20 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2022-01-05 16:33:20 +0100 |
commit | 9ce7b48f46812dab0554114d315f62b0bd12a40d (patch) | |
tree | e443f503ce0455b773986e50577d6de2b5773b58 | |
parent | 74d0d4d9573d060908efa9a1e08411878be4587f (diff) | |
parent | 887488f870424663917fd51f06ce3c202f0b2773 (diff) | |
download | qutebrowser-9ce7b48f46812dab0554114d315f62b0bd12a40d.tar.gz qutebrowser-9ce7b48f46812dab0554114d315f62b0bd12a40d.zip |
Merge remote-tracking branch 'origin/pr/6626'
-rw-r--r-- | qutebrowser/browser/webengine/notification.py | 13 | ||||
-rw-r--r-- | tests/end2end/features/notifications.feature | 8 |
2 files changed, 19 insertions, 2 deletions
diff --git a/qutebrowser/browser/webengine/notification.py b/qutebrowser/browser/webengine/notification.py index e943e44e9..69c702aec 100644 --- a/qutebrowser/browser/webengine/notification.py +++ b/qutebrowser/browser/webengine/notification.py @@ -65,7 +65,7 @@ if TYPE_CHECKING: from qutebrowser.config import config from qutebrowser.misc import objects -from qutebrowser.utils import qtutils, log, utils, debug, message, version +from qutebrowser.utils import qtutils, log, utils, debug, message, version, objreg from qutebrowser.qt import sip @@ -368,6 +368,17 @@ class NotificationBridgePresenter(QObject): # https://www.riverbankcomputing.com/pipermail/pyqt/2020-May/042918.html log.misc.debug(f"Ignoring click request for notification {notification_id} " "due to PyQt bug") + return + self._focus_first_matching_tab(notification) + + def _focus_first_matching_tab(self, notification: "QWebEngineNotification") -> None: + for win_id in objreg.window_registry: + tabbedbrowser = objreg.get("tabbed-browser", window=win_id, scope="window") + for idx, tab in enumerate(tabbedbrowser.widgets()): + if tab.url().matches(notification.origin(), QUrl.RemovePath): + tabbedbrowser.widget.setCurrentIndex(idx) + return + log.misc.debug(f"No matching tab found for {notification.origin()}") def _drop_adapter(self) -> None: """Drop the currently active adapter (if any). diff --git a/tests/end2end/features/notifications.feature b/tests/end2end/features/notifications.feature index 08c5f725f..cd34793ef 100644 --- a/tests/end2end/features/notifications.feature +++ b/tests/end2end/features/notifications.feature @@ -4,7 +4,8 @@ Feature: Notifications HTML5 notification API interaction Background: - Given I open data/javascript/notifications.html + Given I clean up open tabs + And I open data/javascript/notifications.html And I set content.notifications.enabled to true And I run :click-element id button And I clean up the notification server @@ -120,8 +121,13 @@ Feature: Notifications Scenario: User clicks presented notification When I run :click-element id show-button And I wait for the javascript message "notification shown" + And I open about:blank in a new tab And I click the notification Then the javascript message "notification clicked" should be logged + And the following tabs should be open: + - about:blank + - data/javascript/notifications.html (active) + - about:blank @pyqtwebengine<5.15.0 Scenario: User clicks presented notification (old Qt) |