Pier Angelo Vendrame pushed to branch base-browser-115.2.0esr-13.0-1 at The Tor Project / Applications / Tor Browser
Commits:
-
a4d48a95
by Pier Angelo Vendrame at 2023-09-12T15:02:03+02:00
-
92026016
by Pier Angelo Vendrame at 2023-09-12T15:02:04+02:00
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:
... | ... | @@ -1574,11 +1574,18 @@ export class SearchService { |
1574 | 1574 | "engines reported by AddonManager startup"
|
1575 | 1575 | );
|
1576 | 1576 | for (let extension of this.#startupExtensions) {
|
1577 | - await this.#installExtensionEngine(
|
|
1578 | - extension,
|
|
1579 | - [lazy.SearchUtils.DEFAULT_TAG],
|
|
1580 | - true
|
|
1581 | - );
|
|
1577 | + try {
|
|
1578 | + await this.#installExtensionEngine(
|
|
1579 | + extension,
|
|
1580 | + [lazy.SearchUtils.DEFAULT_TAG],
|
|
1581 | + true
|
|
1582 | + );
|
|
1583 | + } catch (ex) {
|
|
1584 | + lazy.logConsole.error(
|
|
1585 | + `#installExtensionEngine failed for ${extension.id}`,
|
|
1586 | + ex
|
|
1587 | + );
|
|
1588 | + }
|
|
1582 | 1589 | }
|
1583 | 1590 | this.#startupExtensions.clear();
|
1584 | 1591 | |
... | ... | @@ -2715,7 +2722,6 @@ export class SearchService { |
2715 | 2722 | };
|
2716 | 2723 | |
2717 | 2724 | let engines = [];
|
2718 | - let revert = false;
|
|
2719 | 2725 | for (let locale of locales) {
|
2720 | 2726 | lazy.logConsole.debug(
|
2721 | 2727 | "addEnginesFromExtension: installing:",
|
... | ... | @@ -2723,28 +2729,7 @@ export class SearchService { |
2723 | 2729 | ":",
|
2724 | 2730 | locale
|
2725 | 2731 | );
|
2726 | - try {
|
|
2727 | - engines.push(await installLocale(locale));
|
|
2728 | - } catch (err) {
|
|
2729 | - lazy.logConsole.error(
|
|
2730 | - `Could not install the search engine of ${extension.id}`,
|
|
2731 | - err
|
|
2732 | - );
|
|
2733 | - revert = true;
|
|
2734 | - break;
|
|
2735 | - }
|
|
2736 | - }
|
|
2737 | - if (revert) {
|
|
2738 | - for (let engine of engines) {
|
|
2739 | - try {
|
|
2740 | - this.removeEngine(engine);
|
|
2741 | - } catch (err) {
|
|
2742 | - lazy.logConsole.warn(
|
|
2743 | - "Failed to revert the addition of a search engine",
|
|
2744 | - err
|
|
2745 | - );
|
|
2746 | - }
|
|
2747 | - }
|
|
2732 | + engines.push(await installLocale(locale));
|
|
2748 | 2733 | }
|
2749 | 2734 | return engines;
|
2750 | 2735 | }
|
1 | +/* Any copyright is dedicated to the Public Domain.
|
|
2 | + http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
3 | + |
|
4 | +"use strict";
|
|
5 | + |
|
6 | +const lazy = {};
|
|
7 | + |
|
8 | +const { promiseShutdownManager, promiseStartupManager } = AddonTestUtils;
|
|
9 | + |
|
10 | +ChromeUtils.defineESModuleGetters(lazy, {
|
|
11 | + ExtensionTestUtils:
|
|
12 | + "resource://testing-common/ExtensionXPCShellUtils.sys.mjs",
|
|
13 | +});
|
|
14 | + |
|
15 | +add_setup(async function () {
|
|
16 | + let server = useHttpServer();
|
|
17 | + server.registerContentType("sjs", "sjs");
|
|
18 | + await SearchTestUtils.useTestEngines("test-extensions");
|
|
19 | + await promiseStartupManager();
|
|
20 | + |
|
21 | + registerCleanupFunction(async () => {
|
|
22 | + await promiseShutdownManager();
|
|
23 | + });
|
|
24 | +});
|
|
25 | + |
|
26 | +add_task(async function test_install_duplicate_engine_startup() {
|
|
27 | + let name = "Plain";
|
|
28 | + let id = "plain@xxxxxxxxxxxxxxxxx";
|
|
29 | + consoleAllowList.push(
|
|
30 | + `#installExtensionEngine failed for ${id}`,
|
|
31 | + `An engine called ${name} already exists`
|
|
32 | + );
|
|
33 | + // Do not use SearchTestUtils.installSearchExtension, as we need to manually
|
|
34 | + // start the search service after installing the extension.
|
|
35 | + let extensionInfo = {
|
|
36 | + useAddonManager: "permanent",
|
|
37 | + files: {},
|
|
38 | + manifest: SearchTestUtils.createEngineManifest({
|
|
39 | + name,
|
|
40 | + search_url: "https://example.com/plain",
|
|
41 | + }),
|
|
42 | + };
|
|
43 | + |
|
44 | + let extension = lazy.ExtensionTestUtils.loadExtension(extensionInfo);
|
|
45 | + await extension.startup();
|
|
46 | + |
|
47 | + await Services.search.init();
|
|
48 | + |
|
49 | + await AddonTestUtils.waitForSearchProviderStartup(extension);
|
|
50 | + let engine = await Services.search.getEngineByName(name);
|
|
51 | + let submission = engine.getSubmission("foo");
|
|
52 | + Assert.equal(
|
|
53 | + submission.uri.spec,
|
|
54 | + "https://duckduckgo.com/?q=foo&t=ffsb",
|
|
55 | + "Should have not changed the app provided engine."
|
|
56 | + );
|
|
57 | + |
|
58 | + await extension.unload();
|
|
59 | +}); |
... | ... | @@ -191,6 +191,7 @@ support-files = data/search_ignorelist.json |
191 | 191 | [test_webextensions_migrate_to.js]
|
192 | 192 | support-files = data/search-migration.json
|
193 | 193 | [test_webextensions_normandy_upgrade.js]
|
194 | +[test_webextensions_startup_duplicate.js]
|
|
194 | 195 | [test_webextensions_startup_remove.js]
|
195 | 196 | [test_webextensions_upgrade.js]
|
196 | 197 | [test_webextensions_valid.js] |