diff options
author | Jimmy <jimmy@spalge.com> | 2018-04-25 16:54:54 +1200 |
---|---|---|
committer | Jimmy <jimmy@spalge.com> | 2018-05-20 18:42:40 +1200 |
commit | b0d1a137dae4099a79a5779a02bbb61875298b2f (patch) | |
tree | 524d28637c93238d2ff2bed30571efd50b71762a /qutebrowser/browser/greasemonkey.py | |
parent | 13249329f70830b25a4ee736f78f7b304deaf010 (diff) | |
download | qutebrowser-b0d1a137dae4099a79a5779a02bbb61875298b2f.tar.gz qutebrowser-b0d1a137dae4099a79a5779a02bbb61875298b2f.zip |
Greasemonkey: Don't attempt scope isolation on webkit
Since the JSCore used by WebKit 602.1 doesn't fully support Proxy and I
can't think of a way to provide isolation otherwise just revert to the
old behaviour in that case. I am checking for the specific WebKit
version because I'm pretty sure that version just happened to be
released when Proxy support was only partially done, any later release
will presumably have a newer JSCore where it works.
There I changed the indentation of a block in the jinja template which
will have inflated the diff.
I added mocking of `objects.backend` to the `webview` and
`webenginewebview` fixtures, I am pretty sure they are mutually
exclusive so don't expect any issues from that.
Because of the feature detection being at template compile time I had to
tweak the test setup to be done via a fixture instead of the setupClass
functionality that I was using before.
Diffstat (limited to 'qutebrowser/browser/greasemonkey.py')
-rw-r--r-- | qutebrowser/browser/greasemonkey.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/qutebrowser/browser/greasemonkey.py b/qutebrowser/browser/greasemonkey.py index 578830793..db8246bab 100644 --- a/qutebrowser/browser/greasemonkey.py +++ b/qutebrowser/browser/greasemonkey.py @@ -31,9 +31,10 @@ import attr from PyQt5.QtCore import pyqtSignal, QObject, QUrl from qutebrowser.utils import (log, standarddir, jinja, objreg, utils, - javascript, urlmatch) + javascript, urlmatch, version, usertypes) from qutebrowser.commands import cmdutils from qutebrowser.browser import downloads +from qutebrowser.misc import objects def _scripts_dir(): @@ -108,13 +109,18 @@ class GreasemonkeyScript: browser's debugger/inspector will not match up to the line numbers in the source script directly. """ + # Don't use Proxy on this webkit version, the support isn't there. + use_proxy = not ( + objects.backend == usertypes.Backend.QtWebKit and + version.qWebKitVersion() == '602.1') template = jinja.js_environment.get_template('greasemonkey_wrapper.js') return template.render( scriptName=javascript.string_escape( "/".join([self.namespace or '', self.name])), scriptInfo=self._meta_json(), scriptMeta=javascript.string_escape(self.script_meta), - scriptSource=self._code) + scriptSource=self._code, + use_proxy=use_proxy) def _meta_json(self): return json.dumps({ |