Commit Graph

98 Commits

Author SHA1 Message Date
Florian Bruhin b0d3c8eee3 Greasemonkey: Make sure script names are unique
Fixes #6353
2021-06-11 19:14:14 +02:00
Florian Bruhin 62a8124f37 Fix quirk tests 2021-04-13 11:30:31 +02:00
Lembrun 880dd82be8 Changing path.open to read_text 2021-03-12 22:29:50 +01:00
Lembrun 59e0449471 Added blank line 2021-03-11 20:19:18 +01:00
Lembrun 148d5f25ef Created JS_DIR and moved str(css_path) 2021-03-11 20:13:34 +01:00
Lembrun c947488dd7 Changed joinpath to / 2021-03-11 08:36:57 +01:00
Lembrun 744cd94469 Removed unused import os in tests/unit/javascript 2021-03-10 10:49:21 +01:00
Lembrun 6aa6a9d0f5 Merge branch 'master' into pathlib-/unit/javascript 2021-03-09 22:46:25 +01:00
Florian Bruhin 0a38fff4c6 Simplify test_greasemonkey via js_tester fixture 2021-03-09 18:42:19 +01:00
Lembrun 260f91de56 Replaced os.path by the pathlib equivalent in unit/javascript folder 2021-03-03 15:35:40 +01:00
Lembrun e8b05af233 Qtbot methods changed to snake case,snake case check added 2021-02-26 22:07:08 +01:00
Florian Bruhin 1598425a05 Handle regex special chars in replaceAll polyfill
Fixes #6206
See #6047 and #6208
2021-02-24 21:32:53 +01:00
Florian Bruhin a9bcb39cd7 Add unit tests for JS quirks 2021-02-11 18:00:42 +01:00
Florian Bruhin 1a4fff1a42 doc: Switch URLs to https 2021-01-26 15:19:01 +01:00
Florian Bruhin 222f1f19a1 Bump copyright years
Closes #6015
2021-01-20 20:06:19 +01:00
Bryon Meinka 846825bb95 load scripts from config directory
fixes #5615
2020-11-29 17:12:45 -05:00
Florian Bruhin 05111e8423 old qt: Adjust greasemonkey support 2020-11-04 11:30:54 +01:00
Florian Bruhin a4d1b88348 tests: Don't set iframe.src in test_appendchild.js
The test file was taken from acid3, which does actually serve documents
for those locations.

For us, those documents never were available (as we're using `setHtml`
which uses a `data` URL internally), but the test does work just fine
without them. It was intended to test `appendChild` with different tags,
see the original commit (6c241f96ed) as
well as #2723 for details.

So far, them being there wasn't a problem, but with Qt 5.15.2 (or rather
the underlying Chromium 83), we get errors logged like this one:

    "Invalid relative frame source URL (xhtml.3) within data URL.", source:  (47)

So let's just not set them at all.

See #5752.
2020-10-13 18:05:25 +02:00
Florian Bruhin c99bf8ba32 tests: Retry setting JS HTML if loading timed out
Should hopefully help with flakiness on macOS...
See #5390
2020-07-28 20:40:29 +02:00
Florian Bruhin 4b9ddfb85b tests: Simplify some open() calls 2020-06-24 10:26:46 +02:00
Jordan Cannon 76d1c436a6 Add test for greasemonkey shared window proxy 2020-03-07 07:25:24 -06:00
Florian Bruhin 9e4276db9b Adjust copyrights for 2020 2020-01-04 18:21:17 +01:00
Florian Bruhin 7b87f6760f Split config.stylesheet into separate module
This avoids circular imports such as:
urlutils -> config -> jinja -> urlutils
2019-12-20 16:54:08 +01:00
Florian Bruhin 23061dbe10 tests: Change some marks from skipif to xfail 2019-11-19 16:20:40 +01:00
Florian Bruhin 22e1b22acc Remove unused import 2019-02-25 11:26:44 +01:00
Florian Bruhin 184e0ee44e Rename force_document_end to needs_document_end_workaround 2019-02-25 09:57:17 +01:00
Florian Bruhin 94542c5f78 Merge branch 'greasemonkey-quirks' 2019-02-25 09:56:18 +01:00
Florian Bruhin 8642b6e8ce Fix JSTester.run_file() for new pkg_resources
Read the file via open() instead of utils.read_file.
2019-02-25 09:28:25 +01:00
Florian Bruhin 0e11b85474 Re-enable stylesheet tests for Qt 5.12
This partially reverts commit 0953596ed6.
This reverts commit 0aa342eae6.
2019-02-25 09:28:25 +01:00
Florian Bruhin 6dd978ae05 GreaseMonkey: Force document-end for known-broken scripts
See #4322
2019-02-23 12:52:30 +01:00
Jay Kamat 3e816f5f8b
Update copyright for 2019 2019-02-22 21:45:08 -08:00
Florian Bruhin 0953596ed6 Skip remaining tests which are broken on Qt 5.12
See #4320, #4244
2018-12-11 18:36:52 +01:00
Florian Bruhin 0aa342eae6 Mark test_appendchild as xfail on Qt 5.12
See #4244
2018-12-11 11:05:06 +01:00
Florian Bruhin f6c36ccbee Rename openurl to load_url
We still call the :open command openurl, but in the tab API and in
TabbedBrowser it's now called load_url.
2018-11-30 08:31:03 +01:00
Florian Bruhin c225e724ac Merge remote-tracking branch 'origin/pr/4133' 2018-10-05 22:56:53 +02:00
Florian Bruhin 718376f154 Refactor JS escaping
This renames javascript.convert_js_arg() to javascript.to_js() and uses that
instead of string_escape() where possible.
2018-09-27 16:36:28 +02:00
Florian Bruhin 905863f74e Fix lint 2018-09-27 10:08:50 +02:00
Florian Bruhin 56b8447fb9 Use callback.assert_called_with() 2018-09-27 10:06:50 +02:00
Florian Bruhin a27a8ada4d Use qtbot.wait_callback 2018-09-26 11:45:45 +02:00
Jesko Dujmovic 25e396faea
Merge branch 'master' into master 2018-09-13 22:06:04 +02:00
Florian Bruhin f9327731b8 Handle UTF-8 byte order marks in Greasemonkey scripts
See e.g. https://github.com/jerone/UserScripts/issues/135
2018-09-12 23:54:32 +02:00
Jimmy 5252541fe3 greasemonkey: better handle scripts without metadata
Previously calling `script.code()` would fail if the script didn't have
a `name`. This wasn't being hit in practice because the only place that
constructs GreasemonkeyScripts was checking for that condition and add
the filename there as a fallback.

