Commit Graph

16066 Commits

Author SHA1 Message Date
Jimmy
c43d173197 greasemonkey: s/userscripts/greasemonkey_scripts/
No need to confuse developers as well as users.
2018-06-26 16:42:31 +12:00
Jimmy
ee2c765859 greasemonkey: check _widget is not deleted
Just for good luck.

No crash has been reported here but it is a common pattern for functions
called from signals.
2018-06-26 16:42:31 +12:00
Jimmy
6f1232e621 greasemonkey: move 5.7.1 injection method into _WebEngineScripts
Moves the 5.8 check to `_WebEngineScripts.init()`.

Changes `_inject_userscripts` to allow for the two code paths. With
5.7.1 we need to specify the injection point and not clear all scripts
for each call, since we have to call it three times.

Change the 5.8+ hook to call a new method which passes all the scripts
into `_inject_userscripts` so that doesn't have to have a fallback
conditional inside it because thats an inversion of responsibility!

Pulling the remove scripts part into a seperate function and making it
the callers responsibilty to call that first would tidy it up a little
more but meh.

I was worried about just doing `_widget.page().urlChanged.connect()`
once at tab init, where before it was connected at page init, because I
was under the impression that the child page can be replaced at any
time, eg when navigating to a new origin. But under manual testing I
didn't see that at all. Maybe I was mistaken or maybe that only started
in a later Qt version.
2018-06-26 16:42:31 +12:00
Jimmy
324966cfe7 greasemonkey: also support qute-js-world on 5.7.1
A straight copy from webengintab.

Yes I know I shouldn't be importing a private thing from webenginetab,
I'm working on refactoring now.
2018-06-26 15:00:35 +12:00
Jimmy
521268a1f7 Update comment. 2018-06-26 15:00:35 +12:00
Jimmy
54ca9b34e5 greasemonkey: enable running in isolated js worlds
QtWebEngine (via chromium) has the ability to run injected scripts in
isolated "worlds". What is isolated is just the javascript environment,
so variables and functions defined by the page and the script won't
clobber each other, or be able to interact (including variables saved to
the global `window` object). The DOM is still accessible from "isolated"
scripts.

This is NOT a security measure. You cannot put untrusted scripts in one
of these isolated worlds and expect it to not be able to do whatever
page js can do, it is just for namespacing convenience. See
https://stackoverflow.com/questions/9515704/insert-code-into-the-page-context-using-a-content-script
for some examples of how to inject scripts into the page scope using DOM
elements.

Now you can specify the world ID in a `@qute-js-world` directive like:

```
// ==UserScript==
// @name         Do thing
// @match        *://some.site/*
// @qute-js-world 1234
// ==/UserScript==
document.body.innerHTML = "<strong>overwritten</strong>"
```

The QtWebEngine docs say worldid is a `quint32` so you can put whatever
number (positive, whole, real) you want there. I have chosen to allow
the `qutebrowser.utils.usertypes` enum as aliases for IDs that are
predefined in
`qutebrowser.browser.webengine.webenginetab._JS_WORLD_MAP`. So you can
pass `main`, `application`, `user` or `jseval` in there too. `main` (0)
is the default one and is the only one in which JS disabled when
`content.javascript.enabled` is set to `false`. All others are still
enabled.

I'm not sure whether using any of those already-named worlds makes
sense, apart from `main`. We could stop people from using them I
suppose. Another option is to allow people to pass in `*` as a value to
have scripts put into their own little worlds, probably backed by a
counter in the GreaseMonkeyManager class.

Chrome docs: https://developer.chrome.com/extensions/content_scripts#execution-environment
Webengine docs: https://doc.qt.io/qt-5/qwebenginescript.html#details
2018-06-26 15:00:35 +12:00
Florian Bruhin
1bc3d444b6 Stabilize escaping URLs test 2018-06-25 23:02:50 +02:00
Florian Bruhin
876aa5a9b1 Fix lint 2018-06-25 22:51:55 +02:00
Florian Bruhin
87778277e0 Fix SSL error page tests 2018-06-25 22:51:48 +02:00
Florian Bruhin
81b3ef937e Move handling of certificate errors to webenginetab 2018-06-25 21:04:32 +02:00
Florian Bruhin
8a4bba11ed Disable certificate workaround on Qt >= 5.9
Fixes #4020
2018-06-25 20:35:48 +02:00
Florian Bruhin
3f923b41e0 Revert "Update pyqt5 from 5.10.1 to 5.11.1"
This reverts commit 1f19db0785.
2018-06-25 20:08:50 +02:00
Florian Bruhin
158ccd7d54 Revert "Update pyqt5 from 5.10 to 5.11.1"
This reverts commit e1bc5389a2.
2018-06-25 20:08:42 +02:00
Florian Bruhin
228ca732d5 Merge remote-tracking branch 'origin/pyup-scheduled-update-2018-06-25' 2018-06-25 20:08:24 +02:00
pyup-bot
b3790f7a7e Update pytest from 3.6.1 to 3.6.2 2018-06-25 19:21:17 +02:00
pyup-bot
d6554a131e Update hypothesis from 3.59.1 to 3.61.0 2018-06-25 19:21:15 +02:00
pyup-bot
1f19db0785 Update pyqt5 from 5.10.1 to 5.11.1 2018-06-25 19:21:14 +02:00
pyup-bot
e1bc5389a2 Update pyqt5 from 5.10 to 5.11.1 2018-06-25 19:21:12 +02:00
Florian Bruhin
6c9e23af4a eslint: Turn off max-lines-per-function 2018-06-25 08:14:02 +02:00
Florian Bruhin
13f765a000 Fix changelog formatting 2018-06-24 22:33:46 +02:00
Florian Bruhin
fc19262eaa Fix test_shared.py 2018-06-24 22:31:27 +02:00
Florian Bruhin
f2f481d991 Support URL patterns for permissions and ssl_strict
See #3636
2018-06-24 21:38:37 +02:00
Florian Bruhin
f5e69b2174 Show inspector after creating it 2018-06-24 19:57:52 +02:00
Florian Bruhin
e6e844b039 Support URL patterns for content.headers settings
See #3636
2018-06-24 19:54:24 +02:00
Florian Bruhin
a02c25dfb1 Don't escape URLs for qute://history
We only use the URL to set a 'href' attribute, which does not need escaping.

