Bug 1649186 - Remove use of nsISearchService.addEngineWithDetails from remaining mochitests. r=mak

Differential Revision: https://phabricator.services.mozilla.com/D108478
This commit is contained in:
Mark Banner 2021-03-19 14:06:07 +00:00
parent 5e786e8b26
commit d1d9f9a603
4 changed files with 22 additions and 18 deletions

View File

@ -155,9 +155,11 @@ add_task(async function basic() {
// For engines with an invalid TLD, we filter on the entire domain.
add_task(async function malformedEngine() {
let badEngine = await Services.search.addEngineWithDetails("TestMalformed", {
template: `http://example.foobar/?search={searchTerms}`,
await SearchTestUtils.installSearchExtension({
name: "TestMalformed",
search_url: "https://example.foobar/",
});
let badEngine = Services.search.getEngineByName("TestMalformed");
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
@ -206,5 +208,4 @@ add_task(async function malformedEngine() {
await UrlbarTestUtils.exitSearchMode(window);
await UrlbarTestUtils.promisePopupClose(window);
await Services.search.removeEngine(badEngine);
});

View File

@ -533,9 +533,9 @@ const tests = [
async function(win) {
info("Type an @alias, then space, then search and press enter.");
const alias = "testalias";
let aliasEngine = await Services.search.addEngineWithDetails("AliasTest", {
alias,
template: "http://example.com/?search={searchTerms}",
await SearchTestUtils.installSearchExtension({
name: "AliasTest",
keyword: alias,
});
await UrlbarTestUtils.promiseAutocompleteResultPopup({
@ -557,7 +557,6 @@ const tests = [
EventUtils.synthesizeKey("VK_RETURN", {}, win);
await promise;
await Services.search.removeEngine(aliasEngine);
return {
category: "urlbar",
method: "engagement",

View File

@ -87,11 +87,13 @@ async function withNewSearchEngine(taskFn) {
}
add_task(async function setup() {
// Create a new search engine.
await Services.search.addEngineWithDetails("MozSearch", {
alias: "mozalias",
method: "GET",
template: "http://example.com/?q={searchTerms}",
await SearchTestUtils.installSearchExtension({
name: "MozSearch",
keyword: "mozalias",
// TODO: Bug 1698568. This should just be `search_url: "https://example.com"`
// with the default value of `search_url_get_params`.
search_url: "https://example.com/?q={searchTerms}",
search_url_get_params: "",
});
// Make it the default search engine.
@ -135,7 +137,6 @@ add_task(async function setup() {
registerCleanupFunction(async function() {
Services.telemetry.canRecordExtended = oldCanRecord;
await Services.search.setDefault(originalEngine);
await Services.search.removeEngine(engine);
Services.prefs.setBoolPref(SUGGEST_URLBAR_PREF, suggestionsEnabled);
await PlacesUtils.history.clear();
await UrlbarTestUtils.formHistory.clear();
@ -1170,7 +1171,7 @@ add_task(async function test_privateWindow() {
SearchSERPTelemetry.overrideSearchTelemetryForTests([
{
telemetryId: "example",
searchPageRegexp: "^http://example\\.com/",
searchPageRegexp: "^https://example\\.com/",
queryParamName: "q",
},
]);

View File

@ -211,9 +211,12 @@ add_task(async function onboarding_impressions() {
async function impressions_test(isOnboarding) {
await BrowserTestUtils.withNewTab("about:blank", async browser => {
const firstEngineHost = "example";
let secondEngine = await Services.search.addEngineWithDetails(
`${ENGINE_NAME}2`,
{ template: `http://${firstEngineHost}-2.com/?q={searchTerms}` }
let extension = await SearchTestUtils.installSearchExtension(
{
name: `${ENGINE_NAME}2`,
search_url: `https://${firstEngineHost}-2.com/`,
},
true
);
for (let i = 0; i < 3; i++) {
@ -444,6 +447,6 @@ async function impressions_test(isOnboarding) {
);
await PlacesUtils.history.clear();
await Services.search.removeEngine(secondEngine);
await extension.unload();
});
}