Commit Graph

24265 Commits

Author SHA1 Message Date
toofar 8f89499cd5 Set up custom profile for webengine_tab fixture
Make sure webenginesettings.default_profile is set before creating a
webengine tab. The webengine_tab fixture is used in the web_tab and
tabbed_browser fixtures.

Previously when `WebEngineView.__init__()` ran default_profile was set
to None which was causing the tabs to be created pointing to the Qt
default profile. Which was working fine until I moved the common JS
scripts used for hint mode etc up to the profile, now they just weren't
getting run.

Unfortunately using a fully set up default profile was too tricky for
me. The stuff in webenginesettings around setting up the default profile
is written specifically for setting up global stuff when the real
application. Apart from init_profile() depending on a bunch of other
global singletons (more to set up) the user agent setting is hard to
work with. There is an assert in `_init_default_profile()` if the global
user agent string is already set. If you bypass the global user agent
string then websettings chokes on it not being set (websettings is
called from webenginesettings).

That's probably all possible to unpick, just need to go through the
codepaths noting down what the regiments for the application path are
and what needs to be operable for tests. We will probably make it a bit
better when moving more towards containers anyway.

Alternatively we could have a session/request scope autouse=True fixture
to set up all the real global stuff. That might be benefitial to make
the tests faster anyway. Going through the full profile setup stuff for
every test might make them a bit slower.

A couple of the caret tests are still failing. Not sure why.
2023-05-21 15:32:32 +12:00
toofar 025757a9c1 move JS_WORLD_MAP to usertypes, circular import 2023-04-30 15:12:46 +12:00
toofar acb58804c3 Move all qwebenginescript logic up to profile.
Qt had a regression relating to injecting scripts in 6.5. This only
applied to QWebEngineScripts in a page's collection, ones in a
profile's collection where fine. Since QWebEngineScripts learnt about
greasemonkey compatible metadata (a few years ago now) Qt manages when
scripts are injected and into what sites. So from that point of view all
we have to do is make sure scripts are registered with Qt when a profile
is initialised and then forget about them. So moving up to the profile
level fits that lifecycle better.

This is an initial, low effort, attempt at moving script registrations
to be up in the profile. Here's what I've done:

* move everything around QWebEngineScript out of webenginetab up to
  webenginesettings
    * injecting greasemonkey scripts
    * injecting site specific quirks (the site specific part is actually
      managed by greasemonkey metadata)
    * injecting global JS that is used on every page like hint, caret
      and stylesheet utility code
* move JS_WORLD_MAP up  to qtutils alongside MAX_WORLD_ID
    * this now introduces backend specific code into this module
* move greasemonkey initialisation to be earlier so the singleton
  manager exists when webenginesettings are initialized
    * I haven't looked at what dependancies the grasemonkey module has,
      if this causes issue we could split the greasemonkey
      initialization up (part one: create singleton, part two: read
      all scripts + fire reloaded signal)
* the profile level stylesheet is still overriden in the tab when a) a
  search is started or ended, to show/hide the scroll bar b) when the
  user stylesheets setting changes, so you don't have to reload the page

Moving everything up off of an object, in webenginetab, up to module
level function in webenginesettings meant removing a bunch of references
to "self" and using functools.partial to retain references to profiles
for signals. Subclassing QWebEngineProfile would probably help make that
stuff a little more robust, and would help us move towards having an
arbitrary number of profiles. But the only downside I can think of right
now is that signal connections wont get cleaned up when profiles are
deleted because they aren't connected to bound methods. But we aren't
currently deleting profiles (apart from at shutdown).

I left a couple of comments in around possible improvements. The
interface for the change_filter decorator surprised me a bit.

`_inject_greasemonkey_scripts()` might be able to be made smaller by
re-using the script factory. Or moving the world validation out.

Regarding the original regression in 6.5, regarding all the global
scripts like stylesheet, hint, caret etc. That issue can also be worked
around by injecting them twice (at document created and deferred). They
all have guards in the code so should be idempotent. That doesn't help
greasemonkey scripts though which are also affected.

I haven't tried running the tests :)

