The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.
Extensions: Manifest V2 extensions such as uBlock Origin run again (#228)
Victor905a58261ef0
diff --git a/Sources/Cra/Services/Import/ExtensionImporter.swift b/Sources/Cra/Services/Import/ExtensionImporter.swiftindex b59b78f..611b32c 100644--- a/Sources/Cra/Services/Import/ExtensionImporter.swift+++ b/Sources/Cra/Services/Import/ExtensionImporter.swift@@ -74,8 +74,15 @@ enum ExtensionImporter {return settings}+ /// Chromium's DISABLE_UNSUPPORTED_MANIFEST_VERSION: Chrome 139 and later turn every+ /// Manifest V2 extension off with it. Cra runs them (GitHub #228), so it doesn't count.+ static let unsupportedManifestVersion = 1 << 23+private static func isDisabled(_ s: [String: Any]) -> Bool {- !((s["disable_reasons"] as? [Any])?.isEmpty ?? true) || (s["state"] as? Int) == 0+ if let reasons = s["disable_reasons"] as? [Any], !reasons.isEmpty {+ return reasons.contains { ($0 as? Int) != unsupportedManifestVersion }+ }+ return (s["state"] as? Int) == 0}/// Extensions turned off in this profile (chrome://extensions), of any install location:diff --git a/Tests/Fixtures/Chromium/Default/Preferences b/Tests/Fixtures/Chromium/Default/Preferencesindex 5973aa0..684eaf9 100644--- a/Tests/Fixtures/Chromium/Default/Preferences+++ b/Tests/Fixtures/Chromium/Default/Preferences@@ -12,7 +12,22 @@1],"path": "/nowhere"+ },+ "cccccccccccccccccccccccccccccccc": {+ "location": 1,+ "disable_reasons": [+ 8388608+ ],+ "path": "cccc/1.0"+ },+ "dddddddddddddddddddddddddddddddd": {+ "location": 1,+ "disable_reasons": [+ 1,+ 8388608+ ],+ "path": "dddd/1.0"}}}-}\ No newline at end of file+}diff --git a/Tests/Fixtures/Chromium/README.md b/Tests/Fixtures/Chromium/README.mdindex b5fc2fd..4f9a8fd 100644--- a/Tests/Fixtures/Chromium/README.md+++ b/Tests/Fixtures/Chromium/README.md@@ -1,5 +1,6 @@A made-up Chromium profile (Default/) in Chromium's own formats, for the importer tests andthe parser fuzzer (scripts/test-store.sh, scripts/fuzz.sh): a version 3 SNSS session with aclosed tab, a tab with two navigations and a chrome:// page; Bookmarks with a nested, an empty-and a file: entry; Preferences with one extension on and one turned off. Every address is on+and a file: entry; Preferences with one extension on, one turned off, one Chrome turned off only for being+Manifest V2 (disable reason 1 << 23, which Cra doesn't apply) and one turned off for both reasons. Every address is onexample.com.diff --git a/Tests/Fixtures/ManifestV2Extension/background.js b/Tests/Fixtures/ManifestV2Extension/background.jsnew file mode 100644index 0000000..4e7f966--- /dev/null+++ b/Tests/Fixtures/ManifestV2Extension/background.js@@ -0,0 +1,7 @@+// Cancels every request whose address holds "cra-mv2-probe". Only a running Manifest V2+// extension can: blocking webRequest listeners are gone from Manifest V3.+chrome.webRequest.onBeforeRequest.addListener(+ () => ({ cancel: true }),+ { urls: ["http://127.0.0.1/*cra-mv2-probe*"] },+ ["blocking"]+);diff --git a/Tests/Fixtures/ManifestV2Extension/manifest.json b/Tests/Fixtures/ManifestV2Extension/manifest.jsonnew file mode 100644index 0000000..ffb780b--- /dev/null+++ b/Tests/Fixtures/ManifestV2Extension/manifest.json@@ -0,0 +1,8 @@+{+ "manifest_version": 2,+ "name": "Cra Manifest V2 Fixture",+ "version": "1.0",+ "description": "Made up for scripts/scenario.sh: a Manifest V2 extension that blocks requests from a persistent background page with webRequestBlocking, the way uBlock Origin does (GitHub #228).",+ "permissions": ["webRequest", "webRequestBlocking", "http://127.0.0.1/*"],+ "background": { "scripts": ["background.js"], "persistent": true }+}diff --git a/Tests/Scenarios/manifest-v2-extensions.scenario b/Tests/Scenarios/manifest-v2-extensions.scenarionew file mode 100644index 0000000..811c1ce--- /dev/null+++ b/Tests/Scenarios/manifest-v2-extensions.scenario@@ -0,0 +1,15 @@+# A Manifest V2 extension, the kind uBlock Origin is, loads and blocks requests. Chromium 156+# refuses to load MV2 extensions ("unsupported manifest version", in a modal alert for a folder+# loaded at start-up) and turns installed ones off; Cra's engine keeps them+# (scripts/cef-patches/extensions-manifest-v2.patch, GitHub #228).+# The fixture cancels requests whose address holds "cra-mv2-probe" from a blocking webRequest+# listener, which Manifest V3 no longer has; without the extension the fetch loads the page.+# promise: #228+budget rss=600 stalls50=5+extension ${FIXTURES}/ManifestV2Extension+cra://open?url=${PAGE}?n=mv2+expect-log loaded 127\.0\.0\.1+wait 2+cra://debug?cdp=Runtime.evaluate¶ms={"expression":"fetch('page.html?cra-mv2-probe').then(()=>'mv2:loaded',()=>'mv2:blocked')","awaitPromise":true}+expect-log Cra cdp Runtime.evaluate .*"value":"mv2:blocked"+reject-log fault:diff --git a/Tests/StoreTests.swift b/Tests/StoreTests.swiftindex f43da25..27143fb 100644--- a/Tests/StoreTests.swift+++ b/Tests/StoreTests.swift@@ -21,6 +21,7 @@ enum StoreTests {try arcImport()try diaImport()chromiumProfile()+ chromiumManifestV2Import()autoArchive()tabSleepCadence()tabRestTimes()@@ -229,10 +230,21 @@ enum StoreTests {expect(marks.other.map(\.url) == ["https://example.com/other"], "other and mobile bookmarks come after")expect(ChromiumImporter.parseSession(Data("SNSS".utf8) + Data([4, 0, 0, 0]) + Data(repeating: 1, count: 16)).isEmpty,"an encrypted session (version 4) gives nothing rather than garbage")- expect(ExtensionImporter.disabledIDs(inProfile: profile) == ["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],+ expect(ExtensionImporter.disabledIDs(inProfile: profile).contains("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")+ && !ExtensionImporter.disabledIDs(inProfile: profile).contains("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),"an extension with disable_reasons is off, one in state 1 is on")}+ // promise: #228+ /// Chrome 139 and later turn every Manifest V2 extension off (disable reason 1 << 23);+ /// Cra runs them (extensions-manifest-v2.patch), so an import from Chrome brings uBlock+ /// Origin over turned on unless the person had turned it off too.+ private static func chromiumManifestV2Import() {+ let profile = URL(fileURLWithPath: #filePath).deletingLastPathComponent().appendingPathComponent("Fixtures/Chromium/Default")+ expect(ExtensionImporter.disabledIDs(inProfile: profile) == ["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "dddddddddddddddddddddddddddddddd"],+ "off only for being Manifest V2 counts as on; off by the person as well stays off")+ }+/// Arc archives unused Today tabs on a 30-minute pass; the selected tab stays.@MainActorprivate static func autoArchive() {diff --git a/Tests/promises.lock b/Tests/promises.lockindex 8d7caa4..bdba39f 100644--- a/Tests/promises.lock+++ b/Tests/promises.lock@@ -355,6 +355,8 @@#226 Packages/CraCore/Tests/CraCoreTests/ToolbarCompositionTests.swift::theURLFieldHasTheSlidersWithoutExtensions a7173c578717#226 Tests/Scenarios/site-controls-no-extensions.scenario c1c5b5365539#227 Tests/Scenarios/quit-during-web-store-install.scenario a3e3b0c8eb2b+#228 Tests/Scenarios/manifest-v2-extensions.scenario 79e8ee402189+#228 Tests/StoreTests.swift::chromiumManifestV2Import bf235b11b6d1#231 Packages/CraCore/Tests/CraCoreTests/MenuBarModeTests.swift::incognitoWindowsCloseTheRestArePutAway 017bb7d06672#231 Packages/CraCore/Tests/CraCoreTests/MenuBarModeTests.swift::offEveryQuitQuits f494762d7992#231 Packages/CraCore/Tests/CraCoreTests/MenuBarModeTests.swift::onlyCrasOwnQuitStaysInTheMenuBar 93aebb57b7cadiff --git a/scripts/cef-patches/extensions-manifest-v2.patch b/scripts/cef-patches/extensions-manifest-v2.patchnew file mode 100644index 0000000..3465bc3--- /dev/null+++ b/scripts/cef-patches/extensions-manifest-v2.patch@@ -0,0 +1,56 @@+diff --git a/chrome/browser/extensions/api/developer_private/extension_info_generator.cc b/chrome/browser/extensions/api/developer_private/extension_info_generator.cc+index d4ef0e322b..19066f8ad0 100644+--- a/chrome/browser/extensions/api/developer_private/extension_info_generator.cc++++ b/chrome/browser/extensions/api/developer_private/extension_info_generator.cc+@@ -900,8 +900,9 @@ void ExtensionInfoGenerator::FillExtensionInfo(const Extension& extension,+ // MV2 deprecation.+ ManifestV2Handler* mv2_handler = ManifestV2Handler::Get(profile);+ CHECK(mv2_handler);+- info.is_affected_by_mv2_deprecation =+- mv2_handler->IsExtensionAffected(extension);++ // Cra supports Manifest V2: chrome://extensions shows no "no longer++ // supported" notice for them.++ info.is_affected_by_mv2_deprecation = false;+ if (info.web_store_url.length() > 0) {+ info.recommendations_url =+ extension_urls::GetNewWebstoreItemRecommendationsUrl(extension.id())+diff --git a/extensions/browser/manifest_v2_handler.cc b/extensions/browser/manifest_v2_handler.cc+index 5841d3dfbc..f216fd34de 100644+--- a/extensions/browser/manifest_v2_handler.cc++++ b/extensions/browser/manifest_v2_handler.cc+@@ -108,13 +108,11 @@ bool ManifestV2HandlerFactory::ServiceIsCreatedWithBrowserContext() const {+ }++ // Returns true if legacy extensions should be disabled.++// Cra keeps Manifest V2 extensions (uBlock Origin among them) installable and on,++// as Chrome did before 139; the ones Chromium turned off come back on at the next++// profile load (CheckDisabledExtensions). GitHub #228.+ bool ShouldDisableLegacyExtensions() {+- if (g_allow_mv2_for_testing) {+- // We allow legacy MV2 extensions for testing purposes.+- return false;+- }+-+- return true;++ return false;+ }++ } // namespace+diff --git a/extensions/common/extension.cc b/extensions/common/extension.cc+index 28a3cac375..22618c16e6 100644+--- a/extensions/common/extension.cc++++ b/extensions/common/extension.cc+@@ -97,12 +97,7 @@ bool IsManifestSupported(int manifest_version,+ // Supported versions are always safe.+ if (manifest_version >= kMinimumSupportedManifestVersion &&+ manifest_version <= kMaximumSupportedManifestVersion) {+- // Emit a warning for unpacked extensions on Manifest V2 warning that+- // MV2 is deprecated.+- if (type == Manifest::Type::kExtension && manifest_version == 2 &&+- Manifest::IsUnpackedLocation(location)) {+- *warning = errors::kManifestV2IsDeprecatedWarning;+- }++ // Cra supports Manifest V2: no deprecation warning on unpacked ones.+ return true;+ }+diff --git a/scripts/fetch-cef.sh b/scripts/fetch-cef.shindex 6e3d566..f840c94 100755--- a/scripts/fetch-cef.sh+++ b/scripts/fetch-cef.sh@@ -15,7 +15,7 @@ CEF_VERSION="${CEF_VERSION:-156.0.26+g8ea0c73+chromium-156.0.8078.88}"ARCH="${CEF_ARCH:-$([ "$(uname -m)" = arm64 ] && echo macosarm64 || echo macosx64)}"NAME="cef_binary_${CEF_VERSION}_${ARCH}_minimal"# Bump the suffix (codecs2, …) when the build changes but CEF_VERSION does not.-CEF_RELEASE="${CEF_RELEASE:-cef-${CEF_VERSION%%+*}-codecs1}"+CEF_RELEASE="${CEF_RELEASE:-cef-${CEF_VERSION%%+*}-codecs2}"URL="${CEF_URL:-https://github.com/VictorKildahl/cra/releases/download/${CEF_RELEASE}/cef_binary_${ARCH}_minimal.tar.bz2}"mkdir -p vendor