Make content.headers.referer work on QtWebEngine
This commit is contained in:
parent
bd21686e0d
commit
17c7663ad0
@ -42,6 +42,7 @@ Added
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
||||
- The `content.headers.referer` setting now works on QtWebEngine.
|
||||
- The `:repeat` command now takes a count which is multiplied with the given
|
||||
"times" argument.
|
||||
- The default keybinding to leave passthrough mode was changed from `<Ctrl-V>`
|
||||
|
@ -1677,6 +1677,8 @@ Default: +pass:[true]+
|
||||
=== content.headers.referer
|
||||
When to send the Referer header.
|
||||
The Referer header tells websites from which website you were coming from when visiting them.
|
||||
No restart is needed with QtWebKit.
|
||||
This setting requires a restart.
|
||||
|
||||
Type: <<types,String>>
|
||||
|
||||
@ -1684,12 +1686,10 @@ Valid values:
|
||||
|
||||
* +always+: Always send the Referer.
|
||||
* +never+: Never send the Referer. This is not recommended, as some sites may break.
|
||||
* +same-domain+: Only send the Referer for the same domain. This will still protect your privacy, but shouldn't break any sites.
|
||||
* +same-domain+: Only send the Referer for the same domain. This will still protect your privacy, but shouldn't break any sites. With QtWebEngine, the referer will still be sent for other domains, but with stripped path information.
|
||||
|
||||
Default: +pass:[same-domain]+
|
||||
|
||||
This setting is only available with the QtWebKit backend.
|
||||
|
||||
[[content.headers.user_agent]]
|
||||
=== content.headers.user_agent
|
||||
User agent to send. Unset to send the default.
|
||||
|
@ -456,14 +456,18 @@ content.headers.referer:
|
||||
- never: "Never send the Referer. This is not recommended, as some sites
|
||||
may break."
|
||||
- same-domain: "Only send the Referer for the same domain. This will
|
||||
still protect your privacy, but shouldn't break any sites."
|
||||
backend: QtWebKit
|
||||
still protect your privacy, but shouldn't break any sites. With
|
||||
QtWebEngine, the referer will still be sent for other domains, but
|
||||
with stripped path information."
|
||||
restart: true
|
||||
desc: >-
|
||||
When to send the Referer header.
|
||||
|
||||
The Referer header tells websites from which website you were coming from
|
||||
when visiting them.
|
||||
|
||||
No restart is needed with QtWebKit.
|
||||
|
||||
content.headers.user_agent:
|
||||
default: null
|
||||
type:
|
||||
|
@ -215,4 +215,15 @@ def qt_args(namespace):
|
||||
raise utils.Unreachable("Unknown low-end device mode {}"
|
||||
.format(low_end_device_mode))
|
||||
|
||||
referrer = config.val.content.headers.referer
|
||||
if referrer == 'always':
|
||||
pass
|
||||
elif referrer == 'never':
|
||||
argv.append('--no-referrers')
|
||||
elif referrer == 'same-domain':
|
||||
argv.append('--reduced-referrer-granularity')
|
||||
else:
|
||||
raise utils.Unreachable("Unknown referrer {}"
|
||||
.format(referrer))
|
||||
|
||||
return argv
|
||||
|
@ -359,10 +359,11 @@ class TestQtArgs:
|
||||
return parser
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def patch_version_check(self, monkeypatch):
|
||||
"""Make sure no --disable-shared-workers argument gets added."""
|
||||
def reduce_args(self, monkeypatch, config_stub):
|
||||
"""Make sure no --disable-shared-workers/referer argument get added."""
|
||||
monkeypatch.setattr(configinit.qtutils, 'version_check',
|
||||
lambda version, compiled=False: True)
|
||||
config_stub.val.content.headers.referer = 'always'
|
||||
|
||||
@pytest.mark.parametrize('args, expected', [
|
||||
# No Qt arguments
|
||||
@ -524,6 +525,25 @@ class TestQtArgs:
|
||||
else:
|
||||
assert arg in args
|
||||
|
||||
@pytest.mark.parametrize('referer, arg', [
|
||||
('always', None),
|
||||
('never', '--no-referrers'),
|
||||
('same-domain', '--reduced-referrer-granularity'),
|
||||
])
|
||||
def test_referer(self, config_stub, monkeypatch, parser, referer, arg):
|
||||
monkeypatch.setattr(configinit.objects, 'backend',
|
||||
usertypes.Backend.QtWebEngine)
|
||||
|
||||
config_stub.val.content.headers.referer = referer
|
||||
parsed = parser.parse_args([])
|
||||
args = configinit.qt_args(parsed)
|
||||
|
||||
if arg is None:
|
||||
assert '--no-referrers' not in args
|
||||
assert '--reduced-referrer-granularity' not in args
|
||||
else:
|
||||
assert arg in args
|
||||
|
||||
|
||||
@pytest.mark.parametrize('arg, confval, used', [
|
||||
# overridden by commandline arg
|
||||
|
Loading…
Reference in New Issue
Block a user