Add content.canvas_reading setting

See #2377
Closes #2235
This commit is contained in:
Florian Bruhin 2018-06-11 23:28:04 +02:00
parent ad7e080827
commit 093f07f552
5 changed files with 42 additions and 0 deletions

View File

@ -47,6 +47,8 @@ Added
(requires Qt 5.10).
* New `content.webrtc_public_interfaces_only` setting to only expose public
interfaces over WebRTC (requires Qt 5.9.2 or 5.11).
* New `content.canvas_reading` setting to disable reading from canvas
elements.
Changed
~~~~~~~

View File

@ -113,6 +113,7 @@
|<<content.cache.appcache,content.cache.appcache>>|Enable support for the HTML 5 web application cache feature.
|<<content.cache.maximum_pages,content.cache.maximum_pages>>|Maximum number of pages to hold in the global memory page cache.
|<<content.cache.size,content.cache.size>>|Size (in bytes) of the HTTP network cache. Null to use the default value.
|<<content.canvas_reading,content.canvas_reading>>|Allow websites to read canvas elements.
|<<content.cookies.accept,content.cookies.accept>>|Which cookies to accept.
|<<content.cookies.store,content.cookies.store>>|Store cookies.
|<<content.default_encoding,content.default_encoding>>|Default encoding to use for websites.
@ -1517,6 +1518,18 @@ Type: <<types,Int>>
Default: empty
[[content.canvas_reading]]
=== content.canvas_reading
Allow websites to read canvas elements.
Note this is needed for some websites to work properly.
This setting requires a restart.
Type: <<types,Bool>>
Default: +pass:[true]+
This setting is only available with the QtWebEngine backend.
[[content.cookies.accept]]
=== content.cookies.accept
Which cookies to accept.

View File

@ -237,6 +237,16 @@ content.cache.size:
With QtWebEngine, the maximum supported value is 2147483647 (~2 GB).
content.canvas_reading:
default: true
type: Bool
backend: QtWebEngine
restart: true
desc: >-
Allow websites to read canvas elements.
Note this is needed for some websites to work properly.
# Defaults from QWebSettings::QWebSettings() in
# qtwebkit/Source/WebKit/qt/Api/qwebsettings.cpp

View File

@ -176,6 +176,9 @@ def qt_args(namespace):
if config.val.qt.force_software_rendering == 'chromium':
argv.append('--disable-gpu')
if not config.val.content.canvas_reading:
argv.append('--disable-reading-from-canvas')
if not qtutils.version_check('5.11'):
# On Qt 5.11, we can control this via QWebEngineSettings
if not config.val.content.autoplay:

View File

@ -451,6 +451,20 @@ class TestQtArgs:
arg = '--force-webrtc-ip-handling-policy=default_public_interface_only'
assert (arg in args) == added
@pytest.mark.parametrize('backend, canvas_reading, added', [
(usertypes.Backend.QtWebEngine, True, False), # enabled
(usertypes.Backend.QtWebKit, False, False), # QtWebKit
(usertypes.Backend.QtWebEngine, False, True),
])
def test_canvas_reading(self, config_stub, monkeypatch, parser,
backend, canvas_reading, added):
config_stub.val.content.canvas_reading = canvas_reading
monkeypatch.setattr(configinit.objects, 'backend', backend)
parsed = parser.parse_args([])
args = configinit.qt_args(parsed)
assert ('--disable-reading-from-canvas' in args) == added
@pytest.mark.parametrize('arg, confval, used', [
# overridden by commandline arg