See #4011
Fixes #4012
2018-06-23 14:27:07 +02:00
Florian Bruhin
d2254ca48b Release v1.3.3
(cherry picked from commit ad9b50601c82f66646088e9ebdd66613eb2e93e2)
2018-06-21 23:32:56 +02:00
Florian Bruhin
66fc3a30dd Update changelog 2018-06-21 23:30:27 +02:00
Florian Bruhin
0864ad4069 Fix shadowing of 'html' name 2018-06-21 22:28:27 +02:00
Florian Bruhin
9a5439e5d0 Re-add waiting for QQuickWidget
Apparently this is still needed on some PyQt versions.
2018-06-21 22:22:04 +02:00
Florian Bruhin
7a7e04a054 Move fix to v1.3.3 in changelog 2018-06-21 21:42:44 +02:00
Florian Bruhin
d961eab1d2 Update changelog for v1.3.3 2018-06-21 21:42:08 +02:00
Florian Bruhin
5a7869f2fe Fix XSS issue on qute://history
Fixes #4011
2018-06-21 21:20:19 +02:00
Florian Bruhin
62d8b5b574 Don't depend on PyQt5.QtQuickWidgets to get RWHV
Some distributions (at least FreeBSD) don't package that module, so let's not
rely on it.
2018-06-21 17:14:29 +02:00
Florian Bruhin
c87757a913 Revert "Properly add QtQuickWidgets dependency"
Looks like FreeBSD doesn't have QtQuickWidgets packaged at all, so let's do the
same without requiring it...

This reverts commit e5405f0ae9.
2018-06-21 16:35:29 +02:00
Florian Bruhin
9f5ca475c9 Don't try to set focus if prev_focus is None 2018-06-21 01:44:15 +02:00
Florian Bruhin
e7a300865c Fix lint 2018-06-21 01:43:09 +02:00
Florian Bruhin
4887385bdd Fix test_dictionary_dir 2018-06-21 01:40:36 +02:00
Florian Bruhin
1000a1eac2 Merge remote-tracking branch 'origin/pr/4005' 2018-06-21 01:01:27 +02:00
Florian Bruhin
e5405f0ae9 Properly add QtQuickWidgets dependency 2018-06-21 00:21:52 +02:00
pyup-bot
a73a778b9d Update pytest-qt from 2.4.0 to 2.4.1 2018-06-18 19:11:20 +02:00
pyup-bot
7c4eaa80b0 Update hypothesis from 3.57.0 to 3.59.1 2018-06-18 19:11:19 +02:00
pyup-bot
c3b76d1d01 Update cheroot from 6.3.1 to 6.3.2 2018-06-18 19:11:17 +02:00
pyup-bot
fa0e8c1b51 Update requests from 2.18.4 to 2.19.1 2018-06-18 19:11:16 +02:00
pyup-bot
da8f76d082 Update requests from 2.18.4 to 2.19.1 2018-06-18 19:11:14 +02:00
pyup-bot
91c0aae05b Update requests from 2.18.4 to 2.19.1 2018-06-18 19:11:13 +02:00
Florian Bruhin
3399f2df96 Always clear searches between page loads
Looks like this wasn't properly fixed in Qt for some reason.
Fixes #3693
See #2728 and bef372e5f5
2018-06-17 21:03:44 +02:00
Florian Bruhin
2029f52fdc Show cause when ~/.netrc can't be read 2018-06-17 20:53:29 +02:00
Florian Bruhin
663d1a4d2f Read dictionaries from /usr/share/qt on Qt >= 5.10
Fixes #3759
Supersedes #3762
See #2939, #4003
2018-06-17 20:27:52 +02:00
Florian Bruhin
7b7e0c93f5 Update Chromium version in changelog 2018-06-16 11:54:53 +02:00
Florian Bruhin
e2ef39e872 Add Comment to .desktop file 2018-06-14 23:29:16 +02:00