Bug 1315675 - Fix tests to not fail if browser.urlbar.oneOffSearches gets turned off in other branches. r=mak

MozReview-Commit-ID: HgLy6Dis0jU

--HG--
extra : rebase_source : 3952f431f909274ddbd716f21445b950e00a7b79
This commit is contained in:
Mark Banner 2016-11-08 14:08:52 +00:00
Родитель 965963b650
Коммит d762b04ac8
2 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -4,6 +4,7 @@ const TEST_ENGINE_NAME = "Foo";
const TEST_ENGINE_BASENAME = "testEngine.xml";
const SEARCHBAR_BASE_ID = "searchbar-engine-one-off-item-";
const URLBAR_BASE_ID = "urlbar-engine-one-off-item-";
const ONEOFF_URLBAR_PREF = "browser.urlbar.oneOffSearches";
const searchbar = document.getElementById("searchbar");
const urlbar = document.getElementById("urlbar");
@ -60,6 +61,11 @@ add_task(function* test_searchBarChangeEngine() {
});
add_task(function* test_urlBarChangeEngine() {
Services.prefs.setBoolPref(ONEOFF_URLBAR_PREF, true);
registerCleanupFunction(function* () {
Services.prefs.clearUserPref(ONEOFF_URLBAR_PREF);
});
// Ensure the engine is reset.
resetEngine();

Просмотреть файл

@ -6,6 +6,7 @@ const SCALAR_URLBAR = "browser.engagement.navigation.urlbar";
const SUGGEST_URLBAR_PREF = "browser.urlbar.suggest.searches";
// The name of the search engine used to generate suggestions.
const SUGGESTION_ENGINE_NAME = "browser_UsageTelemetry usageTelemetrySearchSuggestions.xml";
const ONEOFF_URLBAR_PREF = "browser.urlbar.oneOffSearches";
let searchInAwesomebar = Task.async(function* (inputText, win=window) {
yield new Promise(r => waitForFocus(r, win));
@ -55,11 +56,15 @@ add_task(function* setup() {
// Enable search suggestions in the urlbar.
Services.prefs.setBoolPref(SUGGEST_URLBAR_PREF, true);
// Enable the urlbar one-off buttons.
Services.prefs.setBoolPref(ONEOFF_URLBAR_PREF, true);
// Make sure to restore the engine once we're done.
registerCleanupFunction(function* () {
Services.search.currentEngine = originalEngine;
Services.search.removeEngine(engine);
Services.prefs.clearUserPref(SUGGEST_URLBAR_PREF, true);
Services.prefs.clearUserPref(ONEOFF_URLBAR_PREF);
});
});