diff options
author | Florian Bruhin <me@the-compiler.org> | 2023-11-22 22:23:53 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2023-11-22 22:23:53 +0100 |
commit | bd865777368018774760f6fa81cf3b582104acda (patch) | |
tree | 21d1752f7eb897ec1bc4cae35c9a929a441b532d | |
parent | 4dab98a3be47865fdaf9fe692e510bb6aca1262f (diff) | |
download | qutebrowser-bd865777368018774760f6fa81cf3b582104acda.tar.gz qutebrowser-bd865777368018774760f6fa81cf3b582104acda.zip |
pakjoy: Add undocumented escape hatch
-rw-r--r-- | qutebrowser/misc/pakjoy.py | 5 | ||||
-rw-r--r-- | tests/unit/misc/test_pakjoy.py | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/qutebrowser/misc/pakjoy.py b/qutebrowser/misc/pakjoy.py index 6765c8687..b1e4b7884 100644 --- a/qutebrowser/misc/pakjoy.py +++ b/qutebrowser/misc/pakjoy.py @@ -38,6 +38,7 @@ HANGOUTS_MARKER = b"// Extension ID: nkeimhogjdpnpccoofpliimaahmaaome" HANGOUTS_ID = 36197 # as found by toofar PAK_VERSION = 5 RESOURCES_ENV_VAR = "QTWEBENGINE_RESOURCES_PATH" +DISABLE_ENV_VAR = "QUTE_DISABLE_PAKJOY" CACHE_DIR_NAME = "webengine_resources_pak_quirk" PAK_FILENAME = "qtwebengine_resources.pak" @@ -228,6 +229,10 @@ def _patch(file_to_patch: pathlib.Path) -> None: def patch_webengine() -> None: """Apply any patches to webengine resource pak files.""" + if os.environ.get(DISABLE_ENV_VAR): + log.misc.debug(f"Not applying quirk due to {DISABLE_ENV_VAR}") + return + try: # Still calling this on Qt != 6.6 so that the directory is cleaned up # when not needed anymore. diff --git a/tests/unit/misc/test_pakjoy.py b/tests/unit/misc/test_pakjoy.py index 55a147269..a889fcf49 100644 --- a/tests/unit/misc/test_pakjoy.py +++ b/tests/unit/misc/test_pakjoy.py @@ -39,6 +39,7 @@ skip_if_unsupported = pytest.mark.skipif( def prepare_env(qapp, monkeypatch): monkeypatch.setattr(pakjoy.objects, "qapp", qapp) monkeypatch.delenv(pakjoy.RESOURCES_ENV_VAR, raising=False) + monkeypatch.delenv(pakjoy.DISABLE_ENV_VAR, raising=False) def patch_version(monkeypatch, *args): @@ -77,6 +78,15 @@ def test_version_gate(cache_tmpdir, unaffected_version, mocker, workdir_exists): assert not workdir.exists() +def test_escape_hatch(affected_version, mocker, monkeypatch): + fake_open = mocker.patch("qutebrowser.misc.pakjoy.open") + monkeypatch.setenv(pakjoy.DISABLE_ENV_VAR, "1") + + pakjoy.patch_webengine() + + assert not fake_open.called + + class TestFindWebengineResources: @pytest.fixture def qt_data_path(self, monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path): |