ref: #7662
2023-04-30 15:12:46 +12:00
Florian Bruhin 346a39ba14
Merge pull request #7674 from qutebrowser/update-dependencies
Update dependencies
2023-04-24 13:12:50 +02:00
qutebrowser bot 120e1efed5 Update dependencies 2023-04-24 04:24:26 +00:00
Florian Bruhin 059c6fdc75 Update docs 2023-04-22 22:45:50 +02:00
toofar caee222ceb
Merge pull request #7670 from qutebrowser/update-dependencies
Update dependencies
2023-04-22 16:36:56 +12:00
toofar d4cafc0019
Merge pull request #7672 from illfygli/master
Add `utm_name` to URL params that are stripped
2023-04-18 22:22:08 +12:00
ugla d568ce4c72
Add `utm_name` to URL params that are stripped 2023-04-18 11:24:41 +02:00
qutebrowser bot 88985aeaa0 Update dependencies 2023-04-17 04:21:54 +00:00
Florian Bruhin 5c7741a403
Merge pull request #7665 from qutebrowser/update-dependencies
Update dependencies
2023-04-14 21:34:18 +02:00
Florian Bruhin 06c5de554b ci: Decrease time limit again
Was due to https://github.com/pytest-dev/pytest/issues/10896
2023-04-14 21:04:12 +02:00
Florian Bruhin 49048489c3 Revert "pytest: Ignore Python 3.12 addDuration warning"
This reverts commit ee40046faf.
2023-04-14 21:02:47 +02:00
qutebrowser bot b169ace4d2 Update dependencies 2023-04-14 18:57:08 +00:00
Florian Bruhin ee40046faf pytest: Ignore Python 3.12 addDuration warning
See https://github.com/pytest-dev/pytest/issues/10875
2023-04-11 16:29:50 +02:00
Florian Bruhin e7295740ee tests: Fix broken mock assertions
Uncovered in Python 3.12
2023-04-11 15:29:41 +02:00
Florian Bruhin 5d890f14d0 tests: Handle Python 3.12 with NUL bytes config.py 2023-04-11 15:29:25 +02:00
Florian Bruhin 6e018fe2ab ci: Test a bigger sample of Python versions
- Make sure we still test Python 3.7 and 3.8 after dropping old PyQt
  versions in c5a51eb0bc
