mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 15:55:36 +00:00
Bug 1598569 - Add ability to pass in remote settings url for searchconfig tests r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D65824 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
69ff22a78e
commit
8cbab6191c
@ -47,6 +47,17 @@ var SearchUtils = {
|
||||
OPENSEARCH: "application/opensearchdescription+xml",
|
||||
},
|
||||
|
||||
ENGINES_URLS: {
|
||||
"prod-main":
|
||||
"https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/search-config/records",
|
||||
"prod-preview":
|
||||
"https://firefox.settings.services.mozilla.com/v1/buckets/main-preview/collections/search-config/records",
|
||||
"stage-main":
|
||||
"https://settings.stage.mozaws.net/v1/buckets/main/collections/search-config/records",
|
||||
"stage-preview":
|
||||
"https://settings.stage.mozaws.net/v1/buckets/main-preview/collections/search-config/records",
|
||||
},
|
||||
|
||||
// The following constants are left undocumented in nsISearchService.idl
|
||||
// For the moment, they are meant for testing/debugging purposes only.
|
||||
|
||||
|
@ -3,13 +3,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// This is intended for development-only. Setting it to true restricts the
|
||||
// set of locales and regions that are covered, to provide tests that are
|
||||
// quicker to run.
|
||||
// Turning it on will generate one error at the end of the test, as a reminder
|
||||
// that it needs to be changed back before shipping.
|
||||
const TEST_DEBUG = false;
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
@ -19,14 +12,23 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
AppConstants: "resource://gre/modules/AppConstants.jsm",
|
||||
ObjectUtils: "resource://gre/modules/ObjectUtils.jsm",
|
||||
OS: "resource://gre/modules/osfile.jsm",
|
||||
RemoteSettings: "resource://services-settings/remote-settings.js",
|
||||
SearchEngine: "resource://gre/modules/SearchEngine.jsm",
|
||||
SearchEngineSelector: "resource://gre/modules/SearchEngineSelector.jsm",
|
||||
SearchTestUtils: "resource://testing-common/SearchTestUtils.jsm",
|
||||
SearchUtils: "resource://gre/modules/SearchUtils.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
sinon: "resource://testing-common/Sinon.jsm",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetters(this, {
|
||||
gEnvironment: ["@mozilla.org/process/environment;1", "nsIEnvironment"],
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]);
|
||||
|
||||
const GLOBAL_SCOPE = this;
|
||||
const TEST_DEBUG = gEnvironment.get("TEST_DEBUG");
|
||||
|
||||
const URLTYPE_SUGGEST_JSON = "application/x-suggestions+json";
|
||||
const URLTYPE_SEARCH_HTML = "text/html";
|
||||
@ -100,6 +102,18 @@ class SearchConfigTest {
|
||||
"42"
|
||||
);
|
||||
|
||||
const SEARCH_CONFIG = gEnvironment.get("SEARCH_CONFIG");
|
||||
if (SEARCH_CONFIG) {
|
||||
if (!(SEARCH_CONFIG in SearchUtils.ENGINES_URLS)) {
|
||||
throw new Error(`Invalid value for SEARCH_CONFIG`);
|
||||
}
|
||||
const url = SearchUtils.ENGINES_URLS[SEARCH_CONFIG];
|
||||
const response = await fetch(url);
|
||||
const config = await response.json();
|
||||
const settings = await RemoteSettings(SearchUtils.SETTINGS_KEY);
|
||||
sinon.stub(settings, "get").returns(config.data);
|
||||
}
|
||||
|
||||
// Disable region checks.
|
||||
Services.prefs.setBoolPref("browser.search.geoSpecificDefaults", false);
|
||||
|
||||
@ -139,13 +153,6 @@ class SearchConfigTest {
|
||||
Services.search.isInitialized,
|
||||
"Should have correctly initialized the search service"
|
||||
);
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
this.assertOk(
|
||||
!TEST_DEBUG,
|
||||
"Should not have test debug turned on in production"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user