Extend pakjoy to Qt 6.5.0/.1/.2 with dark mode

See #7837
This commit is contained in:
Florian Bruhin 2023-12-05 13:46:02 +01:00
parent b40e1861c3
commit 9d8c263e9a
3 changed files with 42 additions and 15 deletions

View File

@ -51,7 +51,8 @@ Fixed
- Compatibility with PDF.js v4
- Added an elaborate workaround for a bug in QtWebEngine 6.6.0 causing crashes
on Google Mail/Meet/Chat.
on Google Mail/Meet/Chat, and a bug in QtWebEngine 6.5.0/.1/.2 causing crashes
there with dark mode.
- Graphical glitches in Google sheets and PDF.js, again. Removed the version
restriction for the default application of
`qt.workarounds.disable_accelerated_2d_canvas` as the issue was still

View File

@ -32,11 +32,15 @@ import dataclasses
import contextlib
from typing import ClassVar, IO, Optional, Dict, Tuple, Iterator
from qutebrowser.config import config
from qutebrowser.misc import binparsing, objects
from qutebrowser.utils import qtutils, standarddir, version, utils, log
HANGOUTS_MARKER = b"// Extension ID: nkeimhogjdpnpccoofpliimaahmaaome"
HANGOUTS_ID = 36197 # as found by toofar
HANGOUTS_IDS = [
36197, # QtWebEngine 6.5, as found by toofar
34897, # QtWebEngine 6.4
]
PAK_VERSION = 5
RESOURCES_ENV_VAR = "QTWEBENGINE_RESOURCES_PATH"
DISABLE_ENV_VAR = "QUTE_DISABLE_PAKJOY"
@ -136,9 +140,10 @@ class PakParser:
def _find_manifest(self, entries: Dict[int, PakEntry]) -> Tuple[PakEntry, bytes]:
to_check = list(entries.values())
if HANGOUTS_ID in entries:
# Most likely candidate, based on previous known ID
to_check.insert(0, entries[HANGOUTS_ID])
for hangouts_id in HANGOUTS_IDS:
if hangouts_id in entries:
# Most likely candidate, based on previous known ID
to_check.insert(0, entries[hangouts_id])
for entry in to_check:
manifest = self._maybe_get_hangouts_manifest(entry)
@ -192,7 +197,16 @@ def copy_webengine_resources() -> Optional[pathlib.Path]:
shutil.rmtree(work_dir)
versions = version.qtwebengine_versions(avoid_init=True)
if versions.webengine != utils.VersionNumber(6, 6):
if not (
# https://bugreports.qt.io/browse/QTBUG-118157
versions.webengine == utils.VersionNumber(6, 6)
# https://bugreports.qt.io/browse/QTBUG-113369
or (
versions.webengine >= utils.VersionNumber(6, 5)
and versions.webengine < utils.VersionNumber(6, 5, 3)
and config.val.colors.webpage.darkmode.enabled
)
):
# No patching needed
return None

View File

@ -43,26 +43,38 @@ def prepare_env(qapp, monkeypatch):
monkeypatch.delenv(pakjoy.DISABLE_ENV_VAR, raising=False)
def patch_version(monkeypatch, *args):
def patch_version(monkeypatch: pytest.MonkeyPatch, qtwe_version: utils.VersionNumber):
monkeypatch.setattr(
pakjoy.version,
"qtwebengine_versions",
lambda **kwargs: version.WebEngineVersions(
webengine=utils.VersionNumber(*args),
webengine=qtwe_version,
chromium=None,
source="unittest",
),
)
@pytest.fixture
def unaffected_version(monkeypatch):
patch_version(monkeypatch, 6, 6, 1)
@pytest.fixture(params=[
utils.VersionNumber(6, 4),
utils.VersionNumber(6, 5, 3),
utils.VersionNumber(6, 6, 1),
utils.VersionNumber(6, 7),
])
def unaffected_version(monkeypatch: pytest.MonkeyPatch, request: pytest.FixtureRequest, config_stub):
config_stub.val.colors.webpage.darkmode.enabled = True
patch_version(monkeypatch, request.param)
@pytest.fixture
def affected_version(monkeypatch):
patch_version(monkeypatch, 6, 6)
@pytest.fixture(params=[
utils.VersionNumber(6, 5),
utils.VersionNumber(6, 5, 1),
utils.VersionNumber(6, 5, 2),
utils.VersionNumber(6, 6),
])
def affected_version(monkeypatch: pytest.MonkeyPatch, request: pytest.FixtureRequest, config_stub):
config_stub.val.colors.webpage.darkmode.enabled = True
patch_version(monkeypatch, request.param)
@pytest.mark.parametrize("workdir_exists", [True, False])
@ -318,7 +330,7 @@ class TestWithConstructedResourcesFile:
@pytest.mark.parametrize(
"offset",
[0, 42, pakjoy.HANGOUTS_ID], # test both slow search and fast path
[0, 42, *pakjoy.HANGOUTS_IDS], # test both slow search and fast path
)
def test_happy_path(self, offset):
entries = [b""] * offset + [json_manifest_factory()]