- Keep a modern Python version (3.11) with Qt 5 around, however
- Make sure we still test Python 3.10 too
- Also start testing the Python 3.12 alpha
2023-04-11 15:21:40 +02:00
Florian Bruhin 6f5de192e0 ci: Install libxcb-cursor
See https://codereview.qt-project.org/c/qt/qtbase/+/325414
2023-04-11 14:53:17 +02:00
Florian Bruhin 986348acb9 Revert "ci: Disable broken Qt 6.5"
This reverts commit 681f7ffc57.
2023-04-11 14:53:02 +02:00
Florian Bruhin 681f7ffc57 ci: Disable broken Qt 6.5
See #7624
2023-04-11 13:55:06 +02:00
Florian Bruhin 950d55002e ci: Raise time limit even more
Apparently Windows CI is real slow on GitHub currently...
2023-04-10 23:28:22 +02:00
Florian Bruhin 30e70803d0 ci: Add PyQt 6.5
See #7624
2023-04-10 23:25:15 +02:00
Florian Bruhin 39b6a1e946 ci: Properly raise time limits
CodeQL only needs about 7 minutes, but Windows needs >45
2023-04-10 22:20:19 +02:00
Florian Bruhin 764dbfd008
Merge pull request #7660 from qutebrowser/dependabot/github_actions/peter-evans/create-pull-request-5
build(deps): bump peter-evans/create-pull-request from 4 to 5
2023-04-10 21:09:18 +02:00
Florian Bruhin f6f29692e4 Revert "Ignore pylint invalid-name false-positives"
This reverts commit 485f1c5fbc.
2023-04-10 21:07:57 +02:00
Florian Bruhin 98f25a6dbb
Merge pull request #7655 from qutebrowser/update-dependencies
Update dependencies
2023-04-10 21:07:18 +02:00
Florian Bruhin 055224cb8d ci: Bump tests timeout once again
Looks like 45mins is too tight for GHA on Windows with heavy load...
2023-04-10 21:05:53 +02:00
dependabot[bot] 106a71f314
build(deps): bump peter-evans/create-pull-request from 4 to 5
Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 4 to 5.
- [Release notes](https://github.com/peter-evans/create-pull-request/releases)
- [Commits](https://github.com/peter-evans/create-pull-request/compare/v4...v5)

---
updated-dependencies:
- dependency-name: peter-evans/create-pull-request
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-10 19:01:49 +00:00
qutebrowser bot 734ff1c176 Update dependencies 2023-04-10 04:21:37 +00:00
Florian Bruhin 3e4d021070 tests: Fix relative URL for caret test
Similar issue as with ab7245732e
2023-04-07 15:45:20 +02:00
Florian Bruhin 3e4833da6e Update chromium version info 2023-04-07 15:36:03 +02:00
Florian Bruhin 54026a3217 tests: Ignore another Qt 6.5 debug message
See https://github.com/qutebrowser/qutebrowser/issues/7624
2023-04-06 22:55:53 +02:00
Florian Bruhin 04dad0c789
Merge pull request #7640 from qutebrowser/update-dependencies
Update dependencies
2023-04-04 08:33:38 +02:00
Florian Bruhin 72c38a8e19 tests: Remove old pytest-instafail/hypothesis filterwarnings 2023-04-03 08:22:45 +02:00
qutebrowser bot 9ff100f0d5 Update dependencies 2023-04-03 04:24:13 +00:00
Florian Bruhin fd4217ffd2 tests: Make download error more forgiving
For unknown reasons, on nightly CI we now get TWO errors:

<qutebrowser.browser.webkit.certificateerror.CertificateErrorWrapper errors=['NoPeerCertificate', 'SelfSignedCertificate'] string='The peer did not present any certificate\nThe certificate is self-signed, and untrusted'>
2023-03-29 15:15:11 +02:00
Florian Bruhin 293a993b6b build_release: Also ignore GpuChannelMsg_CreateCommandBuffer for Qt 5
Looks like we have some failing smoke tests with:

[6636:16643:0329/041427.206197:ERROR:command_buffer_proxy_impl.cc(141)] ContextResult::kTransientFailure: Failed to send GpuChannelMsg_CreateCommandBuffer.
2023-03-29 10:28:30 +02:00
toofar c5803587c1 tests: Add text content to another HTML file
I saw this test fail on windows at some point with what looked like the
same issue. (Couldn't find an element to click.)

ref; #7621
2023-03-25 18:38:27 +13:00
toofar cb0b51c094 tests: wait for flaky iframes to load via JS
TL;DR: I think I stabilized a couple of hinting iframe tests and applied
that change to all the iframe usages in the end2end tests in the hopes
that it would resolve some other flaky tests.

I was facing some tests that hinted elements in iframes failing
intermittently recently. They were most consistently failing on the
windows runner. This is similar to the trend described in the comment
linked from #1525.

The tests failing recently where:

    tests (py39-pyqt515, windows-2019, 3.9)
    test_using_hintfollow_inside_an_iframe
    test_using_hintfollow_inside_an_iframe_button

    tests (py311-pyqt515, ubuntu-20.04, 3.11)
    test_using_hintfollow_inside_an_iframe
    test_using_hintfollow_inside_an_iframe_button

They are failing because hints don't get generated for the elements in
the iframe. I can see hints do get generated for the iframe itself
though.
Examining the logs in 5.15 it seems that there is a
`cur_load_finished(True) (tab *)` log line after we run :hint. I suspect
that this is the load finished signal for the iframe.
I attempted to change the bdd open_path function to wait for the current
message it's looking for and then additionally look for that
cur_load_finished signal, but then it starts failing locally when the
iframe load signal actually comes before the parent frame one. Just
looking for the cur_load_finished signal itself also always found it
immediately ("already found"), probably from the parent frame.

So instead of trying to deal with that indeterminate ordering or
trying to change the signals to say what frame they are coming from, I
added javascript to all the pages used in iframes that run on load, and
changed all the tests to watch for log messages from the JS.

It's not the most maintainable solution, perhaps if we generated our
test files with jinja we could have some "subframe loaded" boilerplate,
get a message to log from a query param, look at metadata from test
files for the open_path checking etc.

I then searched for all the iframe usages in the test data and applied
that change to all of those files and all the tests that used them. A
few of those tests also had `flaky` annotations on them. I removed those
annotations for now in the hopes that there were affected by the same
problem. And that I actually managed to work around it correctly.

ref: #7621
2023-03-25 18:37:58 +13:00
Florian Bruhin e03b81cb35 doc: Add more changelog entries for Qt 6 stuff 2023-03-24 12:56:27 +01:00
Florian Bruhin 41ebbc0d73 scripts: Fix indent 2023-03-23 22:17:17 +01:00
Florian Bruhin dabd8ede86 scripts: Use proper Qt version for smoke test
See https://github.com/qutebrowser/qutebrowser/issues/7202#issuecomment-1481877459
2023-03-23 22:01:48 +01:00
Florian Bruhin fe6687f2ea tests: Stabilize "Hinting an input after undoing a tab close"
Without this wait, the test is flaky, because sometimes the keys are pressed
before qutebrowser has entered insert mode.

When running:

    tox -e py311-pyqt64 -- tests/end2end/features/test_hints_bdd.py -k undoing --count 100

around 30% of the runs, we get:

============================== :click-element id qute-input-existing ==============================

[...]

----> Waiting for 'command called: *' in the log
[...]
17:56:54.042 DEBUG    commands   command:run:549 Calling qutebrowser.components.misccommands.click_element(<qutebrowser.browser.webengine.webenginetab.WebEngineTab tab_id=197 url='http://localhost:50977/data/hints/link_input.html'>, 'id', 'qute-input-existing', target=<ClickTarget.normal: 1>, force_event=False, select_first=False)
17:56:54.043 DEBUG    ipc        ipc:_get_socket:373 In _get_socket with None socket!
----> found it

============================== :fake-key -g something ==============================

[...]

----> Waiting for '[*] contents: existingsomething' in the log
17:56:54.062 DEBUG    modes      modeman:_handle_keypress:290 got keypress in mode KeyMode.normal - delegating to <qutebrowser.keyinput.modeparsers.NormalKeyParser>
[...]
17:56:54.111 DEBUG    modes      modeman:_handle_keypress:290 got keypress in mode KeyMode.normal - delegating to <qutebrowser.keyinput.modeparsers.NormalKeyParser>
[...]
17:56:54.112 DEBUG    modes      modeman:_handle_keypress:290 got keypress in mode KeyMode.normal - delegating to <qutebrowser.keyinput.modeparsers.NormalKeyParser>
[...]
17:56:54.113 DEBUG    commands   command:run:535 command called: quickmark-save
[...]
17:56:54.143 DEBUG    webview    webenginetab:_js_cb_single:766 Got element from JS: {'attributes': {'id': 'qute-input-existing', 'value': 'existing'}, 'caret_position': 0, 'class_name': '', 'id': 0, 'is_content_editable': False, 'outer_xml': '<input id="qute-input-existing" value="existing">', 'rects': [{'bottom': 143, 'height': 21, 'left': 8, 'right': 166, 'top': 122, 'width': 158}], 'tag_name': 'INPUT', 'text': '', 'value': 'existing'}
17:56:54.143 DEBUG    webelem    webelem:click:422 Clicking <qutebrowser.browser.webengine.webengineelem.WebEngineElement html='<input id="qute-input-existing" value="existing">'> with click_target ClickTarget.normal, force_event False
17:56:54.143 DEBUG    webelem    webelem:is_editable:257 Checking if element is editable: <qutebrowser.browser.webengine.webengineelem.WebEngineElement html='<input id="qute-input-existing" value="existing">'>
17:56:54.143 DEBUG    webelem    webelem:click:434 Clicking via JS focus()
17:56:54.144 DEBUG    webelem    webelem:is_editable:257 Checking if element is editable: <qutebrowser.browser.webengine.webengineelem.WebEngineElement html='<input id="qute-input-existing" value="existing">'>
17:56:54.144 DEBUG    modes      modeman:enter:366 Entering mode KeyMode.insert (reason: clicking input)

With the change, the test passes 100/100 times.
2023-03-23 18:10:22 +01:00
Florian Bruhin 7c222c5b19 Merge branch 'update-dependencies' 2023-03-23 17:34:39 +01:00
Florian Bruhin dbc7871b47 Update changelog URLs 2023-03-23 17:32:39 +01:00
Florian Bruhin 55a72095cd mypy: Update to new ignore name 2023-03-23 17:32:39 +01:00
Florian Bruhin 485f1c5fbc Ignore pylint invalid-name false-positives
See https://github.com/PyCQA/pylint/issues/8487
2023-03-23 17:32:39 +01:00
Florian Bruhin 0510ffcfa9 tests: Remove before_first_request for webserver_sub_ssl
This was first introduced in adbdfcbad3,
most likely because we got logging from the built-in Werkzeug webserver.

It doesn't seem to be needed anymore, possibly since
41c4ee3e2f where we started using CherryPy
for the SSL server too.

This should fix nighly bleeding tests, because the before_first_request
decorator got removed in Flask:

https://github.com/pallets/flask/pull/4621
https://github.com/pallets/flask/pull/4995
2023-03-20 17:23:55 +01:00
Florian Bruhin e16eebc975 docs: Add Matrix theme
See https://www.reddit.com/r/qutebrowser/comments/11w1agq/matrix_theme/
2023-03-20 17:08:20 +01:00