diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index ab9bfaef2..726a2efab 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -1673,6 +1673,21 @@ class WebEngineTab(browsertab.AbstractTab): navigation.accepted = False self.load_url(navigation.url) + # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-140515 + ua_setting = "content.headers.user_agent" + if ( + navigation.accepted + and config.instance.get(ua_setting, navigation.url, fallback=False) + is not usertypes.UNSET + and navigation.navigation_type == usertypes.NavigationRequest.Type.redirect + and navigation.is_main_frame + and utils.VersionNumber(6, 5) <= qtwe_ver < utils.VersionNumber(6, 10, 1) + ): + navigation.accepted = False + # Using QTimer.singleShot as WORKAROUND for this crashing otherwise + # with QtWebEngine 6.10: https://bugreports.qt.io/browse/QTBUG-140543 + QTimer.singleShot(0, functools.partial(self.load_url, navigation.url)) + if not navigation.accepted or not navigation.is_main_frame: return diff --git a/tests/end2end/features/misc.feature b/tests/end2end/features/misc.feature index 6825621ea..a6ae7b87a 100644 --- a/tests/end2end/features/misc.feature +++ b/tests/end2end/features/misc.feature @@ -386,6 +386,13 @@ Feature: Various utility commands. And I run :jseval console.log(window.navigator.userAgent) Then the header User-Agent should be set to toaster + Scenario: User-agent header with redirect + When I run :set -u localhost content.headers.user_agent toaster + And I open redirect-to?url=headers without waiting + And I wait until headers is loaded + And I run :jseval console.log(window.navigator.userAgent) + Then the header User-Agent should be set to toaster + Scenario: User-agent header (JS) When I set content.headers.user_agent to toaster And I open about:blank