зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 369739, bug 1696027) for browser_searchChangedEngine.js and test_webextensions_upgrade.js failures CLOSED TREE
Backed out changeset 2705f924b635 (bug 369739) Backed out changeset 6e5ccf3eeaa6 (bug 1696027)
This commit is contained in:
Родитель
338f8a12cb
Коммит
621d71189b
|
@ -1,16 +1,12 @@
|
|||
const ANY_URL = undefined;
|
||||
|
||||
const { SearchTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/SearchTestUtils.jsm"
|
||||
);
|
||||
|
||||
SearchTestUtils.init(this);
|
||||
|
||||
registerCleanupFunction(async function cleanup() {
|
||||
while (gBrowser.tabs.length > 1) {
|
||||
BrowserTestUtils.removeTab(gBrowser.tabs[gBrowser.tabs.length - 1]);
|
||||
}
|
||||
await Services.search.setDefault(originalEngine);
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
|
||||
let originalEngine;
|
||||
|
@ -19,10 +15,9 @@ add_task(async function test_setup() {
|
|||
requestLongerTimeout(2);
|
||||
|
||||
// Stop search-engine loads from hitting the network
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch",
|
||||
search_url: "https://example.com/",
|
||||
search_url_get_params: "q={searchTerms}",
|
||||
await Services.search.addEngineWithDetails("MozSearch", {
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
originalEngine = await Services.search.getDefault();
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
const { SearchTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/SearchTestUtils.jsm"
|
||||
);
|
||||
|
||||
SearchTestUtils.init(this);
|
||||
|
||||
registerCleanupFunction(async function cleanup() {
|
||||
await Services.search.setDefault(originalEngine);
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
|
||||
let originalEngine;
|
||||
|
@ -14,10 +10,9 @@ add_task(async function test_setup() {
|
|||
requestLongerTimeout(10);
|
||||
|
||||
// Stop search-engine loads from hitting the network
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch",
|
||||
search_url: "https://example.com/",
|
||||
search_url_get_params: "q={searchTerms}",
|
||||
await Services.search.addEngineWithDetails("MozSearch", {
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
originalEngine = await Services.search.getDefault();
|
||||
|
|
|
@ -3,26 +3,21 @@ requestLongerTimeout(2);
|
|||
|
||||
const ANY_URL = undefined;
|
||||
|
||||
const { SearchTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/SearchTestUtils.jsm"
|
||||
);
|
||||
|
||||
SearchTestUtils.init(this);
|
||||
|
||||
registerCleanupFunction(async function cleanup() {
|
||||
while (gBrowser.tabs.length > 1) {
|
||||
BrowserTestUtils.removeTab(gBrowser.tabs[gBrowser.tabs.length - 1]);
|
||||
}
|
||||
await Services.search.setDefault(originalEngine);
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
|
||||
let originalEngine;
|
||||
add_task(async function test_setup() {
|
||||
// Stop search-engine loads from hitting the network
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch",
|
||||
search_url: "https://example.com/",
|
||||
search_url_get_params: "q={searchTerms}",
|
||||
await Services.search.addEngineWithDetails("MozSearch", {
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
originalEngine = await Services.search.getDefault();
|
||||
|
|
|
@ -3,12 +3,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { SearchTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/SearchTestUtils.jsm"
|
||||
);
|
||||
|
||||
SearchTestUtils.init(this);
|
||||
|
||||
const kButton = document.getElementById("reload-button");
|
||||
|
||||
add_task(async function setup() {
|
||||
|
@ -16,19 +10,21 @@ add_task(async function setup() {
|
|||
set: [["browser.fixup.dns_first_for_single_words", true]],
|
||||
});
|
||||
|
||||
await Services.search.init();
|
||||
|
||||
// Create an engine to use for the test.
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch",
|
||||
search_url: "https://example.com/",
|
||||
search_url_get_params: "q={searchTerms}",
|
||||
await Services.search.addEngineWithDetails("MozSearch1", {
|
||||
method: "GET",
|
||||
template: "https://example.com/?q={searchTerms}",
|
||||
});
|
||||
|
||||
let originalEngine = await Services.search.getDefault();
|
||||
let engineDefault = Services.search.getEngineByName("MozSearch");
|
||||
let engineDefault = Services.search.getEngineByName("MozSearch1");
|
||||
await Services.search.setDefault(engineDefault);
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.setDefault(originalEngine);
|
||||
await Services.search.removeEngine(engineDefault);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
const { SearchTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/SearchTestUtils.jsm"
|
||||
);
|
||||
|
||||
SearchTestUtils.init(this);
|
||||
let engineName = "engine1";
|
||||
|
||||
function getCellText(tree, i, cellName) {
|
||||
return tree.view.getCellText(i, tree.columns.getNamedColumn(cellName));
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
keyword: ["testing", "customkeyword"],
|
||||
search_url: "https://example.com/engine1",
|
||||
search_url_get_params: "search={searchTerms}",
|
||||
const engine = await Services.search.addEngineWithDetails(engineName, {
|
||||
alias: ["testing", "customkeyword"],
|
||||
method: "get",
|
||||
template: "http://example.com/engine1?search={searchTerms}",
|
||||
});
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -5,18 +5,15 @@ const { SearchTestUtils } = ChromeUtils.import(
|
|||
"resource://testing-common/SearchTestUtils.jsm"
|
||||
);
|
||||
|
||||
SearchTestUtils.init(this);
|
||||
|
||||
add_task(async function setup() {
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "engine1",
|
||||
search_url: "https://example.com/engine1",
|
||||
search_url_get_params: "search={searchTerms}",
|
||||
const engine1 = await Services.search.addEngineWithDetails("engine1", {
|
||||
method: "get",
|
||||
template: "http://example.com/engine1?search={searchTerms}",
|
||||
});
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "engine2",
|
||||
search_url: "https://example.com/engine2",
|
||||
search_url_get_params: "search={searchTerms}",
|
||||
|
||||
const engine2 = await Services.search.addEngineWithDetails("engine2", {
|
||||
method: "get",
|
||||
template: "http://example.com/engine2?search={searchTerms}",
|
||||
});
|
||||
|
||||
const originalDefault = await Services.search.getDefault();
|
||||
|
@ -25,6 +22,9 @@ add_task(async function setup() {
|
|||
registerCleanupFunction(async () => {
|
||||
await Services.search.setDefault(originalDefault);
|
||||
await Services.search.setDefaultPrivate(originalDefaultPrivate);
|
||||
|
||||
await Services.search.removeEngine(engine1);
|
||||
await Services.search.removeEngine(engine2);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -262,12 +262,14 @@ add_task(async function setup() {
|
|||
let currentEngines = await Services.search.getVisibleEngines();
|
||||
|
||||
extension1 = await SearchTestUtils.installSearchExtension({
|
||||
id: TEST_ENGINE1_NAME,
|
||||
name: TEST_ENGINE1_NAME,
|
||||
suggest_url:
|
||||
"https://example.com/browser/browser/components/search/test/browser/searchSuggestionEngine.sjs",
|
||||
suggest_url_get_params: "query={searchTerms}",
|
||||
});
|
||||
extension2 = await SearchTestUtils.installSearchExtension({
|
||||
id: TEST_ENGINE2_NAME,
|
||||
name: TEST_ENGINE2_NAME,
|
||||
suggest_url:
|
||||
"https://example.com/browser/browser/components/search/test/browser/searchSuggestionEngine.sjs",
|
||||
|
@ -1020,6 +1022,8 @@ add_task(async function cleanup() {
|
|||
await Services.search.setDefault(
|
||||
Services.search.getEngineByName(currentEngineName)
|
||||
);
|
||||
await extension1.unload();
|
||||
await extension2.unload();
|
||||
});
|
||||
|
||||
function checkState(
|
||||
|
|
|
@ -108,3 +108,9 @@ add_task(async function test_content_search_icon_in_private_window() {
|
|||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
||||
add_task(async function cleanup() {
|
||||
// Extensions must be unloaded before registerCleanupFunction runs, so
|
||||
// unload them here.
|
||||
await extension.unload();
|
||||
});
|
||||
|
|
|
@ -14,23 +14,23 @@ const ENGINE_NAME = "mozSearch";
|
|||
const ENGINE_URL =
|
||||
"https://example.com/browser/browser/components/search/test/browser/mozsearch.sjs";
|
||||
|
||||
let engine;
|
||||
let extension;
|
||||
let oldDefaultEngine;
|
||||
|
||||
add_task(async function setup() {
|
||||
await Services.search.init();
|
||||
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
extension = await SearchTestUtils.installSearchExtension({
|
||||
name: ENGINE_NAME,
|
||||
search_url: ENGINE_URL,
|
||||
search_url_get_params: "test={searchTerms}",
|
||||
});
|
||||
|
||||
let engine = await Services.search.getEngineByName(ENGINE_NAME);
|
||||
engine = await Services.search.getEngineByName(ENGINE_NAME);
|
||||
ok(engine, "Got a search engine");
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
oldDefaultEngine = await Services.search.getDefault();
|
||||
await Services.search.setDefault(engine);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
});
|
||||
});
|
||||
|
||||
async function openNewSearchTab(event_args, expect_new_window = false) {
|
||||
|
@ -174,3 +174,12 @@ add_task(async function test_whereToOpenLink() {
|
|||
// cleanup
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
// We can't do the unload within registerCleanupFunction as that's too late for
|
||||
// the test to be happy. Do it into a cleanup "test" here instead.
|
||||
add_task(async function cleanup() {
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
|
||||
await extension.unload();
|
||||
});
|
||||
|
|
|
@ -6,13 +6,17 @@
|
|||
add_task(async function setup() {
|
||||
await gCUITestUtils.addSearchBar();
|
||||
|
||||
await SearchTestUtils.installSearchExtension();
|
||||
const engine = await Services.search.addEngineWithDetails("dummy", {
|
||||
method: "GET",
|
||||
template: "https://example.com/?q={searchTerms}",
|
||||
});
|
||||
|
||||
const defaultEngine = Services.search.defaultEngine;
|
||||
Services.search.defaultEngine = Services.search.getEngineByName("Example");
|
||||
Services.search.defaultEngine = engine;
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
Services.search.defaultEngine = defaultEngine;
|
||||
await Services.search.removeEngine(engine);
|
||||
gCUITestUtils.removeSearchBar();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,13 +12,16 @@ add_task(async function setup() {
|
|||
// Create two new search engines. Mark one as the default engine, so
|
||||
// the test don't crash. We need to engines for this test as the searchbar
|
||||
// in content doesn't display the default search engine among the one-off engines.
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch",
|
||||
keyword: "mozalias",
|
||||
await Services.search.addEngineWithDetails("MozSearch", {
|
||||
alias: "mozalias",
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch2",
|
||||
keyword: "mozalias2",
|
||||
|
||||
await Services.search.addEngineWithDetails("MozSearch2", {
|
||||
alias: "mozalias2",
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
|
||||
// Make the first engine the default search engine.
|
||||
|
@ -40,6 +43,8 @@ add_task(async function setup() {
|
|||
// Make sure to restore the engine once we're done.
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.setDefault(originalEngine);
|
||||
await Services.search.removeEngine(engineDefault);
|
||||
await Services.search.removeEngine(engineOneOff);
|
||||
await PlacesUtils.history.clear();
|
||||
Services.telemetry.setEventRecordingEnabled("navigation", false);
|
||||
Services.telemetry.canRecordExtended = oldCanRecord;
|
||||
|
@ -70,7 +75,7 @@ add_task(async function test_abouthome_activitystream_simpleQuery() {
|
|||
info("Trigger a simple search, just test + enter.");
|
||||
let p = BrowserTestUtils.browserStopped(
|
||||
tab.linkedBrowser,
|
||||
"https://example.com/?q=test+query"
|
||||
"http://example.com/?q=test+query"
|
||||
);
|
||||
await typeInSearchField(
|
||||
tab.linkedBrowser,
|
||||
|
|
|
@ -8,13 +8,16 @@ add_task(async function setup() {
|
|||
// Create two new search engines. Mark one as the default engine, so
|
||||
// the test don't crash. We need to engines for this test as the searchbar
|
||||
// in content doesn't display the default search engine among the one-off engines.
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch",
|
||||
keyword: "mozalias",
|
||||
await Services.search.addEngineWithDetails("MozSearch", {
|
||||
alias: "mozalias",
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch2",
|
||||
keyword: "mozalias2",
|
||||
|
||||
await Services.search.addEngineWithDetails("MozSearch2", {
|
||||
alias: "mozalias2",
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
|
||||
// Make the first engine the default search engine.
|
||||
|
@ -42,6 +45,8 @@ add_task(async function setup() {
|
|||
// Make sure to restore the engine once we're done.
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.setDefault(originalEngine);
|
||||
await Services.search.removeEngine(engineDefault);
|
||||
await Services.search.removeEngine(engineOneOff);
|
||||
await PlacesUtils.history.clear();
|
||||
Services.telemetry.setEventRecordingEnabled("navigation", false);
|
||||
Services.telemetry.canRecordExtended = oldCanRecord;
|
||||
|
|
|
@ -79,13 +79,16 @@ add_task(async function setup() {
|
|||
// Create two new search engines. Mark one as the default engine, so
|
||||
// the test don't crash. We need to engines for this test as the searchbar
|
||||
// doesn't display the default search engine among the one-off engines.
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch",
|
||||
keyword: "mozalias",
|
||||
await Services.search.addEngineWithDetails("MozSearch", {
|
||||
alias: "mozalias",
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch2",
|
||||
keyword: "mozalias2",
|
||||
|
||||
await Services.search.addEngineWithDetails("MozSearch2", {
|
||||
alias: "mozalias2",
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
|
||||
// Make the first engine the default search engine.
|
||||
|
@ -108,6 +111,8 @@ add_task(async function setup() {
|
|||
registerCleanupFunction(async function() {
|
||||
Services.telemetry.canRecordExtended = oldCanRecord;
|
||||
await Services.search.setDefault(originalEngine);
|
||||
await Services.search.removeEngine(engineDefault);
|
||||
await Services.search.removeEngine(engineOneOff);
|
||||
Services.telemetry.setEventRecordingEnabled("navigation", false);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -65,6 +65,9 @@ async function waitForIdle() {
|
|||
}
|
||||
}
|
||||
|
||||
let extension;
|
||||
let currentEngineName;
|
||||
|
||||
SearchTestUtils.init(this);
|
||||
UrlbarTestUtils.init(this);
|
||||
|
||||
|
@ -79,9 +82,9 @@ add_task(async function setup() {
|
|||
Services.telemetry.canRecordExtended = true;
|
||||
Services.prefs.setBoolPref("browser.search.log", true);
|
||||
|
||||
let currentEngineName = (await Services.search.getDefault()).name;
|
||||
currentEngineName = (await Services.search.getDefault()).name;
|
||||
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
extension = await SearchTestUtils.installSearchExtension({
|
||||
search_url: getPageUrl(true),
|
||||
search_url_get_params: "s={searchTerms}&abc=ff",
|
||||
suggest_url:
|
||||
|
@ -100,9 +103,6 @@ add_task(async function setup() {
|
|||
SearchSERPTelemetry.overrideSearchTelemetryForTests();
|
||||
Services.telemetry.canRecordExtended = oldCanRecord;
|
||||
Services.telemetry.clearScalars();
|
||||
await Services.search.setDefault(
|
||||
Services.search.getEngineByName(currentEngineName)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -326,3 +326,11 @@ add_task(async function test_source_webextension() {
|
|||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function cleanup() {
|
||||
await Services.search.setDefault(
|
||||
Services.search.getEngineByName(currentEngineName)
|
||||
);
|
||||
// Extension must be unloaded before registerCleanupFunction is called.
|
||||
await extension.unload();
|
||||
});
|
||||
|
|
|
@ -65,6 +65,9 @@ async function waitForIdle() {
|
|||
}
|
||||
}
|
||||
|
||||
let extension;
|
||||
let currentEngineName;
|
||||
|
||||
SearchTestUtils.init(this);
|
||||
UrlbarTestUtils.init(this);
|
||||
|
||||
|
@ -84,9 +87,9 @@ add_task(async function setup() {
|
|||
Services.telemetry.canRecordExtended = true;
|
||||
Services.prefs.setBoolPref("browser.search.log", true);
|
||||
|
||||
let currentEngineName = (await Services.search.getDefault()).name;
|
||||
currentEngineName = (await Services.search.getDefault()).name;
|
||||
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
extension = await SearchTestUtils.installSearchExtension({
|
||||
search_url: getPageUrl(true),
|
||||
search_url_get_params: "s={searchTerms}&abc=ff",
|
||||
suggest_url:
|
||||
|
@ -105,9 +108,6 @@ add_task(async function setup() {
|
|||
SearchSERPTelemetry.overrideSearchTelemetryForTests();
|
||||
Services.telemetry.canRecordExtended = oldCanRecord;
|
||||
Services.telemetry.clearScalars();
|
||||
await Services.search.setDefault(
|
||||
Services.search.getEngineByName(currentEngineName)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -228,3 +228,11 @@ add_task(async function test_go_back() {
|
|||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function cleanup() {
|
||||
await Services.search.setDefault(
|
||||
Services.search.getEngineByName(currentEngineName)
|
||||
);
|
||||
// Extension must be unloaded before registerCleanupFunction is called.
|
||||
await extension.unload();
|
||||
});
|
||||
|
|
|
@ -14,7 +14,20 @@ add_task(async function setup() {
|
|||
|
||||
win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
|
||||
// Create an engine to use for the test.
|
||||
await Services.search.addEngineWithDetails("MozSearch1", {
|
||||
alias: "mozalias",
|
||||
method: "GET",
|
||||
template: "https://example.com/?q={searchTerms}",
|
||||
});
|
||||
|
||||
let originalEngine = await Services.search.getDefault();
|
||||
let engineDefault = Services.search.getEngineByName("MozSearch1");
|
||||
await Services.search.setDefault(engineDefault);
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.setDefault(originalEngine);
|
||||
await Services.search.removeEngine(engineDefault);
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
gCUITestUtils.removeSearchBar();
|
||||
});
|
||||
|
|
|
@ -42,14 +42,16 @@ add_task(async function setup() {
|
|||
// Create two new search engines. Mark one as the default engine, so
|
||||
// the test don't crash. We need to engines for this test as the searchbar
|
||||
// doesn't display the default search engine among the one-off engines.
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch1",
|
||||
keyword: "mozalias",
|
||||
await Services.search.addEngineWithDetails("MozSearch1", {
|
||||
alias: "mozalias",
|
||||
method: "GET",
|
||||
template: templateNormal + "{searchTerms}",
|
||||
});
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch2",
|
||||
keyword: "mozalias2",
|
||||
search_url_get_params: "query={searchTerms}",
|
||||
|
||||
await Services.search.addEngineWithDetails("MozSearch2", {
|
||||
alias: "mozalias2",
|
||||
method: "GET",
|
||||
template: templatePrivate + "{searchTerms}",
|
||||
});
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
|
@ -65,10 +67,14 @@ add_task(async function setup() {
|
|||
let engineDefault = Services.search.getEngineByName("MozSearch1");
|
||||
await Services.search.setDefault(engineDefault);
|
||||
|
||||
let engineOneOff = Services.search.getEngineByName("MozSearch2");
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
gCUITestUtils.removeSearchBar();
|
||||
await Services.search.setDefault(originalEngine);
|
||||
await Services.search.setDefaultPrivate(originalPrivateEngine);
|
||||
await Services.search.removeEngine(engineDefault);
|
||||
await Services.search.removeEngine(engineOneOff);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -8,13 +8,17 @@
|
|||
add_task(async function setup() {
|
||||
await gCUITestUtils.addSearchBar();
|
||||
|
||||
await SearchTestUtils.installSearchExtension();
|
||||
const engine = await Services.search.addEngineWithDetails("dummy", {
|
||||
method: "GET",
|
||||
template: "https://example.com/?q={searchTerms}",
|
||||
});
|
||||
|
||||
const defaultEngine = Services.search.defaultEngine;
|
||||
Services.search.defaultEngine = Services.search.getEngineByName("Example");
|
||||
Services.search.defaultEngine = engine;
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
Services.search.defaultEngine = defaultEngine;
|
||||
await Services.search.removeEngine(engine);
|
||||
gCUITestUtils.removeSearchBar();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -542,18 +542,19 @@ add_task(async function pasteAndGo_url() {
|
|||
|
||||
add_task(async function pasteAndGo_nonURL() {
|
||||
// Add a mock engine so we don't hit the network loading the SERP.
|
||||
await SearchTestUtils.installSearchExtension();
|
||||
|
||||
let engine = Services.search.getEngineByName("Example");
|
||||
let engine = await Services.search.addEngineWithDetails("Test", {
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
Services.search.setDefault(engine);
|
||||
|
||||
await doPasteAndGoTest(
|
||||
"pasteAndGo_nonURL",
|
||||
"https://example.com/?q=pasteAndGo_nonURL"
|
||||
"http://example.com/?search=pasteAndGo_nonURL"
|
||||
);
|
||||
|
||||
Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
|
||||
async function doPasteAndGoTest(searchString, expectedURL) {
|
||||
|
|
|
@ -14,19 +14,24 @@ add_task(async function setup() {
|
|||
],
|
||||
});
|
||||
|
||||
await SearchTestUtils.installSearchExtension({ name: "MozSearch" });
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearchPrivate",
|
||||
search_url: "https://example.com/private",
|
||||
const engine = await Services.search.addEngineWithDetails("MozSearch", {
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
|
||||
let originalEngine = await Services.search.getDefault();
|
||||
await Services.search.setDefault(
|
||||
Services.search.getEngineByName("MozSearch")
|
||||
const engine2 = await Services.search.addEngineWithDetails(
|
||||
"MozSearchPrivate",
|
||||
{
|
||||
method: "GET",
|
||||
template: "http://example.com/private?q={searchTerms}",
|
||||
}
|
||||
);
|
||||
let originalEngine = await Services.search.getDefault();
|
||||
await Services.search.setDefault(engine);
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.setDefault(originalEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
await Services.search.removeEngine(engine2);
|
||||
await PlacesUtils.history.clear();
|
||||
await UrlbarTestUtils.formHistory.clear();
|
||||
});
|
||||
|
@ -89,7 +94,7 @@ add_task(async function test_search_normal_window() {
|
|||
}
|
||||
});
|
||||
|
||||
await testSearch(window, "MozSearch", "https://example.com/");
|
||||
await testSearch(window, "MozSearch", "http://example.com/");
|
||||
});
|
||||
|
||||
add_task(async function test_search_private_window_no_separate_default() {
|
||||
|
@ -99,7 +104,7 @@ add_task(async function test_search_private_window_no_separate_default() {
|
|||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
||||
await testSearch(win, "MozSearch", "https://example.com/");
|
||||
await testSearch(win, "MozSearch", "http://example.com/");
|
||||
});
|
||||
|
||||
add_task(async function test_search_private_window() {
|
||||
|
@ -118,5 +123,5 @@ add_task(async function test_search_private_window() {
|
|||
|
||||
const win = await BrowserTestUtils.openNewBrowserWindow({ private: true });
|
||||
|
||||
await testSearch(win, "MozSearchPrivate", "https://example.com/private");
|
||||
await testSearch(win, "MozSearchPrivate", "http://example.com/private");
|
||||
});
|
||||
|
|
|
@ -7,8 +7,21 @@
|
|||
*/
|
||||
|
||||
add_task(async function() {
|
||||
await SearchTestUtils.installSearchExtension({ keyword: "moz" });
|
||||
let engine = Services.search.getEngineByName("Example");
|
||||
const ICON_URI =
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAA" +
|
||||
"CQkWg2AAABGklEQVQoz2NgGB6AnZ1dUlJSXl4eSDIyMhLW4Ovr%2B%2Fr168uXL69Zs4YoG%2BL" +
|
||||
"i4i5dusTExMTGxsbNzd3f37937976%2BnpmZmagbHR09J49e5YvX66kpATVEBYW9ubNm2nTphkb" +
|
||||
"G7e2tp44cQLIuHfvXm5urpaWFlDKysqqu7v73LlzECMYIiIiHj58mJCQoKKicvXq1bS0NKBgW1v" +
|
||||
"bjh074uPjgeqAXE1NzSdPnvDz84M0AEUvXLgAsW379u1z5swBen3jxo2zZ892cHB4%2BvQp0KlA" +
|
||||
"fwI1cHJyghQFBwfv2rULokFXV%2FfixYu7d%2B8GGqGgoMDKyrpu3br9%2B%2FcDuXl5eVA%2FA" +
|
||||
"EWBfoWHAdAYoNuAYQ0XAeoUERFhGDYAAPoUaT2dfWJuAAAAAElFTkSuQmCC";
|
||||
await Services.search.addEngineWithDetails("MozSearch", {
|
||||
iconURL: ICON_URI,
|
||||
alias: "moz",
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
let originalEngine = await Services.search.getDefault();
|
||||
await Services.search.setDefault(engine);
|
||||
|
||||
|
@ -24,6 +37,7 @@ add_task(async function() {
|
|||
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.setDefault(originalEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
try {
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
} catch (ex) {
|
||||
|
@ -57,7 +71,7 @@ add_task(async function() {
|
|||
|
||||
Assert.equal(
|
||||
gBrowser.selectedBrowser.currentURI.spec,
|
||||
"https://example.com/?q=open+a+search",
|
||||
"http://example.com/?q=open+a+search",
|
||||
"Should have loaded the correct page"
|
||||
);
|
||||
});
|
||||
|
|
|
@ -44,7 +44,14 @@ add_task(async function origin() {
|
|||
add_task(async function tokenAlias() {
|
||||
// We have built-in engine aliases that may conflict with the one we choose
|
||||
// here in terms of autofill, so be careful and choose a weird alias.
|
||||
await SearchTestUtils.installSearchExtension({ keyword: "@__example" });
|
||||
await Services.search.addEngineWithDetails("Test", {
|
||||
alias: "@__example",
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
registerCleanupFunction(async function() {
|
||||
let engine = Services.search.getEngineByName("Test");
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
|
||||
// Do an initial search that triggers autofill so that the placeholder has an
|
||||
// initial value.
|
||||
|
@ -170,14 +177,18 @@ add_task(async function noMatch2() {
|
|||
|
||||
add_task(async function clear_placeholder_for_keyword_or_alias() {
|
||||
info("Clear the autofill placeholder if a keyword is typed");
|
||||
await PlacesTestUtils.addVisits("https://example.com/");
|
||||
await PlacesTestUtils.addVisits("http://example.com/");
|
||||
await PlacesUtils.keywords.insert({
|
||||
keyword: "ex",
|
||||
url: "https://somekeyword.com/",
|
||||
url: "http://somekeyword.com/",
|
||||
});
|
||||
let engine = await Services.search.addEngineWithDetails("AutofillTest", {
|
||||
alias: "exam",
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
await SearchTestUtils.installSearchExtension({ keyword: "exam" });
|
||||
registerCleanupFunction(async function() {
|
||||
await PlacesUtils.keywords.remove("ex");
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
|
||||
// Do an initial search that triggers autofill so that the placeholder has an
|
||||
|
|
|
@ -176,7 +176,14 @@ add_task(async function urlPort() {
|
|||
});
|
||||
|
||||
add_task(async function tokenAlias() {
|
||||
await SearchTestUtils.installSearchExtension({ keyword: "@example" });
|
||||
await Services.search.addEngineWithDetails("Test", {
|
||||
alias: "@example",
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
registerCleanupFunction(async function() {
|
||||
let engine = Services.search.getEngineByName("Test");
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
value: "@ExA",
|
||||
|
|
|
@ -99,7 +99,14 @@ add_task(async function url() {
|
|||
add_task(async function tokenAlias() {
|
||||
// We have built-in engine aliases that may conflict with the one we choose
|
||||
// here in terms of autofill, so be careful and choose a weird alias.
|
||||
await SearchTestUtils.installSearchExtension({ keyword: "@__example" });
|
||||
await Services.search.addEngineWithDetails("Test", {
|
||||
alias: "@__example",
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
registerCleanupFunction(async function() {
|
||||
let engine = Services.search.getEngineByName("Test");
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
// all lowercase
|
||||
await typeAndCheck([
|
||||
["@", "@"],
|
||||
|
|
|
@ -100,9 +100,11 @@ add_task(
|
|||
let suggestOpenPages = Preferences.get("browser.urlbar.suggest.openpage");
|
||||
Preferences.set("browser.urlbar.suggest.openpage", false);
|
||||
|
||||
await SearchTestUtils.installSearchExtension();
|
||||
|
||||
let engine = Services.search.getEngineByName("Example");
|
||||
await Services.search.addEngineWithDetails("MozSearch", {
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
let originalEngine = await Services.search.getDefault();
|
||||
await Services.search.setDefault(engine);
|
||||
|
||||
|
@ -112,6 +114,10 @@ add_task(
|
|||
Preferences.set("browser.urlbar.suggest.openpage", suggestOpenPages);
|
||||
|
||||
await Services.search.setDefault(originalEngine);
|
||||
let mozSearchEngine = Services.search.getEngineByName("MozSearch");
|
||||
if (mozSearchEngine) {
|
||||
await Services.search.removeEngine(mozSearchEngine);
|
||||
}
|
||||
}
|
||||
registerCleanupFunction(cleanup);
|
||||
|
||||
|
@ -124,7 +130,7 @@ add_task(
|
|||
await BrowserTestUtils.browserLoaded(
|
||||
gBrowser.selectedTab.linkedBrowser,
|
||||
false,
|
||||
"https://example.com/?q=ex"
|
||||
"http://example.com/?q=ex"
|
||||
);
|
||||
await cleanup();
|
||||
})
|
||||
|
|
|
@ -11,9 +11,12 @@ const TEST_URL = "data:text/html,a test page";
|
|||
|
||||
add_task(async function test_setup() {
|
||||
// Stop search-engine loads from hitting the network.
|
||||
await SearchTestUtils.installSearchExtension();
|
||||
await Services.search.addEngineWithDetails("MozSearch", {
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
let originalEngine = await Services.search.getDefault();
|
||||
let engine = Services.search.getEngineByName("Example");
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
await Services.search.setDefault(engine);
|
||||
|
||||
registerCleanupFunction(async function cleanup() {
|
||||
|
@ -21,6 +24,7 @@ add_task(async function test_setup() {
|
|||
BrowserTestUtils.removeTab(gBrowser.tabs[gBrowser.tabs.length - 1]);
|
||||
}
|
||||
await Services.search.setDefault(originalEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -89,14 +93,14 @@ add_task(async function checkDragText() {
|
|||
await BrowserTestUtils.withNewTab(TEST_URL, async browser => {
|
||||
info("Check dragging multi word text to the urlbar");
|
||||
const TEXT = "Firefox is awesome";
|
||||
const TEXT_URL = "https://example.com/?q=Firefox+is+awesome";
|
||||
const TEXT_URL = "http://example.com/?q=Firefox+is+awesome";
|
||||
let promiseLoad = BrowserTestUtils.browserLoaded(browser, false, TEXT_URL);
|
||||
simulateURLBarDrop({ type: "text/plain", data: TEXT });
|
||||
await promiseLoad;
|
||||
|
||||
info("Check dragging single word text to the urlbar");
|
||||
const WORD = "Firefox";
|
||||
const WORD_URL = "https://example.com/?q=Firefox";
|
||||
const WORD_URL = "http://example.com/?q=Firefox";
|
||||
promiseLoad = BrowserTestUtils.browserLoaded(browser, false, WORD_URL);
|
||||
simulateURLBarDrop({ type: "text/plain", data: WORD });
|
||||
await promiseLoad;
|
||||
|
|
|
@ -28,20 +28,29 @@ add_task(async function() {
|
|||
});
|
||||
|
||||
sandbox = sinon.createSandbox();
|
||||
await SearchTestUtils.installSearchExtension();
|
||||
await SearchTestUtils.installSearchExtension({ name: "Example2" });
|
||||
|
||||
let engine = await Services.search.addEngineWithDetails("MozSearch", {
|
||||
alias: "moz",
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
let engine2 = await Services.search.addEngineWithDetails("MozSearch2", {
|
||||
alias: "@moz",
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
let bm = await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: "https://example.com/?q=%s",
|
||||
url: "http://example.com/?q=%s",
|
||||
title: "test",
|
||||
});
|
||||
await PlacesUtils.keywords.insert({
|
||||
keyword: "keyword",
|
||||
url: "https://example.com/?q=%s",
|
||||
url: "http://example.com/?q=%s",
|
||||
});
|
||||
registerCleanupFunction(async () => {
|
||||
sandbox.restore();
|
||||
await Services.search.removeEngine(engine);
|
||||
await Services.search.removeEngine(engine2);
|
||||
await PlacesUtils.bookmarks.remove(bm);
|
||||
await UrlbarTestUtils.formHistory.clear();
|
||||
});
|
||||
|
|
|
@ -41,17 +41,16 @@ add_task(async function() {
|
|||
url: "http://example.com/",
|
||||
parentGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
});
|
||||
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "Test",
|
||||
keyword: "@test",
|
||||
let engine = await Services.search.addEngineWithDetails("Test", {
|
||||
alias: "@test",
|
||||
template: `http://example.com/?search={searchTerms}`,
|
||||
});
|
||||
|
||||
let originalEngine = await Services.search.getDefault();
|
||||
await Services.search.setDefault(Services.search.getEngineByName("Test"));
|
||||
await Services.search.setDefault(engine);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
await Services.search.setDefault(originalEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
await PlacesUtils.bookmarks.remove(bm);
|
||||
await PlacesUtils.history.clear();
|
||||
});
|
||||
|
|
|
@ -229,11 +229,12 @@ async function assertState(
|
|||
|
||||
add_task(async function init() {
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: TEST_DEFAULT_ENGINE_NAME,
|
||||
keyword: "@test",
|
||||
});
|
||||
let engine = Services.search.getEngineByName(TEST_DEFAULT_ENGINE_NAME);
|
||||
let engine = await Services.search.addEngineWithDetails(
|
||||
TEST_DEFAULT_ENGINE_NAME,
|
||||
{
|
||||
template: `http://example.com/?search={searchTerms}`,
|
||||
}
|
||||
);
|
||||
await Services.search.setDefault(engine);
|
||||
await Services.search.moveEngine(engine, 0);
|
||||
|
||||
|
@ -248,6 +249,7 @@ add_task(async function init() {
|
|||
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
await PlacesUtils.history.clear();
|
||||
await PlacesUtils.keywords.remove(KEYWORD);
|
||||
});
|
||||
|
|
|
@ -125,15 +125,18 @@ add_task(async function init() {
|
|||
});
|
||||
|
||||
// Add a mock engine so we don't hit the network loading the SERP.
|
||||
await SearchTestUtils.installSearchExtension();
|
||||
let engine = await Services.search.addEngineWithDetails("Test", {
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
await Services.search.setDefault(Services.search.getEngineByName("Example"));
|
||||
Services.search.setDefault(engine);
|
||||
|
||||
await UrlbarQuickSuggest.init();
|
||||
await UrlbarQuickSuggest._processSuggestionsJSON(TEST_DATA);
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
await PlacesUtils.history.clear();
|
||||
await UrlbarTestUtils.formHistory.clear();
|
||||
});
|
||||
|
|
|
@ -5,19 +5,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
FormHistory: "resource://gre/modules/FormHistory.jsm",
|
||||
});
|
||||
|
||||
add_task(async function setup() {
|
||||
await SearchTestUtils.installSearchExtension();
|
||||
|
||||
let engine = Services.search.getEngineByName("Example");
|
||||
let originalEngine = await Services.search.getDefault();
|
||||
await Services.search.setDefault(engine);
|
||||
await Services.search.moveEngine(engine, 0);
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.setDefault(originalEngine);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_remove_history() {
|
||||
const TEST_URL = "http://remove.me/from_urlbar/";
|
||||
await PlacesTestUtils.addVisits(TEST_URL);
|
||||
|
@ -77,6 +64,14 @@ add_task(async function test_remove_form_history() {
|
|||
],
|
||||
});
|
||||
|
||||
await Services.search.addEngineWithDetails("test", {
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
let engine = Services.search.getEngineByName("test");
|
||||
let originalEngine = await Services.search.getDefault();
|
||||
await Services.search.setDefault(engine);
|
||||
|
||||
let formHistoryValue = "foobar";
|
||||
await UrlbarTestUtils.formHistory.add([formHistoryValue]);
|
||||
|
||||
|
@ -144,6 +139,8 @@ add_task(async function test_remove_form_history() {
|
|||
);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await Services.search.setDefault(originalEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
|
||||
// We shouldn't be able to remove a bookmark item.
|
||||
|
@ -189,8 +186,17 @@ add_task(async function test_searchMode_removeRestyledHistory() {
|
|||
],
|
||||
});
|
||||
|
||||
let engine = await Services.search.addEngineWithDetails("test", {
|
||||
method: "GET",
|
||||
template: "http://example.com/",
|
||||
searchGetParams: "q={searchTerms}",
|
||||
});
|
||||
let originalEngine = await Services.search.getDefault();
|
||||
await Services.search.setDefault(engine);
|
||||
await Services.search.moveEngine(engine, 0);
|
||||
|
||||
let query = "ciao";
|
||||
let url = `https://example.com/?q=${query}bar`;
|
||||
let url = `http://example.com/?q=${query}bar`;
|
||||
await PlacesTestUtils.addVisits(url);
|
||||
|
||||
await BrowserTestUtils.withNewTab("about:robots", async function(browser) {
|
||||
|
@ -222,4 +228,6 @@ add_task(async function test_searchMode_removeRestyledHistory() {
|
|||
});
|
||||
await PlacesUtils.history.clear();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await Services.search.setDefault(originalEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
|
|
|
@ -13,12 +13,12 @@ add_task(async function init() {
|
|||
// fired.
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
keyword: ALIAS,
|
||||
aliasEngine = await Services.search.addEngineWithDetails("Test", {
|
||||
alias: ALIAS,
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
aliasEngine = Services.search.getEngineByName("Example");
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.removeEngine(aliasEngine);
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
gURLBar.handleRevert();
|
||||
});
|
||||
|
|
|
@ -16,14 +16,16 @@ const { SearchSuggestionController } = ChromeUtils.import(
|
|||
let gEngine;
|
||||
|
||||
add_task(async function setup() {
|
||||
await SearchTestUtils.installSearchExtension();
|
||||
gEngine = Services.search.getEngineByName("Example");
|
||||
gEngine = await Services.search.addEngineWithDetails("TestLimit", {
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
await Services.search.setDefault(gEngine);
|
||||
await UrlbarTestUtils.formHistory.clear();
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(gEngine);
|
||||
await UrlbarTestUtils.formHistory.clear();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -25,12 +25,13 @@ add_task(async function setup() {
|
|||
defaultEngine.alias = "@default";
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
Services.search.setDefault(defaultEngine);
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
keyword: ALIAS,
|
||||
aliasEngine = await Services.search.addEngineWithDetails("Test", {
|
||||
alias: ALIAS,
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
aliasEngine = Services.search.getEngineByName("Example");
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.removeEngine(aliasEngine);
|
||||
Services.search.setDefault(oldDefaultEngine);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -8,20 +8,27 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const DEFAULT_ENGINE_NAME = "Test";
|
||||
|
||||
add_task(async function setup() {
|
||||
for (let i = 0; i < 5; i++) {
|
||||
await PlacesTestUtils.addVisits([{ uri: "http://example.com/" }]);
|
||||
}
|
||||
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
await SearchTestUtils.installSearchExtension();
|
||||
let defaultEngine = Services.search.getEngineByName("Example");
|
||||
let defaultEngine = await Services.search.addEngineWithDetails(
|
||||
DEFAULT_ENGINE_NAME,
|
||||
{
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
}
|
||||
);
|
||||
await Services.search.setDefault(defaultEngine);
|
||||
await Services.search.moveEngine(defaultEngine, 0);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
await PlacesUtils.history.clear();
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(defaultEngine);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -10,8 +10,9 @@
|
|||
// Tests that we exit search mode in the active tab when the search mode engine
|
||||
// is removed.
|
||||
add_task(async function activeTab() {
|
||||
let extension = await SearchTestUtils.installSearchExtension({}, true);
|
||||
let engine = Services.search.getEngineByName("Example");
|
||||
let engine = await Services.search.addEngineWithDetails("Test", {
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
await Services.search.moveEngine(engine, 0);
|
||||
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
|
@ -24,7 +25,7 @@ add_task(async function activeTab() {
|
|||
engineName: engine.name,
|
||||
entry: "oneoff",
|
||||
});
|
||||
await extension.unload();
|
||||
await Services.search.removeEngine(engine);
|
||||
// Check that we are no longer in search mode.
|
||||
await UrlbarTestUtils.assertSearchMode(window, null);
|
||||
});
|
||||
|
@ -32,8 +33,9 @@ add_task(async function activeTab() {
|
|||
// Tests that we exit search mode in a background tab when the search mode
|
||||
// engine is removed.
|
||||
add_task(async function backgroundTab() {
|
||||
let extension = await SearchTestUtils.installSearchExtension({}, true);
|
||||
let engine = Services.search.getEngineByName("Example");
|
||||
let engine = await Services.search.addEngineWithDetails("Test", {
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
await Services.search.moveEngine(engine, 0);
|
||||
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
|
@ -56,7 +58,7 @@ add_task(async function backgroundTab() {
|
|||
await BrowserTestUtils.switchTab(gBrowser, tab2);
|
||||
// tab2 shouldn't be in search mode.
|
||||
await UrlbarTestUtils.assertSearchMode(window, null);
|
||||
await extension.unload();
|
||||
await Services.search.removeEngine(engine);
|
||||
|
||||
// tab1 should have exited search mode.
|
||||
await BrowserTestUtils.switchTab(gBrowser, tab1);
|
||||
|
@ -67,8 +69,9 @@ add_task(async function backgroundTab() {
|
|||
// Tests that we exit search mode in a background window when the search mode
|
||||
// engine is removed.
|
||||
add_task(async function backgroundWindow() {
|
||||
let extension = await SearchTestUtils.installSearchExtension({}, true);
|
||||
let engine = Services.search.getEngineByName("Example");
|
||||
let engine = await Services.search.addEngineWithDetails("Test", {
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
await Services.search.moveEngine(engine, 0);
|
||||
|
||||
let win1 = window;
|
||||
|
@ -91,7 +94,7 @@ add_task(async function backgroundWindow() {
|
|||
win2.focus();
|
||||
// win2 shouldn't be in search mode.
|
||||
await UrlbarTestUtils.assertSearchMode(win2, null);
|
||||
await extension.unload();
|
||||
await Services.search.removeEngine(engine);
|
||||
|
||||
// win1 should not be in search mode.
|
||||
win1.focus();
|
||||
|
|
|
@ -30,10 +30,9 @@ add_task(async function setup() {
|
|||
// Note that the result domain is subdomain.example.ca. We still expect to
|
||||
// match with example.com results because we ignore subdomains and the public
|
||||
// suffix in this check.
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
search_url: "https://subdomain.example.ca/",
|
||||
let engine = await Services.search.addEngineWithDetails("Test", {
|
||||
template: `http://subdomain.example.ca/?search={searchTerms}`,
|
||||
});
|
||||
let engine = Services.search.getEngineByName("Example");
|
||||
await Services.search.setDefault(engine);
|
||||
await Services.search.moveEngine(engine, 0);
|
||||
|
||||
|
@ -47,7 +46,7 @@ add_task(async function setup() {
|
|||
{
|
||||
type: "tab",
|
||||
title: "Test Remote",
|
||||
url: "https://example.com",
|
||||
url: "http://example.com",
|
||||
icon: UrlbarUtils.ICON.DEFAULT,
|
||||
client: "7cqCr77ptzX3",
|
||||
lastUsed: 1452124677,
|
||||
|
@ -55,7 +54,7 @@ add_task(async function setup() {
|
|||
{
|
||||
type: "tab",
|
||||
title: "Test Remote 2",
|
||||
url: "https://example-2.com",
|
||||
url: "http://example-2.com",
|
||||
icon: UrlbarUtils.ICON.DEFAULT,
|
||||
client: "7cqCr77ptzX3",
|
||||
lastUsed: 1452124677,
|
||||
|
@ -96,6 +95,7 @@ add_task(async function setup() {
|
|||
weaveXPCService.ready = oldWeaveServiceReady;
|
||||
SyncedTabs._internal = originalSyncedTabsInternal;
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
await PlacesUtils.history.clear();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,10 +13,13 @@ add_task(async function setup() {
|
|||
|
||||
// Add a new mock default engine so we don't hit the network.
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
await SearchTestUtils.installSearchExtension({ name: "Test" });
|
||||
await Services.search.setDefault(Services.search.getEngineByName("Test"));
|
||||
let engine = await Services.search.addEngineWithDetails("Test", {
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
await Services.search.setDefault(engine);
|
||||
registerCleanupFunction(async () => {
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
|
||||
// Add one bookmark we'll use below.
|
||||
|
@ -216,7 +219,7 @@ add_task(async function remote() {
|
|||
await loadPromise;
|
||||
Assert.equal(
|
||||
gBrowser.currentURI.spec,
|
||||
"https://example.com/?q=remote",
|
||||
"http://example.com/?search=remote",
|
||||
"Engine's SERP should have loaded"
|
||||
);
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
|
||||
const TEST_QUERY = "test string";
|
||||
const DEFAULT_ENGINE_NAME = "Test";
|
||||
const SUGGESTIONS_ENGINE_NAME = "searchSuggestionEngine.xml";
|
||||
|
||||
// These need to have different domains because otherwise new tab and/or
|
||||
|
@ -28,13 +29,18 @@ add_task(async function setup() {
|
|||
);
|
||||
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
await SearchTestUtils.installSearchExtension();
|
||||
defaultEngine = Services.search.getEngineByName("Example");
|
||||
defaultEngine = await Services.search.addEngineWithDetails(
|
||||
DEFAULT_ENGINE_NAME,
|
||||
{
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
}
|
||||
);
|
||||
await Services.search.setDefault(defaultEngine);
|
||||
await Services.search.moveEngine(suggestionsEngine, 0);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(defaultEngine);
|
||||
});
|
||||
|
||||
// Set our top sites.
|
||||
|
|
|
@ -7,12 +7,22 @@
|
|||
* Tests one-off search button behavior with search mode.
|
||||
*/
|
||||
|
||||
const TEST_ENGINE_NAME = "test engine";
|
||||
const TEST_ENGINE = {
|
||||
name: "test engine",
|
||||
details: {
|
||||
alias: "@test",
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
},
|
||||
};
|
||||
|
||||
add_task(async function setup() {
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: TEST_ENGINE_NAME,
|
||||
keyword: "@test",
|
||||
const engine = await Services.search.addEngineWithDetails(
|
||||
TEST_ENGINE.name,
|
||||
TEST_ENGINE.details
|
||||
);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -36,10 +46,10 @@ add_task(async function test() {
|
|||
|
||||
info("Enter search mode");
|
||||
await UrlbarTestUtils.enterSearchMode(window, {
|
||||
engineName: TEST_ENGINE_NAME,
|
||||
engineName: TEST_ENGINE.name,
|
||||
});
|
||||
await UrlbarTestUtils.assertSearchMode(window, {
|
||||
engineName: TEST_ENGINE_NAME,
|
||||
engineName: TEST_ENGINE.name,
|
||||
entry: "oneoff",
|
||||
});
|
||||
ok(!oneOffs.selectedButton, "There is no selected one-off button");
|
||||
|
|
|
@ -8,14 +8,19 @@
|
|||
"use strict";
|
||||
|
||||
const TEST_ENGINE_NAME = "Test";
|
||||
const TEST_ENGINE_DOMAIN = "example.com";
|
||||
|
||||
add_task(async function setup() {
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: TEST_ENGINE_NAME,
|
||||
keyword: "@test",
|
||||
});
|
||||
let testEngine = await Services.search.addEngineWithDetails(
|
||||
TEST_ENGINE_NAME,
|
||||
{
|
||||
alias: "@test",
|
||||
template: `http://${TEST_ENGINE_DOMAIN}/?search={searchTerms}`,
|
||||
}
|
||||
);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
await Services.search.removeEngine(testEngine);
|
||||
await PlacesUtils.history.clear();
|
||||
});
|
||||
});
|
||||
|
@ -239,13 +244,13 @@ add_task(async function oneOff_alt_downArrow() {
|
|||
// Add some visits to a URL so we have multiple Top Sites.
|
||||
await PlacesUtils.history.clear();
|
||||
for (let i = 0; i < 5; i++) {
|
||||
await PlacesTestUtils.addVisits("https://example.com/");
|
||||
await PlacesTestUtils.addVisits("http://example.com/");
|
||||
}
|
||||
await updateTopSites(
|
||||
sites =>
|
||||
sites &&
|
||||
sites[0]?.searchTopSite &&
|
||||
sites[1]?.url == "https://example.com/",
|
||||
sites[1]?.url == "http://example.com/",
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -414,9 +419,9 @@ add_task(async function fullSearchMode_oneOff_restore_on_down() {
|
|||
info("Add a few visits to top sites");
|
||||
for (let i = 0; i < 5; i++) {
|
||||
await PlacesTestUtils.addVisits([
|
||||
"https://1.example.com/",
|
||||
"https://2.example.com/",
|
||||
"https://3.example.com/",
|
||||
"http://1.example.com/",
|
||||
"http://2.example.com/",
|
||||
"http://3.example.com/",
|
||||
]);
|
||||
}
|
||||
await updateTopSites(sites => sites?.length > 2, false);
|
||||
|
|
|
@ -13,6 +13,7 @@ const MANY_SUGGESTIONS_ENGINE_NAME = "searchSuggestionEngineMany.xml";
|
|||
const MAX_RESULT_COUNT = UrlbarPrefs.get("maxRichResults");
|
||||
|
||||
let suggestionsEngine;
|
||||
let defaultEngine;
|
||||
let expectedFormHistoryResults = [];
|
||||
|
||||
add_task(async function setup() {
|
||||
|
@ -21,13 +22,13 @@ add_task(async function setup() {
|
|||
);
|
||||
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: DEFAULT_ENGINE_NAME,
|
||||
keyword: "@test",
|
||||
});
|
||||
await Services.search.setDefault(
|
||||
Services.search.getEngineByName(DEFAULT_ENGINE_NAME)
|
||||
defaultEngine = await Services.search.addEngineWithDetails(
|
||||
DEFAULT_ENGINE_NAME,
|
||||
{
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
}
|
||||
);
|
||||
await Services.search.setDefault(defaultEngine);
|
||||
await Services.search.moveEngine(suggestionsEngine, 0);
|
||||
|
||||
async function cleanup() {
|
||||
|
@ -62,6 +63,7 @@ add_task(async function setup() {
|
|||
|
||||
registerCleanupFunction(async () => {
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(defaultEngine);
|
||||
await UrlbarTestUtils.formHistory.clear();
|
||||
});
|
||||
|
||||
|
@ -228,7 +230,7 @@ add_task(async function emptySearch_behavior() {
|
|||
source: UrlbarUtils.RESULT_SOURCE.SEARCH,
|
||||
searchParams: {
|
||||
query: " ",
|
||||
engine: DEFAULT_ENGINE_NAME,
|
||||
engine: defaultEngine.name,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -192,13 +192,9 @@ add_task(async function slow_load() {
|
|||
set: [["browser.urlbar.suggest.searches", false]],
|
||||
});
|
||||
const engineName = "Test";
|
||||
let extension = await SearchTestUtils.installSearchExtension(
|
||||
{
|
||||
name: engineName,
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
let engine = await Services.search.addEngineWithDetails(engineName, {
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
const originalTab = gBrowser.selectedTab;
|
||||
const newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
|
||||
|
@ -222,21 +218,17 @@ add_task(async function slow_load() {
|
|||
await UrlbarTestUtils.assertSearchMode(window, null);
|
||||
|
||||
BrowserTestUtils.removeTab(newTab);
|
||||
await Services.search.removeEngine(engine);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await extension.unload();
|
||||
});
|
||||
|
||||
// Tests the same behaviour as slow_load, but in a more reliable way using
|
||||
// non-real-world behaviour.
|
||||
add_task(async function slow_load_guaranteed() {
|
||||
const engineName = "Test";
|
||||
let extension = await SearchTestUtils.installSearchExtension(
|
||||
{
|
||||
name: engineName,
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
let engine = await Services.search.addEngineWithDetails(engineName, {
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
const backgroundTab = BrowserTestUtils.addTab(gBrowser);
|
||||
|
||||
// Simulate a tab that was in search mode, loaded a SERP, then was switched
|
||||
|
@ -254,7 +246,7 @@ add_task(async function slow_load_guaranteed() {
|
|||
await UrlbarTestUtils.assertSearchMode(window, null);
|
||||
|
||||
BrowserTestUtils.removeTab(backgroundTab);
|
||||
await extension.unload();
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
|
||||
// Enters search mode by typing a restriction char with no search string.
|
||||
|
|
|
@ -13,6 +13,8 @@ const serverInfo = {
|
|||
port: 20709, // Must be identical to what is in searchSuggestionEngine2.xml
|
||||
};
|
||||
|
||||
let aliasEngine;
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
|
@ -47,14 +49,16 @@ add_task(async function setup() {
|
|||
await Services.search.moveEngine(engine2, 0);
|
||||
|
||||
// Add an engine with an alias.
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch",
|
||||
keyword: "alias",
|
||||
aliasEngine = await Services.search.addEngineWithDetails("MozSearch", {
|
||||
alias: "alias",
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.setDefaultPrivate(oldDefaultPrivateEngine);
|
||||
await Services.search.removeEngine(aliasEngine);
|
||||
await PlacesUtils.history.clear();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -51,15 +51,16 @@ add_task(async function setup() {
|
|||
await Services.search.moveEngine(engine2, 0);
|
||||
|
||||
// Add an engine with an alias.
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: "MozSearch",
|
||||
keyword: "alias",
|
||||
gAliasEngine = await Services.search.addEngineWithDetails("MozSearch", {
|
||||
alias: "alias",
|
||||
method: "GET",
|
||||
template: "http://example.com/?q={searchTerms}",
|
||||
});
|
||||
gAliasEngine = Services.search.getEngineByName("MozSearch");
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.setDefaultPrivate(oldDefaultPrivateEngine);
|
||||
await Services.search.removeEngine(gAliasEngine);
|
||||
await PlacesUtils.history.clear();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -178,16 +178,18 @@ add_task(async function tabSearchModePreview() {
|
|||
|
||||
add_task(async function tabTabToSearch() {
|
||||
info("Tab past a tab-to-search result after focusing with the keyboard.");
|
||||
await SearchTestUtils.installSearchExtension();
|
||||
|
||||
let engineDomain = "example.com";
|
||||
let testEngine = await Services.search.addEngineWithDetails("Test", {
|
||||
template: `http://${engineDomain}/?search={searchTerms}`,
|
||||
});
|
||||
for (let i = 0; i < 3; i++) {
|
||||
await PlacesTestUtils.addVisits(["https://example.com/"]);
|
||||
await PlacesTestUtils.addVisits([`https://${engineDomain}/`]);
|
||||
}
|
||||
|
||||
// Search for a tab-to-search result.
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
value: "exam",
|
||||
value: engineDomain.slice(0, 4),
|
||||
});
|
||||
await UrlbarTestUtils.promisePopupClose(window);
|
||||
await UrlbarTestUtils.promisePopupOpen(window, () => {
|
||||
|
@ -210,6 +212,7 @@ add_task(async function tabTabToSearch() {
|
|||
await UrlbarTestUtils.assertSearchMode(window, null);
|
||||
});
|
||||
await PlacesUtils.history.clear();
|
||||
await Services.search.removeEngine(testEngine);
|
||||
});
|
||||
|
||||
add_task(async function tabNoSearchStringSearchMode() {
|
||||
|
|
|
@ -27,18 +27,20 @@ add_task(async function setup() {
|
|||
["browser.urlbar.tabToSearch.onboard.interactionsLeft", 0],
|
||||
],
|
||||
});
|
||||
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: TEST_ENGINE_NAME,
|
||||
search_url: `https://${TEST_ENGINE_DOMAIN}/`,
|
||||
});
|
||||
|
||||
let testEngine = await Services.search.addEngineWithDetails(
|
||||
TEST_ENGINE_NAME,
|
||||
{
|
||||
alias: "@test",
|
||||
template: `http://${TEST_ENGINE_DOMAIN}/?search={searchTerms}`,
|
||||
}
|
||||
);
|
||||
for (let i = 0; i < 3; i++) {
|
||||
await PlacesTestUtils.addVisits([`https://${TEST_ENGINE_DOMAIN}/`]);
|
||||
}
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
await PlacesUtils.history.clear();
|
||||
await Services.search.removeEngine(testEngine);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -597,12 +599,11 @@ add_task(async function onboard_multipleEnginesForHostname() {
|
|||
set: [["browser.urlbar.tabToSearch.onboard.interactionsLeft", 3]],
|
||||
});
|
||||
|
||||
let extension = await SearchTestUtils.installSearchExtension(
|
||||
let testEngineMaps = await Services.search.addEngineWithDetails(
|
||||
`${TEST_ENGINE_NAME}Maps`,
|
||||
{
|
||||
name: `${TEST_ENGINE_NAME}Maps`,
|
||||
search_url: `https://${TEST_ENGINE_DOMAIN}/maps/`,
|
||||
},
|
||||
true
|
||||
template: `http://${TEST_ENGINE_DOMAIN}/maps/?search={searchTerms}`,
|
||||
}
|
||||
);
|
||||
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
|
@ -638,7 +639,7 @@ add_task(async function onboard_multipleEnginesForHostname() {
|
|||
"The tab-to-search result is the only onboarding result."
|
||||
);
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => gURLBar.blur());
|
||||
await extension.unload();
|
||||
await Services.search.removeEngine(testEngineMaps);
|
||||
UrlbarPrefs.set("tabToSearch.onboard.interactionsLeft", 3);
|
||||
delete UrlbarProviderTabToSearch.onboardingInteractionAtTime;
|
||||
await SpecialPowers.popPrefEnv();
|
||||
|
@ -652,14 +653,9 @@ add_task(async function extended_unicode_in_engine() {
|
|||
// general-web engine string because Baidu is included in WEB_ENGINE_NAMES.
|
||||
let engineName = "百度";
|
||||
let engineDomain = "example-2.com";
|
||||
let extension = await SearchTestUtils.installSearchExtension(
|
||||
{
|
||||
id: "testunicode",
|
||||
name: engineName,
|
||||
search_url: `https://${engineDomain}/`,
|
||||
},
|
||||
true
|
||||
);
|
||||
let testEngine = await Services.search.addEngineWithDetails(engineName, {
|
||||
template: `http://${engineDomain}/?search={searchTerms}`,
|
||||
});
|
||||
for (let i = 0; i < 3; i++) {
|
||||
await PlacesTestUtils.addVisits([`https://${engineDomain}/`]);
|
||||
}
|
||||
|
@ -692,5 +688,5 @@ add_task(async function extended_unicode_in_engine() {
|
|||
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => gURLBar.blur());
|
||||
await PlacesUtils.history.clear();
|
||||
await extension.unload();
|
||||
await Services.search.removeEngine(testEngine);
|
||||
});
|
||||
|
|
|
@ -11,9 +11,11 @@ add_task(async function() {
|
|||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.urlbar.suggest.searches", true]],
|
||||
});
|
||||
await SearchTestUtils.installSearchExtension({ name: "Test" });
|
||||
let engine = await Services.search.addEngineWithDetails("Test", {
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
await Services.search.setDefault(Services.search.getEngineByName("Test"));
|
||||
await Services.search.setDefault(engine);
|
||||
|
||||
let lotsOfSpaces = "%20".repeat(300);
|
||||
await PlacesTestUtils.addVisits({
|
||||
|
@ -28,6 +30,7 @@ add_task(async function() {
|
|||
await PlacesUtils.history.clear();
|
||||
await UrlbarTestUtils.formHistory.clear();
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const TEST_ALIAS_ENGINE_NAME = "Test";
|
||||
const ALIAS = "@test";
|
||||
const TEST_ENGINE_BASENAME = "searchSuggestionEngine.xml";
|
||||
|
||||
|
@ -15,6 +14,8 @@ const TEST_ENGINE_BASENAME = "searchSuggestionEngine.xml";
|
|||
// speakers.
|
||||
const TEST_SPACES = [" ", "\u3000", " \u3000", "\u3000 "];
|
||||
|
||||
let testEngine;
|
||||
|
||||
// Allow more time for Mac machines so they don't time out in verify mode. See
|
||||
// bug 1673062.
|
||||
if (AppConstants.platform == "macosx") {
|
||||
|
@ -30,12 +31,12 @@ add_task(async function init() {
|
|||
defaultEngine.alias = "@default";
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
Services.search.setDefault(defaultEngine);
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: TEST_ALIAS_ENGINE_NAME,
|
||||
keyword: ALIAS,
|
||||
testEngine = await Services.search.addEngineWithDetails("Test", {
|
||||
alias: ALIAS,
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.removeEngine(testEngine);
|
||||
Services.search.setDefault(oldDefaultEngine);
|
||||
});
|
||||
|
||||
|
@ -106,7 +107,7 @@ async function doSimpleTest(revertBetweenSteps) {
|
|||
// Wait for the second new search that starts when search mode is entered.
|
||||
await UrlbarTestUtils.promiseSearchComplete(window);
|
||||
await UrlbarTestUtils.assertSearchMode(window, {
|
||||
engineName: TEST_ALIAS_ENGINE_NAME,
|
||||
engineName: testEngine.name,
|
||||
entry: "typed",
|
||||
});
|
||||
Assert.equal(gURLBar.value, "", "value should be empty");
|
||||
|
@ -129,7 +130,7 @@ async function doSimpleTest(revertBetweenSteps) {
|
|||
// Wait for the second new search that starts when search mode is entered.
|
||||
await UrlbarTestUtils.promiseSearchComplete(window);
|
||||
await UrlbarTestUtils.assertSearchMode(window, {
|
||||
engineName: TEST_ALIAS_ENGINE_NAME,
|
||||
engineName: testEngine.name,
|
||||
entry: "typed",
|
||||
});
|
||||
Assert.equal(gURLBar.value, "foo", "value should be query");
|
||||
|
@ -152,7 +153,7 @@ async function doSimpleTest(revertBetweenSteps) {
|
|||
// Wait for the second new search that starts when search mode is entered.
|
||||
await UrlbarTestUtils.promiseSearchComplete(window);
|
||||
await UrlbarTestUtils.assertSearchMode(window, {
|
||||
engineName: TEST_ALIAS_ENGINE_NAME,
|
||||
engineName: testEngine.name,
|
||||
entry: "typed",
|
||||
});
|
||||
Assert.equal(gURLBar.value, "", "value should be empty");
|
||||
|
@ -209,7 +210,7 @@ add_task(async function spacesBeforeAlias() {
|
|||
// Wait for the second new search that starts when search mode is entered.
|
||||
await UrlbarTestUtils.promiseSearchComplete(window);
|
||||
await UrlbarTestUtils.assertSearchMode(window, {
|
||||
engineName: TEST_ALIAS_ENGINE_NAME,
|
||||
engineName: testEngine.name,
|
||||
entry: "typed",
|
||||
});
|
||||
Assert.equal(gURLBar.value, "", "value should be empty");
|
||||
|
@ -313,7 +314,7 @@ add_task(async function aliasCase() {
|
|||
// Wait for the second new search that starts when search mode is entered.
|
||||
await UrlbarTestUtils.promiseSearchComplete(window);
|
||||
await UrlbarTestUtils.assertSearchMode(window, {
|
||||
engineName: TEST_ALIAS_ENGINE_NAME,
|
||||
engineName: testEngine.name,
|
||||
entry: "typed",
|
||||
});
|
||||
Assert.equal(gURLBar.value, "", "value should be empty");
|
||||
|
@ -332,7 +333,7 @@ add_task(async function aliasCase_query() {
|
|||
// Wait for the second new search that starts when search mode is entered.
|
||||
await UrlbarTestUtils.promiseSearchComplete(window);
|
||||
await UrlbarTestUtils.assertSearchMode(window, {
|
||||
engineName: TEST_ALIAS_ENGINE_NAME,
|
||||
engineName: testEngine.name,
|
||||
entry: "typed",
|
||||
});
|
||||
Assert.equal(gURLBar.value, "query", "value should be query");
|
||||
|
@ -499,7 +500,7 @@ add_task(async function enterAutofillsAlias() {
|
|||
await searchPromise;
|
||||
|
||||
await UrlbarTestUtils.assertSearchMode(window, {
|
||||
engineName: TEST_ALIAS_ENGINE_NAME,
|
||||
engineName: testEngine.name,
|
||||
entry: "keywordoffer",
|
||||
});
|
||||
|
||||
|
@ -525,7 +526,7 @@ add_task(async function rightEntersSearchMode() {
|
|||
await searchPromise;
|
||||
|
||||
await UrlbarTestUtils.assertSearchMode(window, {
|
||||
engineName: TEST_ALIAS_ENGINE_NAME,
|
||||
engineName: testEngine.name,
|
||||
entry: "typed",
|
||||
});
|
||||
Assert.equal(gURLBar.value, "", "value should be empty");
|
||||
|
@ -561,7 +562,7 @@ add_task(async function rightEntersSearchMode() {
|
|||
);
|
||||
|
||||
await UrlbarTestUtils.assertSearchMode(window, {
|
||||
engineName: TEST_ALIAS_ENGINE_NAME,
|
||||
engineName: testEngine.name,
|
||||
entry: "keywordoffer",
|
||||
isPreview: true,
|
||||
});
|
||||
|
@ -572,7 +573,7 @@ add_task(async function rightEntersSearchMode() {
|
|||
await searchPromise;
|
||||
|
||||
await UrlbarTestUtils.assertSearchMode(window, {
|
||||
engineName: TEST_ALIAS_ENGINE_NAME,
|
||||
engineName: testEngine.name,
|
||||
entry: "keywordoffer",
|
||||
isPreview: false,
|
||||
});
|
||||
|
@ -649,13 +650,10 @@ add_task(async function hiddenEngine() {
|
|||
add_task(async function nonPrefixedKeyword() {
|
||||
let name = "Custom";
|
||||
let alias = "customkeyword";
|
||||
let extension = await SearchTestUtils.installSearchExtension(
|
||||
{
|
||||
name,
|
||||
keyword: alias,
|
||||
},
|
||||
true
|
||||
);
|
||||
let engine = await Services.search.addEngineWithDetails(name, {
|
||||
alias,
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
|
@ -690,19 +688,16 @@ add_task(async function nonPrefixedKeyword() {
|
|||
"The first result should be a keyword search result with the correct engine."
|
||||
);
|
||||
|
||||
await extension.unload();
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
|
||||
// Tests that we show all engines with a token alias that match the search
|
||||
// string.
|
||||
add_task(async function multipleMatchingEngines() {
|
||||
let extension = await SearchTestUtils.installSearchExtension(
|
||||
{
|
||||
name: "TestFoo",
|
||||
keyword: `${ALIAS}foo`,
|
||||
},
|
||||
true
|
||||
);
|
||||
let testEngineFoo = await Services.search.addEngineWithDetails("TestFoo", {
|
||||
alias: `${ALIAS}foo`,
|
||||
template: "http://example-2.com/?search={searchTerms}",
|
||||
});
|
||||
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
|
@ -753,7 +748,7 @@ add_task(async function multipleMatchingEngines() {
|
|||
"Urlbar should contain the search string."
|
||||
);
|
||||
|
||||
await extension.unload();
|
||||
await Services.search.removeEngine(testEngineFoo);
|
||||
});
|
||||
|
||||
// Tests that UrlbarProviderTokenAliasEngines is disabled in search mode.
|
||||
|
|
|
@ -1383,11 +1383,13 @@ add_task(async function test() {
|
|||
await Services.search.setDefault(engine);
|
||||
await Services.search.moveEngine(engine, 0);
|
||||
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: TEST_ENGINE_NAME,
|
||||
keyword: TEST_ENGINE_ALIAS,
|
||||
search_url: `https://${TEST_ENGINE_DOMAIN}/`,
|
||||
});
|
||||
let aliasEngine = await Services.search.addEngineWithDetails(
|
||||
TEST_ENGINE_NAME,
|
||||
{
|
||||
alias: TEST_ENGINE_ALIAS,
|
||||
template: `http://${TEST_ENGINE_DOMAIN}/?search={searchTerms}`,
|
||||
}
|
||||
);
|
||||
|
||||
// Add a bookmark and a keyword.
|
||||
let bm = await PlacesUtils.bookmarks.insert({
|
||||
|
@ -1408,6 +1410,7 @@ add_task(async function test() {
|
|||
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(aliasEngine);
|
||||
await PlacesUtils.keywords.remove("kw");
|
||||
await PlacesUtils.bookmarks.remove(bm);
|
||||
await PlacesUtils.history.clear();
|
||||
|
|
|
@ -65,9 +65,11 @@ add_task(async function init() {
|
|||
});
|
||||
|
||||
// Add a mock engine so we don't hit the network.
|
||||
await SearchTestUtils.installSearchExtension();
|
||||
let engine = await Services.search.addEngineWithDetails("Test", {
|
||||
template: "http://example.com/?search={searchTerms}",
|
||||
});
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
Services.search.setDefault(Services.search.getEngineByName("Example"));
|
||||
Services.search.setDefault(engine);
|
||||
|
||||
// Set up Quick Suggest.
|
||||
await UrlbarQuickSuggest.init();
|
||||
|
@ -84,6 +86,7 @@ add_task(async function init() {
|
|||
registerCleanupFunction(async () => {
|
||||
sandbox.restore();
|
||||
Services.search.setDefault(oldDefaultEngine);
|
||||
await Services.search.removeEngine(engine);
|
||||
Services.telemetry.canRecordExtended = oldCanRecord;
|
||||
delete UrlbarProviderQuickSuggest._helpUrl;
|
||||
});
|
||||
|
|
|
@ -108,9 +108,8 @@ add_task(async function setup() {
|
|||
set: [["browser.urlbar.tabToSearch.onboard.interactionsLeft", 0]],
|
||||
});
|
||||
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: ENGINE_NAME,
|
||||
search_url: `https://${ENGINE_DOMAIN}/`,
|
||||
let engine = await Services.search.addEngineWithDetails(ENGINE_NAME, {
|
||||
template: `http://${ENGINE_DOMAIN}/?q={searchTerms}`,
|
||||
});
|
||||
|
||||
UrlbarTestUtils.init(this);
|
||||
|
@ -126,6 +125,7 @@ add_task(async function setup() {
|
|||
registerCleanupFunction(async () => {
|
||||
Services.telemetry.canRecordExtended = oldCanRecord;
|
||||
UrlbarTestUtils.uninit();
|
||||
await Services.search.removeEngine(engine);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const { SearchTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/SearchTestUtils.jsm"
|
||||
);
|
||||
|
||||
SearchTestUtils.init(this);
|
||||
|
||||
add_task(async function() {
|
||||
// Our search would be handled by the urlbar normally and not by the docshell,
|
||||
// thus we must force going through dns first, so that the urlbar thinks
|
||||
|
@ -16,10 +10,10 @@ add_task(async function() {
|
|||
set: [["browser.fixup.dns_first_for_single_words", true]],
|
||||
});
|
||||
const kSearchEngineID = "test_urifixup_search_engine";
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: kSearchEngineID,
|
||||
search_url: "http://localhost/",
|
||||
search_url_get_params: "search={searchTerms}",
|
||||
const kSearchEngineURL = "http://localhost/?search={searchTerms}";
|
||||
await Services.search.addEngineWithDetails(kSearchEngineID, {
|
||||
method: "get",
|
||||
template: kSearchEngineURL,
|
||||
});
|
||||
|
||||
let oldDefaultEngine = await Services.search.getDefault();
|
||||
|
@ -35,7 +29,13 @@ add_task(async function() {
|
|||
);
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
if (oldDefaultEngine) {
|
||||
await Services.search.setDefault(oldDefaultEngine);
|
||||
}
|
||||
let engine = Services.search.getEngineByName(kSearchEngineID);
|
||||
if (engine) {
|
||||
await Services.search.removeEngine(engine);
|
||||
}
|
||||
});
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
|
|
|
@ -6,16 +6,11 @@
|
|||
const { UrlbarTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/UrlbarTestUtils.jsm"
|
||||
);
|
||||
const { SearchTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/SearchTestUtils.jsm"
|
||||
);
|
||||
|
||||
SearchTestUtils.init(this);
|
||||
|
||||
const kSearchEngineID = "browser_urifixup_search_engine";
|
||||
const kSearchEngineURL = "https://example.com/?search={searchTerms}";
|
||||
const kSearchEngineURL = "http://example.com/?search={searchTerms}";
|
||||
const kPrivateSearchEngineID = "browser_urifixup_search_engine_private";
|
||||
const kPrivateSearchEngineURL = "https://example.com/?private={searchTerms}";
|
||||
const kPrivateSearchEngineURL = "http://example.com/?private={searchTerms}";
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
|
@ -29,28 +24,34 @@ add_task(async function setup() {
|
|||
let oldPrivateEngine = await Services.search.getDefaultPrivate();
|
||||
|
||||
// Add new fake search engines.
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: kSearchEngineID,
|
||||
search_url: "https://example.com/",
|
||||
search_url_get_params: "search={searchTerms}",
|
||||
});
|
||||
await Services.search.setDefault(
|
||||
Services.search.getEngineByName(kSearchEngineID)
|
||||
let newCurrentEngine = await Services.search.addEngineWithDetails(
|
||||
kSearchEngineID,
|
||||
{
|
||||
method: "get",
|
||||
template: kSearchEngineURL,
|
||||
}
|
||||
);
|
||||
await Services.search.setDefault(newCurrentEngine);
|
||||
|
||||
await SearchTestUtils.installSearchExtension({
|
||||
name: kPrivateSearchEngineID,
|
||||
search_url: "https://example.com/",
|
||||
search_url_get_params: "private={searchTerms}",
|
||||
});
|
||||
await Services.search.setDefaultPrivate(
|
||||
Services.search.getEngineByName(kPrivateSearchEngineID)
|
||||
let newPrivateEngine = await Services.search.addEngineWithDetails(
|
||||
kPrivateSearchEngineID,
|
||||
{
|
||||
method: "get",
|
||||
template: kPrivateSearchEngineURL,
|
||||
}
|
||||
);
|
||||
await Services.search.setDefaultPrivate(newPrivateEngine);
|
||||
|
||||
// Remove the fake engines when done.
|
||||
registerCleanupFunction(async () => {
|
||||
await Services.search.setDefault(oldCurrentEngine);
|
||||
await Services.search.setDefault(oldPrivateEngine);
|
||||
if (oldCurrentEngine) {
|
||||
await Services.search.setDefault(oldCurrentEngine);
|
||||
}
|
||||
if (oldPrivateEngine) {
|
||||
await Services.search.setDefault(oldPrivateEngine);
|
||||
}
|
||||
await Services.search.removeEngine(newCurrentEngine);
|
||||
await Services.search.removeEngine(newPrivateEngine);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -26,19 +26,11 @@ var EXPORTED_SYMBOLS = ["SearchTestUtils"];
|
|||
|
||||
var gTestScope;
|
||||
|
||||
var SearchTestUtils = {
|
||||
var SearchTestUtils = Object.freeze({
|
||||
init(testScope) {
|
||||
gTestScope = testScope;
|
||||
let env = Cc["@mozilla.org/process/environment;1"].getService(
|
||||
Ci.nsIEnvironment
|
||||
);
|
||||
this._isMochitest = !env.exists("XPCSHELL_TEST_PROFILE_DIR");
|
||||
if (this._isMochitest) {
|
||||
this._isMochitest = true;
|
||||
AddonTestUtils.initMochitest(testScope);
|
||||
} else {
|
||||
this._isMochitest = false;
|
||||
// This handles xpcshell-tests.
|
||||
// This handles xpcshell-tests.
|
||||
if (!("ExtensionTestUtils" in gTestScope)) {
|
||||
gTestScope.ExtensionTestUtils = ExtensionTestUtils;
|
||||
}
|
||||
},
|
||||
|
@ -185,43 +177,21 @@ var SearchTestUtils = {
|
|||
* Note: If you are in xpcshell-tests, then you should call
|
||||
* `initXPCShellAddonManager` before calling this.
|
||||
*
|
||||
* Note: for tests, the extension must generally be unloaded before
|
||||
* `registerCleanupFunction`s are triggered. See bug 1694409.
|
||||
*
|
||||
* For mochitests this function automatically registers an unload, this
|
||||
* may be skipped with the skipUnload argument.
|
||||
* For xpcshell-tests, we will hopefully be able to add the unload once
|
||||
* bug 1694409 is fixed.
|
||||
*
|
||||
* @param {object} [options]
|
||||
* @see createEngineManifest
|
||||
* @param {boolean} [skipUnload]
|
||||
* If true, this will skip the automatic unloading of the extension.
|
||||
* @returns {object}
|
||||
* The loaded extension. This will need unloading before ending the test.
|
||||
*/
|
||||
async installSearchExtension(options = {}, skipUnload = false) {
|
||||
async installSearchExtension(options = {}) {
|
||||
options.id = (options.id ?? "example") + "@tests.mozilla.org";
|
||||
let extensionInfo = {
|
||||
useAddonManager: "permanent",
|
||||
manifest: this.createEngineManifest(options),
|
||||
};
|
||||
|
||||
let extension;
|
||||
|
||||
// Cleanup must be registered before loading the extension to avoid
|
||||
// failures for mochitests.
|
||||
if (!skipUnload && this._isMochitest) {
|
||||
gTestScope.registerCleanupFunction(async () => {
|
||||
await extension.unload();
|
||||
});
|
||||
}
|
||||
|
||||
extension = gTestScope.ExtensionTestUtils.loadExtension(extensionInfo);
|
||||
let extension = gTestScope.ExtensionTestUtils.loadExtension(extensionInfo);
|
||||
await extension.startup();
|
||||
if (!options.skipWaitForSearchEngine) {
|
||||
await AddonTestUtils.waitForSearchProviderStartup(extension);
|
||||
}
|
||||
|
||||
return extension;
|
||||
},
|
||||
|
||||
|
@ -286,11 +256,8 @@ var SearchTestUtils = {
|
|||
* The generated manifest.
|
||||
*/
|
||||
createEngineManifest(options = {}) {
|
||||
options.id = options.id ?? "example@tests.mozilla.org";
|
||||
options.name = options.name ?? "Example";
|
||||
options.id = options.id ?? options.name.toLowerCase().replaceAll(" ", "");
|
||||
if (!options.id.includes("@")) {
|
||||
options.id += "@tests.mozilla.org";
|
||||
}
|
||||
options.version = options.version ?? "1.0";
|
||||
let manifest = {
|
||||
version: options.version,
|
||||
|
@ -396,4 +363,4 @@ var SearchTestUtils = {
|
|||
this.idleService._fireObservers("idle");
|
||||
await reloadObserved;
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -13,55 +13,38 @@ add_task(async function setup() {
|
|||
|
||||
add_task(async function test_engineUpdate() {
|
||||
const KEYWORD = "keyword";
|
||||
const FILENAME = "engine.xml";
|
||||
const TOPIC = "browser-search-engine-modified";
|
||||
const ONE_DAY_IN_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
let [engine] = await addTestEngines([
|
||||
{ name: "Test search engine", xmlFileName: "engine.xml" },
|
||||
{ name: "Test search engine", xmlFileName: FILENAME },
|
||||
]);
|
||||
|
||||
engine.alias = KEYWORD;
|
||||
await Services.search.moveEngine(engine, 0);
|
||||
|
||||
Assert.ok(
|
||||
!Services.search.getEngineByName("A second test engine"),
|
||||
"Should not be able to get the engine by the new name"
|
||||
);
|
||||
|
||||
// can't have an accurate updateURL in the file since we can't know the test
|
||||
// server origin, so manually set it
|
||||
engine.wrappedJSObject._updateURL = gDataUrl + "engine2.xml";
|
||||
engine.wrappedJSObject._updateURL = gDataUrl + FILENAME;
|
||||
|
||||
let promiseUpdate = SearchTestUtils.promiseSearchNotification(
|
||||
SearchUtils.MODIFIED_TYPE.CHANGED,
|
||||
SearchUtils.TOPIC_ENGINE_MODIFIED
|
||||
);
|
||||
await new Promise(resolve => {
|
||||
Services.obs.addObserver(function obs(subject, topic, data) {
|
||||
if (data == "engine-loaded") {
|
||||
let loadedEngine = subject.QueryInterface(Ci.nsISearchEngine);
|
||||
let rawEngine = loadedEngine.wrappedJSObject;
|
||||
equal(loadedEngine.alias, KEYWORD, "Keyword not cleared by update");
|
||||
equal(rawEngine.getAttr("order"), 1, "Order not cleared by update");
|
||||
Services.obs.removeObserver(obs, TOPIC);
|
||||
resolve();
|
||||
}
|
||||
}, TOPIC);
|
||||
|
||||
// set last update to 8 days ago, since the default interval is 7, then
|
||||
// trigger an update
|
||||
engine.wrappedJSObject.setAttr("updateexpir", Date.now() - ONE_DAY_IN_MS * 8);
|
||||
Services.search.QueryInterface(Ci.nsITimerCallback).notify(null);
|
||||
|
||||
let changedEngine = await promiseUpdate;
|
||||
|
||||
Assert.equal(
|
||||
engine.name,
|
||||
"A second test engine",
|
||||
"Should have update the engines name"
|
||||
);
|
||||
|
||||
Assert.equal(changedEngine.alias, KEYWORD, "Keyword not cleared by update");
|
||||
Assert.equal(
|
||||
changedEngine.wrappedJSObject.getAttr("order"),
|
||||
1,
|
||||
"Order not cleared by update"
|
||||
);
|
||||
|
||||
Assert.ok(
|
||||
!!Services.search.getEngineByName("A second test engine"),
|
||||
"Should be able to get the engine by the new name"
|
||||
);
|
||||
Assert.ok(
|
||||
!Services.search.getEngineByName("Test search engine"),
|
||||
"Should not be able to get the engine by the old name"
|
||||
);
|
||||
// set last update to 8 days ago, since the default interval is 7, then
|
||||
// trigger an update
|
||||
engine.wrappedJSObject.setAttr(
|
||||
"updateexpir",
|
||||
Date.now() - ONE_DAY_IN_MS * 8
|
||||
);
|
||||
Services.search.QueryInterface(Ci.nsITimerCallback).notify(null);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2169,7 +2169,7 @@ add_task(async function test_defaultSearchEngine_paramsChanged() {
|
|||
checkEnvironmentData(data);
|
||||
Assert.deepEqual(data.settings.defaultSearchEngineData, {
|
||||
name: "TestEngine",
|
||||
loadPath: "[other]addEngineWithDetails:testengine@tests.mozilla.org",
|
||||
loadPath: "[other]addEngineWithDetails:example@tests.mozilla.org",
|
||||
origin: "verified",
|
||||
submissionURL: "https://www.google.com/fake1?q=",
|
||||
});
|
||||
|
@ -2197,7 +2197,7 @@ add_task(async function test_defaultSearchEngine_paramsChanged() {
|
|||
checkEnvironmentData(data);
|
||||
Assert.deepEqual(data.settings.defaultSearchEngineData, {
|
||||
name: "TestEngine",
|
||||
loadPath: "[other]addEngineWithDetails:testengine@tests.mozilla.org",
|
||||
loadPath: "[other]addEngineWithDetails:example@tests.mozilla.org",
|
||||
origin: "verified",
|
||||
submissionURL: "https://www.google.com/fake2?q=",
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче