Commit Graph

14374 Commits

Author SHA1 Message Date
Florian Bruhin
26edf55f85 Update install instructions for Fedora/OpenBSD 2017-11-28 17:56:17 +01:00
Florian Bruhin
3857491cf9 Make sure docs are up-to-date for navigate.feature 2017-11-28 17:06:41 +01:00
Florian Bruhin
ca74991900 Read backend after args.temp_settings
This should hopefully not affect any config change handlers, as almost nothing
is registered this early.

Fixes #3340
2017-11-28 17:00:45 +01:00
Ryan Roden-Corrent
01a9405391 Make ophaned editor test less flaky.
Instead of having the editor sleep a short time, explicitly send it a
signal to exit.
2017-11-28 08:38:04 -05:00
Ryan Roden-Corrent
9dfc6b0f61 Change wording for orphaned editor.
The term "vanished" is used elsewhere.
2017-11-28 08:37:38 -05:00
Ryan Roden-Corrent
b6dcd4d387 Reapply "Hide quickmark/bookmark completion if empty."
This reverts commit e72e8b8556.

Now that the SQL category works in isolation, it is possible to hide
quickmarks/bookmarks when those categories are empty.

Fixes #960
2017-11-28 07:21:26 -05:00
Florian Bruhin
b407f4ab41 Release v1.0.4 2017-11-28 10:56:15 +01:00
Florian Bruhin
9a8d68aa25 Mark :undo test as flaky
I don't get why it fails sometimes - so another @flaky stop-gap for now.
2017-11-28 09:19:37 +01:00
Florian Bruhin
93bdff5d40 Merge remote-tracking branch 'origin/pr/3330' 2017-11-28 08:29:17 +01:00
Florian Bruhin
56759cca6b Make more unit tests run with Qt 5.7.1 on a newer Linux 2017-11-28 08:16:07 +01:00
Florian Bruhin
0850aab96f Merge remote-tracking branch 'origin/pr/3337' 2017-11-28 07:58:42 +01:00
Florian Bruhin
1d17e7ab03 Update changelog 2017-11-28 07:04:57 +01:00
Florian Bruhin
ef1825efb0 Handle sqlite errors during :history-clear 2017-11-28 07:02:33 +01:00
Florian Bruhin
73587b1e16 Add SQLITE_CORRUPT to environmental SQL errors 2017-11-28 06:55:55 +01:00
Florian Bruhin
4fed8518e1 Handle "out of memory" error in sql.init() 2017-11-28 06:53:41 +01:00
Florian Bruhin
814a88b741 Add nEXT to list of alternatives
[ci skip]
2017-11-28 06:24:45 +01:00
Ryan Roden-Corrent
40e4e73e36 Ensure HistoryCategory works in isolation.
While QSortFilterProxyModel emits layoutChanged when changing the
pattern, QSqlQueryModel emits modelReset. As only layoutChanged was
connected, a HistoryCategory would only work in a model that also had at
least one ListCategory.

The simplest solution is to have the parent model emit the signal
directly. This also emits a single signal on a pattern change rather
that one for each child model.

Resolves #3016.
2017-11-27 11:49:32 -05:00
pyup-bot
9a8bac18ae Update pluggy from 0.5.2 to 0.6.0 2017-11-27 16:02:24 +01:00
pyup-bot
b820b9d530 Update pytest-qt from 2.2.1 to 2.3.0 2017-11-27 16:02:22 +01:00
pyup-bot
5f30016901 Update hypothesis from 3.38.0 to 3.38.5 2017-11-27 16:02:21 +01:00
pyup-bot
54db781b97 Update hunter from 2.0.1 to 2.0.2 2017-11-27 16:02:20 +01:00
pyup-bot
5df2025745 Update cheroot from 5.9.1 to 5.10.0 2017-11-27 16:02:18 +01:00
pyup-bot
6c47b5d2d7 Update setuptools from 36.8.0 to 38.2.1 2017-11-27 16:02:17 +01:00
pyup-bot
a4b96c3443 Update check-manifest from 0.35 to 0.36 2017-11-27 16:02:15 +01:00
Jimmy
0381d74e9a Greasemonkey: privatise some utility functions 2017-11-27 20:10:38 +13:00
Florian Bruhin
0e80be2d30 Clear end2end test data again after initializing
If we don't do this, earlier tests can affect later ones when e.g. using "...
should not be logged", as we don't really wait until a test has been fully
finished.
2017-11-27 20:10:38 +13:00
Florian Bruhin
db353c4030 Connect the page signal for GreaseMonkey
Looks like we don't get the mainFrame's loadFinished signal properly.
2017-11-27 20:10:38 +13:00
Florian Bruhin
6933bc05b4 Add some debug logging for GreaseMonkey with QtWebKit 2017-11-27 20:10:38 +13:00
Jimmy
df624944f9 Greasemonkey: webkit: injected all scripts on loadFinished.
The signal we were using to inject greasemonkey scripts registered to
run at document-start (javaScriptWindowObjectCleared) was unreliable to
non-existant. The initialLayoutCompleted signal is a bit of an odd duck
too I suppose. Anyway, we don't anticipate any scripts would break from
being injected when the page is finished loaded that wouldn't already
have been flaky due to the complexities of the modern web. If there is
an issue hopefully someone raises an issue and we can look into it.
2017-11-27 20:10:38 +13:00
Jimmy
8a5b42ffbd Greasemonkey: es6ify the greasemonkey wrapper js.
Because backwards compatibility sucks I guess.
2017-11-27 20:10:38 +13:00
Jimmy
92b48e77c7 Greasemonkey: add unit tests for GreasemonkeyManager 2017-11-27 20:10:38 +13:00
Jimmy
dd59f8d724 Greasemonkey: add more end2end tests
Test document-end and noframes. Because coverage.py told me to.
Hopefully this doesn't slow the test run down too much, particularly the
"should not be logged" bit.

I'm just reusing and existing test html page that used an iframe because
I'm lazy.
2017-11-27 20:10:38 +13:00
Jimmy
361a1ed6e4 Greasemonkey: change PROPS_REGEX to handle non-value keys.
We weren't actually picking up the @noframes greasemonkey directive
because of this. I haven't tested this very extensively but it seems to
work for making the property value optional.
2017-11-27 19:27:31 +13:00
Jimmy
9aeb5775c1 greasemonkey: run scripts on subframes on webkit
Use the `QWebPage.frameCreated` signal to get notifications of subframes
and connect the javascript injection triggering signals on those frames
too.

I had to add a `url = url() or requestedUrl()` bit in there because the
inject_userjs method was getting called to early or something when
frame.url() wasn't set or was set to the previous page so we were
passing the wrong url to greasemonkey.scripts_for().

I ran into a bizarre (I maybe it is completely obvious and I just don't
see it) issue where the signals attached to the main frame that were
connected to a partial function with the main frame as an argument were
not getting emitted, or at least those partial functions were not being
called. I worked around it by using None to mean defaulting to the main
frame in a couple of places.
2017-11-27 19:27:31 +13:00
Jimmy
4c3461038d Greasemonkey: add minimal end-to-end test.
Just runs a greasemonkey script on a test page and uses console.log to
ensure it is running.

Tests @include, and basic happy path greasemonkey.py operation (loading
and parsing script, scrip_for on webkit), only testing document-start
injecting point but that is the troublsome one at this point.

Tested on py35 debian unstable (oldwebkit and qtwebengine5.9) debian
stable qtwebengine5.7.

Note the extra :reload call for qt5.7 because document-start scripts
don't seem to run on the first page load with the current insertion
point. I need to look into this more to look at ways of fixing this.
2017-11-27 19:27:31 +13:00
Jimmy
7c497427ce Greasemonkey: various javascript fixups to GM wrapper template.
Thanks to @sandrosc. A few breaking changes fixed (default method to
GM_xhr not working, GM_listvalues not cleaning up output, GM_setvalue
param checking logic wrong) and a few hygenic changes made.
2017-11-27 19:27:31 +13:00
Jimmy
c0832eb04b Greasemonkey: support @nosubframes.
And run on frames by default. At least on webengine. There is probably
some api to enumerate frames on a webkit page.

Not tested.
2017-11-27 19:27:31 +13:00
Jimmy
fb019b2dab Address second round line comments.
Add qute version to GM_info object in GM wrapper.
Support using the greasemonkey @namespace metadata for its intended
purpose of avoiding name collisions.
Get a nice utf8 encoded string from a QUrl more better.
2017-11-27 19:27:31 +13:00
Jimmy
efde31aa57 Greasemonkey: Support QTWebEngine versions < 5.8
QTWebEngine 5.8 added support for parsing greasemonkey metadata blocks
and scripts added to the QWebEngineScriptCollection of a page or its
profile and then deciding what urls to run those scripts on and at what
point in the load process to run them. For earlier versions we must do
that work ourselves. But with the additional handicap of the less rich
qtwebengine api.

