mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1870685 - Ensure mochi browser chrome tests pass with search-config-v2 enabled. r=Standard8
Depends on D202637 Differential Revision: https://phabricator.services.mozilla.com/D204133
This commit is contained in:
parent
4604a693b6
commit
00f0ac69d1
@ -7,6 +7,7 @@ ChromeUtils.defineESModuleGetters(this, {
|
||||
AddonManager: "resource://gre/modules/AddonManager.sys.mjs",
|
||||
AddonTestUtils: "resource://testing-common/AddonTestUtils.sys.mjs",
|
||||
SearchTestUtils: "resource://testing-common/SearchTestUtils.sys.mjs",
|
||||
SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
|
||||
TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs",
|
||||
});
|
||||
|
||||
@ -21,14 +22,19 @@ SearchTestUtils.init(this);
|
||||
const DEFAULT_ENGINE = {
|
||||
id: "basic",
|
||||
name: "basic",
|
||||
loadPath: "[addon]basic@search.mozilla.org",
|
||||
submissionUrl:
|
||||
"https://mochi.test:8888/browser/browser/components/search/test/browser/?search=&foo=1",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]basic@search.mozilla.org"
|
||||
: "[addon]basic@search.mozilla.org",
|
||||
submissionUrl: SearchUtils.newSearchConfigEnabled
|
||||
? "https://mochi.test:8888/browser/browser/components/search/test/browser/?foo=1&search="
|
||||
: "https://mochi.test:8888/browser/browser/components/search/test/browser/?search=&foo=1",
|
||||
};
|
||||
const ALTERNATE_ENGINE = {
|
||||
id: "simple",
|
||||
name: "Simple Engine",
|
||||
loadPath: "[addon]simple@search.mozilla.org",
|
||||
loadPath: SearchUtils.newSearchConfigEnabled
|
||||
? "[app]simple@search.mozilla.org"
|
||||
: "[addon]simple@search.mozilla.org",
|
||||
submissionUrl: "https://example.com/?sourceId=Mozilla-search&search=",
|
||||
};
|
||||
const ALTERNATE2_ENGINE = {
|
||||
@ -97,7 +103,11 @@ add_setup(async function () {
|
||||
await SearchTestUtils.useMochitestEngines(searchExtensions);
|
||||
|
||||
SearchTestUtils.useMockIdleService();
|
||||
let response = await fetch(`resource://search-extensions/engines.json`);
|
||||
let response = await fetch(
|
||||
SearchUtils.newSearchConfigEnabled
|
||||
? `resource://search-extensions/search-config-v2.json`
|
||||
: `resource://search-extensions/engines.json`
|
||||
);
|
||||
let json = await response.json();
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(json.data);
|
||||
|
||||
|
@ -0,0 +1,97 @@
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"recordType": "engine",
|
||||
"identifier": "basic",
|
||||
"base": {
|
||||
"name": "basic",
|
||||
"urls": {
|
||||
"search": {
|
||||
"base": "https://mochi.test:8888/browser/browser/components/search/test/browser/",
|
||||
"params": [
|
||||
{
|
||||
"name": "foo",
|
||||
"value": "1"
|
||||
}
|
||||
],
|
||||
"searchTermParamName": "search"
|
||||
},
|
||||
"suggestions": {
|
||||
"base": "https://mochi.test:8888/browser/browser/modules/test/browser/usageTelemetrySearchSuggestions.sjs",
|
||||
"searchTermParamName": "q"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variants": [
|
||||
{
|
||||
"environment": { "allRegionsAndLocales": true }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"recordType": "engine",
|
||||
"identifier": "simple",
|
||||
"base": {
|
||||
"name": "Simple Engine",
|
||||
"urls": {
|
||||
"search": {
|
||||
"base": "https://example.com",
|
||||
"params": [
|
||||
{
|
||||
"name": "sourceId",
|
||||
"value": "Mozilla-search"
|
||||
}
|
||||
],
|
||||
"searchTermParamName": "search"
|
||||
},
|
||||
"suggestions": {
|
||||
"base": "https://example.com",
|
||||
"searchTermParamName": "search"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variants": [
|
||||
{
|
||||
"environment": { "allRegionsAndLocales": true }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"recordType": "engine",
|
||||
"identifier": "another",
|
||||
"base": {
|
||||
"name": "another",
|
||||
"urls": {
|
||||
"search": {
|
||||
"base": "https://mochi.test:8888/browser/browser/components/search/test/browser/",
|
||||
"params": [
|
||||
{
|
||||
"name": "bar",
|
||||
"value": "1"
|
||||
}
|
||||
],
|
||||
"searchTermParamName": "search"
|
||||
},
|
||||
"suggestions": {
|
||||
"base": "https://mochi.test:8888/browser/browser/modules/test/browser/usageTelemetrySearchSuggestions.sjs",
|
||||
"searchTermParamName": "q"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variants": [
|
||||
{
|
||||
"environment": { "allRegionsAndLocales": true }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"recordType": "defaultEngines",
|
||||
"globalDefault": "basic",
|
||||
"specificDefaults": []
|
||||
},
|
||||
{
|
||||
"recordType": "engineOrders",
|
||||
"orders": []
|
||||
}
|
||||
]
|
||||
}
|
@ -22,6 +22,65 @@ const CONFIG_DEFAULT = [
|
||||
},
|
||||
];
|
||||
|
||||
const CONFIG_V2 = [
|
||||
{
|
||||
recordType: "engine",
|
||||
identifier: "basic",
|
||||
base: {
|
||||
name: "basic",
|
||||
urls: {
|
||||
search: {
|
||||
base: "https://example.com",
|
||||
searchTermParamName: "q",
|
||||
},
|
||||
trending: {
|
||||
base: "https://example.com/browser/browser/components/search/test/browser/trendingSuggestionEngine.sjs",
|
||||
method: "GET",
|
||||
},
|
||||
},
|
||||
aliases: ["basic"],
|
||||
},
|
||||
variants: [
|
||||
{
|
||||
environment: { allRegionsAndLocales: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
recordType: "engine",
|
||||
identifier: "private",
|
||||
base: {
|
||||
name: "private",
|
||||
urls: {
|
||||
search: {
|
||||
base: "https://example.com",
|
||||
searchTermParamName: "q",
|
||||
},
|
||||
suggestions: {
|
||||
base: "https://example.com",
|
||||
method: "GET",
|
||||
searchTermParamName: "search",
|
||||
},
|
||||
},
|
||||
aliases: ["private"],
|
||||
},
|
||||
variants: [
|
||||
{
|
||||
environment: { allRegionsAndLocales: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
recordType: "defaultEngines",
|
||||
globalDefault: "basic",
|
||||
specificDefaults: [],
|
||||
},
|
||||
{
|
||||
recordType: "engineOrders",
|
||||
orders: [],
|
||||
},
|
||||
];
|
||||
|
||||
SearchTestUtils.init(this);
|
||||
|
||||
add_setup(async () => {
|
||||
@ -38,7 +97,9 @@ add_setup(async () => {
|
||||
});
|
||||
|
||||
SearchTestUtils.useMockIdleService();
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(CONFIG_DEFAULT);
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(
|
||||
SearchUtils.newSearchConfigEnabled ? CONFIG_V2 : CONFIG_DEFAULT
|
||||
);
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
|
@ -17,6 +17,40 @@ const CONFIG_DEFAULT = [
|
||||
},
|
||||
];
|
||||
|
||||
const CONFIG_DEFAULT_V2 = [
|
||||
{
|
||||
recordType: "engine",
|
||||
identifier: "basic",
|
||||
base: {
|
||||
name: "basic",
|
||||
urls: {
|
||||
search: {
|
||||
base: "https://example.com",
|
||||
searchTermParamName: "q",
|
||||
},
|
||||
trending: {
|
||||
base: "https://example.com/browser/browser/components/search/test/browser/trendingSuggestionEngine.sjs",
|
||||
method: "GET",
|
||||
},
|
||||
},
|
||||
},
|
||||
variants: [
|
||||
{
|
||||
environment: { allRegionsAndLocales: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
recordType: "defaultEngines",
|
||||
globalDefault: "basic",
|
||||
specificDefaults: [],
|
||||
},
|
||||
{
|
||||
recordType: "engineOrders",
|
||||
orders: [],
|
||||
},
|
||||
];
|
||||
|
||||
const TOP_SITES = [
|
||||
"https://example-1.com/",
|
||||
"https://example-2.com/",
|
||||
@ -45,7 +79,9 @@ add_setup(async () => {
|
||||
});
|
||||
|
||||
SearchTestUtils.useMockIdleService();
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(CONFIG_DEFAULT);
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(
|
||||
SearchUtils.newSearchConfigEnabled ? CONFIG_DEFAULT_V2 : CONFIG_DEFAULT
|
||||
);
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
|
@ -13,6 +13,7 @@
|
||||
ChromeUtils.defineESModuleGetters(this, {
|
||||
UrlbarProviderClipboard:
|
||||
"resource:///modules/UrlbarProviderClipboard.sys.mjs",
|
||||
SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
|
||||
});
|
||||
|
||||
// This test has many subtests and can time out in verify mode.
|
||||
@ -756,29 +757,76 @@ add_task(async function selected_result_trending() {
|
||||
});
|
||||
|
||||
let defaultEngine = await Services.search.getDefault();
|
||||
let extension = await SearchTestUtils.installSearchExtension(
|
||||
{
|
||||
name: "mozengine",
|
||||
search_url: "https://example.org/",
|
||||
},
|
||||
{ setAsDefault: true, skipUnload: true }
|
||||
);
|
||||
let extension;
|
||||
if (!SearchUtils.newSearchConfigEnabled) {
|
||||
extension = await SearchTestUtils.installSearchExtension(
|
||||
{
|
||||
name: "mozengine",
|
||||
search_url: "https://example.org/",
|
||||
},
|
||||
{ setAsDefault: true, skipUnload: true }
|
||||
);
|
||||
}
|
||||
|
||||
SearchTestUtils.useMockIdleService();
|
||||
await SearchTestUtils.updateRemoteSettingsConfig([
|
||||
{
|
||||
webExtension: { id: "mozengine@tests.mozilla.org" },
|
||||
urls: {
|
||||
trending: {
|
||||
fullPath:
|
||||
"https://example.com/browser/browser/components/search/test/browser/trendingSuggestionEngine.sjs",
|
||||
query: "",
|
||||
},
|
||||
},
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
default: "yes",
|
||||
},
|
||||
]);
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(
|
||||
SearchUtils.newSearchConfigEnabled
|
||||
? [
|
||||
{
|
||||
recordType: "engine",
|
||||
identifier: "mozengine",
|
||||
base: {
|
||||
name: "mozengine",
|
||||
urls: {
|
||||
search: {
|
||||
base: "https://example.org/",
|
||||
searchTermParamName: "q",
|
||||
},
|
||||
trending: {
|
||||
base: "https://example.com/browser/browser/components/search/test/browser/trendingSuggestionEngine.sjs",
|
||||
method: "GET",
|
||||
},
|
||||
},
|
||||
},
|
||||
variants: [
|
||||
{
|
||||
environment: { allRegionsAndLocales: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
recordType: "defaultEngines",
|
||||
globalDefault: "mozengine",
|
||||
specificDefaults: [],
|
||||
},
|
||||
{
|
||||
recordType: "engineOrders",
|
||||
orders: [],
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
webExtension: { id: "mozengine@tests.mozilla.org" },
|
||||
urls: {
|
||||
trending: {
|
||||
fullPath:
|
||||
"https://example.com/browser/browser/components/search/test/browser/trendingSuggestionEngine.sjs",
|
||||
query: "",
|
||||
},
|
||||
},
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
default: "yes",
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
if (SearchUtils.newSearchConfigEnabled) {
|
||||
let engine = Services.search.getEngineByName("mozengine");
|
||||
await Services.search.setDefault(
|
||||
engine,
|
||||
Ci.nsISearchService.CHANGE_REASON_UNKNOWN
|
||||
);
|
||||
}
|
||||
|
||||
await doTest(async () => {
|
||||
await openPopup("");
|
||||
@ -796,7 +844,13 @@ add_task(async function selected_result_trending() {
|
||||
]);
|
||||
});
|
||||
|
||||
await extension.unload();
|
||||
if (SearchUtils.newSearchConfigEnabled) {
|
||||
let engine = Services.search.getEngineByName("mozengine");
|
||||
await Services.search.removeEngine(engine);
|
||||
} else {
|
||||
await extension.unload();
|
||||
}
|
||||
|
||||
await Services.search.setDefault(
|
||||
defaultEngine,
|
||||
Ci.nsISearchService.CHANGE_REASON_UNKNOWN
|
||||
@ -823,29 +877,82 @@ add_task(async function selected_result_trending_rich() {
|
||||
});
|
||||
|
||||
let defaultEngine = await Services.search.getDefault();
|
||||
let extension = await SearchTestUtils.installSearchExtension(
|
||||
{
|
||||
name: "mozengine",
|
||||
search_url: "https://example.org/",
|
||||
},
|
||||
{ setAsDefault: true, skipUnload: true }
|
||||
);
|
||||
let extension;
|
||||
if (!SearchUtils.newSearchConfigEnabled) {
|
||||
extension = await SearchTestUtils.installSearchExtension(
|
||||
{
|
||||
name: "mozengine",
|
||||
search_url: "https://example.org/",
|
||||
},
|
||||
{ setAsDefault: true, skipUnload: true }
|
||||
);
|
||||
}
|
||||
|
||||
SearchTestUtils.useMockIdleService();
|
||||
await SearchTestUtils.updateRemoteSettingsConfig([
|
||||
{
|
||||
webExtension: { id: "mozengine@tests.mozilla.org" },
|
||||
urls: {
|
||||
trending: {
|
||||
fullPath:
|
||||
"https://example.com/browser/browser/components/search/test/browser/trendingSuggestionEngine.sjs?richsuggestions=true",
|
||||
query: "",
|
||||
},
|
||||
},
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
default: "yes",
|
||||
},
|
||||
]);
|
||||
await SearchTestUtils.updateRemoteSettingsConfig(
|
||||
SearchUtils.newSearchConfigEnabled
|
||||
? [
|
||||
{
|
||||
recordType: "engine",
|
||||
identifier: "mozengine",
|
||||
base: {
|
||||
name: "mozengine",
|
||||
urls: {
|
||||
search: {
|
||||
base: "https://example.org/",
|
||||
searchTermParamName: "q",
|
||||
},
|
||||
trending: {
|
||||
base: "https://example.com/browser/browser/components/search/test/browser/trendingSuggestionEngine.sjs",
|
||||
method: "GET",
|
||||
params: [
|
||||
{
|
||||
name: "richsuggestions",
|
||||
value: "true",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
variants: [
|
||||
{
|
||||
environment: { allRegionsAndLocales: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
recordType: "defaultEngines",
|
||||
globalDefault: "mozengine",
|
||||
specificDefaults: [],
|
||||
},
|
||||
{
|
||||
recordType: "engineOrders",
|
||||
orders: [],
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
webExtension: { id: "mozengine@tests.mozilla.org" },
|
||||
urls: {
|
||||
trending: {
|
||||
fullPath:
|
||||
"https://example.com/browser/browser/components/search/test/browser/trendingSuggestionEngine.sjs?richsuggestions=true",
|
||||
query: "",
|
||||
},
|
||||
},
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
default: "yes",
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
if (SearchUtils.newSearchConfigEnabled) {
|
||||
let engine = Services.search.getEngineByName("mozengine");
|
||||
await Services.search.setDefault(
|
||||
engine,
|
||||
Ci.nsISearchService.CHANGE_REASON_UNKNOWN
|
||||
);
|
||||
}
|
||||
|
||||
await doTest(async () => {
|
||||
await openPopup("");
|
||||
@ -863,7 +970,13 @@ add_task(async function selected_result_trending_rich() {
|
||||
]);
|
||||
});
|
||||
|
||||
await extension.unload();
|
||||
if (SearchUtils.newSearchConfigEnabled) {
|
||||
let engine = Services.search.getEngineByName("mozengine");
|
||||
await Services.search.removeEngine(engine);
|
||||
} else {
|
||||
await extension.unload();
|
||||
}
|
||||
|
||||
await Services.search.setDefault(
|
||||
defaultEngine,
|
||||
Ci.nsISearchService.CHANGE_REASON_UNKNOWN
|
||||
|
@ -42,6 +42,36 @@ const SEARCH_CONFIG = [
|
||||
},
|
||||
];
|
||||
|
||||
const CONFIG_V2 = [
|
||||
{
|
||||
recordType: "engine",
|
||||
identifier: "test_urifixup_search_engine_app_provided",
|
||||
base: {
|
||||
name: "test_urifixup_search_engine_app_provided",
|
||||
urls: {
|
||||
search: {
|
||||
base: "https://www.example.org/",
|
||||
searchTermParamName: "search",
|
||||
},
|
||||
},
|
||||
},
|
||||
variants: [
|
||||
{
|
||||
environment: { allRegionsAndLocales: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
recordType: "defaultEngines",
|
||||
globalDefault: "test_urifixup_search_engine_app_provided",
|
||||
specificDefaults: [],
|
||||
},
|
||||
{
|
||||
recordType: "engineOrders",
|
||||
orders: [],
|
||||
},
|
||||
];
|
||||
|
||||
async function setupSearchService() {
|
||||
SearchTestUtils.init(this);
|
||||
|
||||
@ -54,7 +84,11 @@ async function setupSearchService() {
|
||||
"42"
|
||||
);
|
||||
|
||||
await SearchTestUtils.useTestEngines(".", null, SEARCH_CONFIG);
|
||||
await SearchTestUtils.useTestEngines(
|
||||
".",
|
||||
null,
|
||||
SearchUtils.newSearchConfigEnabled ? CONFIG_V2 : SEARCH_CONFIG
|
||||
);
|
||||
await AddonTestUtils.promiseStartupManager();
|
||||
await Services.search.init();
|
||||
}
|
||||
|
@ -1,3 +1,7 @@
|
||||
const { PromiseTestUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/PromiseTestUtils.sys.mjs"
|
||||
);
|
||||
|
||||
var pref = "browser.fixup.typo.scheme";
|
||||
|
||||
var data = [
|
||||
@ -103,11 +107,20 @@ var dontFixURIs = [
|
||||
var len = data.length;
|
||||
|
||||
add_task(async function setup() {
|
||||
await setupSearchService();
|
||||
// Now we've initialised the search service, we force remove the engines
|
||||
// it has, so they don't interfere with this test.
|
||||
// Force search service to fail, so we do not have any engines that can
|
||||
// interfere with this test.
|
||||
// Search engine integration is tested in test_URIFixup_search.js.
|
||||
Services.search.wrappedJSObject._engines.clear();
|
||||
Services.search.wrappedJSObject.errorToThrowInTest = "Settings";
|
||||
|
||||
// When search service fails, we want the promise rejection to be uncaught
|
||||
// so we can continue running the test.
|
||||
PromiseTestUtils.expectUncaughtRejection(
|
||||
/Fake Settings error during search service initialization./
|
||||
);
|
||||
|
||||
try {
|
||||
await setupSearchService();
|
||||
} catch {}
|
||||
});
|
||||
|
||||
// Make sure we fix what needs fixing when there is no pref set.
|
||||
|
@ -80,6 +80,7 @@ export const NON_SPLIT_ENGINE_IDS = [
|
||||
"engine-same-name-gd",
|
||||
"engine-purpose",
|
||||
"engine-fr",
|
||||
"fixup_search",
|
||||
];
|
||||
|
||||
const TOPIC_LOCALES_CHANGE = "intl:app-locales-changed";
|
||||
|
Loading…
Reference in New Issue
Block a user