[tbb-commits] [Git][tpo/applications/tor-browser][tor-browser-115.2.0esr-13.0-1] 2 commits: Revert "Bug 42022: Prevent extension search engines from breaking the whole search system"
Pier Angelo Vendrame (@pierov)
git at gitlab.torproject.org
Tue Sep 12 12:55:32 UTC 2023
Pier Angelo Vendrame pushed to branch tor-browser-115.2.0esr-13.0-1 at The Tor Project / Applications / Tor Browser
Commits:
967cf4de by Pier Angelo Vendrame at 2023-09-12T14:47:03+02:00
Revert "Bug 42022: Prevent extension search engines from breaking the whole search system"
This reverts commit 9d7a9a7969394bc9503cc22ad9324666ca72cecc.
- - - - -
27211730 by Pier Angelo Vendrame at 2023-09-12T14:48:04+02:00
Bug 1849129: Prevent exceptions caused by extensions from interrupting the SearchService initialization. r=search-reviewers,Standard8
Differential Revision: https://phabricator.services.mozilla.com/D186456
- - - - -
3 changed files:
- toolkit/components/search/SearchService.sys.mjs
- + toolkit/components/search/tests/xpcshell/test_webextensions_startup_duplicate.js
- toolkit/components/search/tests/xpcshell/xpcshell.ini
Changes:
=====================================
toolkit/components/search/SearchService.sys.mjs
=====================================
@@ -1574,11 +1574,18 @@ export class SearchService {
"engines reported by AddonManager startup"
);
for (let extension of this.#startupExtensions) {
- await this.#installExtensionEngine(
- extension,
- [lazy.SearchUtils.DEFAULT_TAG],
- true
- );
+ try {
+ await this.#installExtensionEngine(
+ extension,
+ [lazy.SearchUtils.DEFAULT_TAG],
+ true
+ );
+ } catch (ex) {
+ lazy.logConsole.error(
+ `#installExtensionEngine failed for ${extension.id}`,
+ ex
+ );
+ }
}
this.#startupExtensions.clear();
@@ -2713,7 +2720,6 @@ export class SearchService {
};
let engines = [];
- let revert = false;
for (let locale of locales) {
lazy.logConsole.debug(
"addEnginesFromExtension: installing:",
@@ -2721,28 +2727,7 @@ export class SearchService {
":",
locale
);
- try {
- engines.push(await installLocale(locale));
- } catch (err) {
- lazy.logConsole.error(
- `Could not install the search engine of ${extension.id}`,
- err
- );
- revert = true;
- break;
- }
- }
- if (revert) {
- for (let engine of engines) {
- try {
- this.removeEngine(engine);
- } catch (err) {
- lazy.logConsole.warn(
- "Failed to revert the addition of a search engine",
- err
- );
- }
- }
+ engines.push(await installLocale(locale));
}
return engines;
}
=====================================
toolkit/components/search/tests/xpcshell/test_webextensions_startup_duplicate.js
=====================================
@@ -0,0 +1,59 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const lazy = {};
+
+const { promiseShutdownManager, promiseStartupManager } = AddonTestUtils;
+
+ChromeUtils.defineESModuleGetters(lazy, {
+ ExtensionTestUtils:
+ "resource://testing-common/ExtensionXPCShellUtils.sys.mjs",
+});
+
+add_setup(async function () {
+ let server = useHttpServer();
+ server.registerContentType("sjs", "sjs");
+ await SearchTestUtils.useTestEngines("test-extensions");
+ await promiseStartupManager();
+
+ registerCleanupFunction(async () => {
+ await promiseShutdownManager();
+ });
+});
+
+add_task(async function test_install_duplicate_engine_startup() {
+ let name = "Plain";
+ let id = "plain at tests.mozilla.org";
+ consoleAllowList.push(
+ `#installExtensionEngine failed for ${id}`,
+ `An engine called ${name} already exists`
+ );
+ // Do not use SearchTestUtils.installSearchExtension, as we need to manually
+ // start the search service after installing the extension.
+ let extensionInfo = {
+ useAddonManager: "permanent",
+ files: {},
+ manifest: SearchTestUtils.createEngineManifest({
+ name,
+ search_url: "https://example.com/plain",
+ }),
+ };
+
+ let extension = lazy.ExtensionTestUtils.loadExtension(extensionInfo);
+ await extension.startup();
+
+ await Services.search.init();
+
+ await AddonTestUtils.waitForSearchProviderStartup(extension);
+ let engine = await Services.search.getEngineByName(name);
+ let submission = engine.getSubmission("foo");
+ Assert.equal(
+ submission.uri.spec,
+ "https://duckduckgo.com/?q=foo&t=ffsb",
+ "Should have not changed the app provided engine."
+ );
+
+ await extension.unload();
+});
=====================================
toolkit/components/search/tests/xpcshell/xpcshell.ini
=====================================
@@ -191,6 +191,7 @@ support-files = data/search_ignorelist.json
[test_webextensions_migrate_to.js]
support-files = data/search-migration.json
[test_webextensions_normandy_upgrade.js]
+[test_webextensions_startup_duplicate.js]
[test_webextensions_startup_remove.js]
[test_webextensions_upgrade.js]
[test_webextensions_valid.js]
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/8cff1681b5043289085fa21e1a1927c59e5b4c47...27211730a538a733912a5f3a86ebfa8960e26c1d
--
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/8cff1681b5043289085fa21e1a1927c59e5b4c47...27211730a538a733912a5f3a86ebfa8960e26c1d
You're receiving this email because of your account on gitlab.torproject.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20230912/ca71c1db/attachment-0001.htm>
More information about the tbb-commits
mailing list