We have acceptNavigationRequest, loadStarted, loadProgress,
loadFinished, urlChanged to choose from regarding points at which to
register scripts for the current page.

Adding scripts on acceptNavigation loadStarted and loadFinished causes
scripts to run too early or too late (eg on the pages being navigated
from/to) and not run on the desired page at the time they are inserted.
We could maybe do some more sophisticated stuff with loadProgress but it
didn't have any better behaviour in the brief testing I gave it.
Registering scripts on the urlChanged event seems to work fine. Even if
it seems like there could be problems with the signal firing too often,
due to not necessarily being tied to the page load progress, that
doesn't seem to have an effect in practice. The event is fired when, for
example, the url fragment changes and even if we add a new script to the
collection (or remove an existing one) it doesn't have an effect on what
is running on the page.

I suspect all of those timing issues is due to the signals being
forwarded fairly directly from the underlying chomium/blink code but the
webengine script stuff only being pushed back to the implementation on
certain events.

Anyway, using urlChanged seems to work fine due to some quirk(s) of the
implementation. That might change with later development but this
codepath is only ever going to be used for version 5.7.

There are other potential optimizations like not removing and then
re-adding scripts for the current page. But they probably wouldn't do
anything anyway, or at least anything that you would expect.
2017-11-27 19:27:31 +13:00
Jimmy
209e43e0ba Greasemonkey: Match against percent encoded urls only.
This change requires urls specified in @include, @exclude and @matches
directives in metadata blocks to be in the same form that
QUrl.toEncoded() returns. That is a punycoded domain and percent encoded
path and query. This seems to be what Tampermonkey on chrome expects to.

Also changes the scripts_for() function to take a QUrl arg so the caller
doesn't need to worry about encodings.
2017-11-27 19:27:31 +13:00
Jimmy
d318178567 Greasemonkey: Fix metadata block regex.
This regex was broken since the original PR and subsequent code seemed to be
working around it. Before re.split was returning [everything up to
/UserScript, everything else], now it returns [before UserScript, metadata,
after /UserScript], which is good.

Also I added the check for the UserScript line starting at column 0 as per
spec.
2017-11-27 19:27:31 +13:00
Jimmy
5e49e7eef2 Greasemonkey: Throw Errors if GM_ function args wrong type.
These argument type restrictions are mentioned on the greasespot pages for
these value storage functions. We could call JSON.dumps() instead but better
to push that onto the caller so we don't have to try handle deserialization.

Also removes the check for localstorage because everyone has supported that
for years.
2017-11-27 19:27:31 +13:00
Jimmy
d93c583c0d Greasemonkey: Escape jinja variables for JS strings. 2017-11-27 19:27:31 +13:00
Jimmy
a7f41b4564 Greasemonkey: ensure only GM scripts are cleaned up on reload.
WebEngine only. Previously we were just removing every script from the
main world. But some other scripts might got here in the future so new
we are overriding the name field to add a GM- prefix so hopefully we
only remove greasemonkey scripts before adding new ones.
2017-11-27 19:27:31 +13:00
Jimmy
fd5d44182b Greasemonkey: move GM_* template into seperate file.
Also ported it to jinja rather than str.format().

Also ran the js through jslint and fixed up a few very minor things.
2017-11-27 19:27:31 +13:00
Jimmy
c1b912f567 Greasemonkey: move inject_userscripts into webenginesettings 2017-11-27 19:27:31 +13:00
Jimmy
edf737ff7d Greasemonkey: move scripts for a domain into data class.
Also makes scripts that don't include a greasemonkey metadata block
match any url. QWebEngine already has that behaviour.
2017-11-27 19:27:31 +13:00
Jimmy
41035cb5ca Greasemonkey: restrict page schemes that scripts can run on
Scripts shouldn't run on qute://settings or source:// etc.

Whitelist from:
https://wiki.greasespot.net/Include_and_exclude_rules
2017-11-27 19:27:31 +13:00
Jimmy
799730f686 Remove GM_ and userscript variables from global scope. 2017-11-27 19:27:31 +13:00
Jimmy
325c595b89 Greasemonkey: Don't strip gm metadata from scripts when loading.
Since we just pass them to webenginescriptcollection on that backend and
that wants to parse it itself to figure out injection point etc.
2017-11-27 19:27:31 +13:00