Add more hardcoded IDs and tests

This commit is contained in:
Florian Bruhin 2024-07-12 15:28:38 +02:00
parent d9b9349656
commit bcf792a0dc
2 changed files with 19 additions and 14 deletions

View File

@ -38,8 +38,12 @@ from qutebrowser.utils import qtutils, standarddir, version, utils, log
HANGOUTS_MARKER = b"// Extension ID: nkeimhogjdpnpccoofpliimaahmaaome"
HANGOUTS_IDS = [
36197, # QtWebEngine 6.5, as found by toofar
34897, # QtWebEngine 6.4
41262, # QtWebEngine 6.7
36197, # QtWebEngine 6.6
34897, # QtWebEngine 6.5
32707, # QtWebEngine 6.4
27537, # QtWebEngine 6.3
23607, # QtWebEngine 6.2
]
PAK_VERSION = 5
RESOURCES_ENV_VAR = "QTWEBENGINE_RESOURCES_PATH"

View File

@ -25,17 +25,6 @@ pytestmark = pytest.mark.usefixtures("cache_tmpdir")
versions = version.qtwebengine_versions(avoid_init=True)
# Used to skip happy path tests with the real resources file.
#
# Since we don't know how reliably the Google Meet hangouts extensions is
# reliably in the resource files, and this quirk is only targeting 6.6
# anyway.
skip_if_unsupported = pytest.mark.skipif(
versions.webengine != utils.VersionNumber(6, 6),
reason="Code under test only runs on 6.6",
)
@pytest.fixture(autouse=True)
def prepare_env(qapp, monkeypatch):
monkeypatch.setattr(pakjoy.objects, "qapp", qapp)
@ -206,7 +195,6 @@ def read_patched_manifest():
class TestWithRealResourcesFile:
"""Tests that use the real pak file form the Qt installation."""
@skip_if_unsupported
def test_happy_path(self):
# Go through the full patching processes with the real resources file from
# the current installation. Make sure our replacement string is in it
@ -266,6 +254,19 @@ class TestWithRealResourcesFile:
"Not applying quirks. Expected location: "
)
def test_hardcoded_ids(self):
"""Make sure we hardcoded the currently valid ID.
This avoids users having to iterate through the whole resource file on
every start. It will probably break on every QtWebEngine upgrade and can
be fixed by adding the respective ID to HANGOUTS_IDS.
"""
resources_dir = pakjoy._find_webengine_resources()
file_to_patch = resources_dir / pakjoy.PAK_FILENAME
with open(file_to_patch, "rb") as f:
parser = pakjoy.PakParser(f)
assert parser.manifest_entry.resource_id in pakjoy.HANGOUTS_IDS
def json_manifest_factory(extension_id=pakjoy.HANGOUTS_MARKER, url=pakjoy.TARGET_URL):
assert isinstance(extension_id, bytes)