diff --git a/qutebrowser/browser/webengine/webenginesettings.py b/qutebrowser/browser/webengine/webenginesettings.py index 9f721fdcf..43ff61c09 100644 --- a/qutebrowser/browser/webengine/webenginesettings.py +++ b/qutebrowser/browser/webengine/webenginesettings.py @@ -417,6 +417,25 @@ def _init_profile(profile: QWebEngineProfile) -> None: lambda url: profile.clearVisitedLinks([url])) _global_settings.init_settings() + _maybe_disable_hangouts_extension(profile) + + +def _maybe_disable_hangouts_extension(profile: QWebEngineProfile) -> None: + """Disable the Hangouts extension for Qt 6.10+.""" + if not config.val.qt.workarounds.disable_hangouts_extension: + return + + try: + ext_manager = profile.extensionManager() + except AttributeError: + return # added in QtWebEngine 6.10 + + assert ext_manager is not None # mypy + for info in ext_manager.extensions(): + if info.id() == pakjoy.HANGOUTS_EXT_ID: + log.misc.debug(f"Disabling extension: {info.name()}") + # setExtensionEnabled(info, False) seems to segfault + ext_manager.unloadExtension(info) def _clear_webengine_permissions_json(): diff --git a/qutebrowser/misc/pakjoy.py b/qutebrowser/misc/pakjoy.py index 87b84789b..d1db1b468 100644 --- a/qutebrowser/misc/pakjoy.py +++ b/qutebrowser/misc/pakjoy.py @@ -38,8 +38,11 @@ from qutebrowser.config import config from qutebrowser.misc import binparsing, objects from qutebrowser.qt import core from qutebrowser.utils import qtutils, standarddir, version, utils, log, message +from qutebrowser.qt.webenginecore import QWebEngineProfile -HANGOUTS_MARKER = b"// Extension ID: nkeimhogjdpnpccoofpliimaahmaaome" + +HANGOUTS_EXT_ID = "nkeimhogjdpnpccoofpliimaahmaaome" +HANGOUTS_MARKER = f"// Extension ID: {HANGOUTS_EXT_ID}".encode("utf-8") HANGOUTS_IDS = [ # Linux 47222, # QtWebEngine 6.9 Beta 3 @@ -228,7 +231,7 @@ def copy_webengine_resources() -> Optional[pathlib.Path]: ) # https://github.com/qutebrowser/qutebrowser/issues/8257 or config.val.qt.workarounds.disable_hangouts_extension - ): + ) or hasattr(QWebEngineProfile, "extensionManager"): # Qt 6.10+ # No patching needed return None diff --git a/tests/unit/misc/test_pakjoy.py b/tests/unit/misc/test_pakjoy.py index de037a3ea..50cfa3fd4 100644 --- a/tests/unit/misc/test_pakjoy.py +++ b/tests/unit/misc/test_pakjoy.py @@ -203,10 +203,10 @@ skip_if_incompatible = pytest.mark.skipif( @pytest.mark.usefixtures("affected_version") +@skip_if_incompatible class TestWithRealResourcesFile: """Tests that use the real pak file form the Qt installation.""" - @skip_if_incompatible 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,7 +266,6 @@ class TestWithRealResourcesFile: "Not applying quirks. Expected location: " ) - @skip_if_incompatible def test_hardcoded_ids(self): """Make sure we hardcoded the currently valid ID. @@ -454,6 +453,7 @@ class TestWithConstructedResourcesFile: def quirk_dir_path(self, tmp_path: pathlib.Path) -> pathlib.Path: return tmp_path / "cache" / pakjoy.CACHE_DIR_NAME + @skip_if_incompatible def test_patching(self, resources_path: pathlib.Path, quirk_dir_path: pathlib.Path): """Go through the full patching processes with a fake resources file.""" with pakjoy.patch_webengine(): @@ -473,6 +473,7 @@ class TestWithConstructedResourcesFile: with pakjoy.patch_webengine(): assert pakjoy.RESOURCES_ENV_VAR in os.environ + @skip_if_incompatible def test_preset_env_var( self, resources_path: pathlib.Path,