This change make the `name` attribute more explicitly mandatory by
failing with a `ValueError` if it is not provided and make it still
possible to use the filename fallback in that case by adding a
`filename` keyward argument to `__init__()`.

Additionally where `script_meta` is used in `script.code()` a fallback
to and emptry string was added so it doesn't fail for raw javascript
files without greasemonkey metadata.
2018-09-09 20:51:19 +12:00
Florian Bruhin c9fddfe458 Fix lint 2018-06-09 23:00:57 +02:00
Jimmy 6573a4d616 Tell pylint to shut its fat mouth.
I just want to return something I can refer to the attributes of via dot
syntax without having to pointlessly write the names both when I declare
the data class and when I assign the variables.

Such a stupid warning.
2018-05-20 18:42:40 +12:00
Jimmy b0d1a137da 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.
2018-05-20 18:42:40 +12:00
Jimmy 13249329f7 Greasemonkey: skip window scoping test on webkit
The implementation of Proxy in JSCore used by current QtWebkit (webkit
602.1) doesn't support the `set()` handler for whatever reason. So
instead of testing for a specific behaviour that we can't ensure on that
version let's just skip the tests and handle user complaints with
sympathy.
2018-05-20 18:42:40 +12:00
Jimmy c7a9792b67 Greasemonkey: Add test for window scoping refinements.
Adds a test to codify what I think greasemonkey scripts expect from
their scope chains. Particularly that they can:

1. access the global `window` object
2. access all of the attributes of the global window object as global
   objects themselves
3. see any changes the page made to the global scope
4. write to attributes of `window` and have those attributes, and changes
   to existing attributes, accessable via global scope
5. do number 4 without breaking the pages expectations, that is what
   `unsafeWindow` is for

There are some other points about greasemonkey scripts' environment that
I believe to be true but am not testing in this change:

* changes a page makes to `window` _after_ a greasemonkey script is
  injected will still be visible to the script if it cares to check and
  it hasn't already shadowed them
* said changes will not overwrite changes that the greasemonkey script
  has made.
2018-05-20 18:42:40 +12:00
Florian Bruhin 4932cc4d24 Merge remote-tracking branch 'origin/pr/3804' 2018-05-03 13:33:08 +02:00
Florian Bruhin d2207f66f1 Skip test_set_error entirely
See #3771
2018-04-16 17:14:14 +02:00
Jimmy c5334fb683 Greasemonkey: use UrlPatterns for match directives
The greasemonkey `@match` directive is used to match urls against
chromium url patterns (as opposed to `@include` which treats its
argument as a glob expression). I was using fnmatch for both here
because I am lazy and knew someone else was going to implement chromium
url patterns for me eventually. Now it is done and I should switch to
using them instead. The most common failing case that this will fix is
something matching on `*://*.domain.com/*` because it wouldn't match
the url with no subdomain.

This codepath is only used on webengine 5.7.1 and webkit backends.
2018-04-14 10:31:20 +12:00