diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index 7c021218e..9d73c0268 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -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 ~~~~~~~ diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 3479f7301..a9b2fc6bd 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -113,6 +113,7 @@ |<>|Enable support for the HTML 5 web application cache feature. |<>|Maximum number of pages to hold in the global memory page cache. |<>|Size (in bytes) of the HTTP network cache. Null to use the default value. +|<>|Allow websites to read canvas elements. |<>|Which cookies to accept. |<>|Store cookies. |<>|Default encoding to use for websites. @@ -1517,6 +1518,18 @@ Type: <> 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: <> + +Default: +pass:[true]+ + +This setting is only available with the QtWebEngine backend. + [[content.cookies.accept]] === content.cookies.accept Which cookies to accept. diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index a137489fd..d32ffef25 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -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 diff --git a/qutebrowser/config/configinit.py b/qutebrowser/config/configinit.py index 38adad534..c4418a17c 100644 --- a/qutebrowser/config/configinit.py +++ b/qutebrowser/config/configinit.py @@ -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: diff --git a/tests/unit/config/test_configinit.py b/tests/unit/config/test_configinit.py index a1c4face6..fcaac5400 100644 --- a/tests/unit/config/test_configinit.py +++ b/tests/unit/config/test_configinit.py @@ -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