Skip to content
Snippets Groups Projects
Verified Commit 3f9d00cb authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

Bug 1849129: Prevent exceptions caused by extensions from interrupting the...

Bug 1849129: Prevent exceptions caused by extensions from interrupting the SearchService initialization. r=search-reviewers,Standard8

Differential Revision: https://phabricator.services.mozilla.com/D186456
parent 73be3148
No related branches found
No related tags found
1 merge request!1037Bug 42614: Rebased onto 115.12
......@@ -1576,11 +1576,18 @@ export class SearchService {
"engines reported by AddonManager startup"
);
for (let extension of this.#startupExtensions) {
try {
await this.#installExtensionEngine(
extension,
[lazy.SearchUtils.DEFAULT_TAG],
true
);
} catch (ex) {
lazy.logConsole.error(
`#installExtensionEngine failed for ${extension.id}`,
ex
);
}
}
this.#startupExtensions.clear();
......
/* 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@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();
});
......@@ -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]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment