Bug 1315675 - Fix tests to not fail if browser.urlbar.oneOffSearches gets turned off in other branches. r?mak
MozReview-Commit-ID: HgLy6Dis0jU
--- a/browser/components/search/test/browser_oneOffContextMenu_setDefault.js
+++ b/browser/components/search/test/browser_oneOffContextMenu_setDefault.js
@@ -1,14 +1,15 @@
"use strict";
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");
const searchPopup = document.getElementById("PopupSearchAutoComplete");
const urlbarPopup = document.getElementById("PopupAutoCompleteRichResult");
const searchIcon = document.getAnonymousElementByAttribute(
searchbar, "anonid", "searchbar-search-button"
);
@@ -55,16 +56,21 @@ add_task(function* test_searchBarChangeE
"Should now have the original engine's name for the tooltip");
Assert.equal(oneOffButton.image, originalEngine.iconURI.spec,
"Should now have the original engine's uri for the image");
yield promiseClosePopup(searchPopup);
});
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();
let oneOffButton = yield openPopupAndGetEngineButton(false, urlbarPopup,
urlBarOneOffBinding,
URLBAR_BASE_ID);
const setDefaultEngineMenuItem = document.getAnonymousElementByAttribute(
--- a/browser/modules/test/browser_UsageTelemetry_urlbar.js
+++ b/browser/modules/test/browser_UsageTelemetry_urlbar.js
@@ -1,16 +1,17 @@
"use strict";
const SCALAR_URLBAR = "browser.engagement.navigation.urlbar";
// The preference to enable suggestions in the 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));
// Write the search query in the urlbar.
win.gURLBar.focus();
win.gURLBar.value = inputText;
win.gURLBar.controller.startSearch(inputText);
// Wait for the popup to show.
@@ -50,21 +51,25 @@ add_task(function* setup() {
Services.search.currentEngine = engine;
// And the first one-off engine.
Services.search.moveEngine(engine, 0);
// 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);
});
});
add_task(function* test_simpleQuery() {
// Let's reset the counts.
Services.telemetry.clearScalars();
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");