Pier Angelo Vendrame pushed to branch tor-browser-115.2.0esr-13.0-1 at The Tor Project / Applications / Tor Browser

Commits:

3 changed files:

Changes:

  • toolkit/components/search/SearchService.sys.mjs
    ... ... @@ -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
     
    
    ... ... @@ -2713,7 +2720,6 @@ export class SearchService {
    2713 2720
         };
    
    2714 2721
     
    
    2715 2722
         let engines = [];
    
    2716
    -    let revert = false;
    
    2717 2723
         for (let locale of locales) {
    
    2718 2724
           lazy.logConsole.debug(
    
    2719 2725
             "addEnginesFromExtension: installing:",
    
    ... ... @@ -2721,28 +2727,7 @@ export class SearchService {
    2721 2727
             ":",
    
    2722 2728
             locale
    
    2723 2729
           );
    
    2724
    -      try {
    
    2725
    -        engines.push(await installLocale(locale));
    
    2726
    -      } catch (err) {
    
    2727
    -        lazy.logConsole.error(
    
    2728
    -          `Could not install the search engine of ${extension.id}`,
    
    2729
    -          err
    
    2730
    -        );
    
    2731
    -        revert = true;
    
    2732
    -        break;
    
    2733
    -      }
    
    2734
    -    }
    
    2735
    -    if (revert) {
    
    2736
    -      for (let engine of engines) {
    
    2737
    -        try {
    
    2738
    -          this.removeEngine(engine);
    
    2739
    -        } catch (err) {
    
    2740
    -          lazy.logConsole.warn(
    
    2741
    -            "Failed to revert the addition of a search engine",
    
    2742
    -            err
    
    2743
    -          );
    
    2744
    -        }
    
    2745
    -      }
    
    2730
    +      engines.push(await installLocale(locale));
    
    2746 2731
         }
    
    2747 2732
         return engines;
    
    2748 2733
       }
    

  • toolkit/components/search/tests/xpcshell/test_webextensions_startup_duplicate.js
    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@tests.mozilla.org";
    
    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
    +});

  • toolkit/components/search/tests/xpcshell/xpcshell.ini
    ... ... @@ -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]