Work around per-domain UA header not working on redirects
See https://bugreports.qt.io/browse/QTBUG-140515 Fixes #8679
This commit is contained in:
parent
ff76871f4e
commit
26368f0b90
|
|
@ -1673,6 +1673,21 @@ class WebEngineTab(browsertab.AbstractTab):
|
||||||
navigation.accepted = False
|
navigation.accepted = False
|
||||||
self.load_url(navigation.url)
|
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:
|
if not navigation.accepted or not navigation.is_main_frame:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -386,6 +386,13 @@ Feature: Various utility commands.
|
||||||
And I run :jseval console.log(window.navigator.userAgent)
|
And I run :jseval console.log(window.navigator.userAgent)
|
||||||
Then the header User-Agent should be set to toaster
|
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)
|
Scenario: User-agent header (JS)
|
||||||
When I set content.headers.user_agent to toaster
|
When I set content.headers.user_agent to toaster
|
||||||
And I open about:blank
|
And I open about:blank
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue