Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

/* Any copyright is dedicated to the Public Domain.
/**
* Tests that rich suggestion results results are shown without
* rich data if richSuggestions are disabled.
*/
const SUGGEST_ENABLED_PREF = "browser.search.suggest.enabled";
const RICH_SUGGESTIONS_PREF = "browser.urlbar.richSuggestions.featureGate";
const QUICKACTIONS_URLBAR_PREF = "quickactions.enabled";
add_setup(async function () {
let engine = await addTestTailSuggestionsEngine(defaultRichSuggestionsFn);
// Install the test engine.
let oldDefaultEngine = await SearchService.getDefault();
registerCleanupFunction(async () => {
SearchService.setDefault(
oldDefaultEngine,
SearchService.CHANGE_REASON.UNKNOWN
);
Services.prefs.clearUserPref(RICH_SUGGESTIONS_PREF);
Services.prefs.clearUserPref(SUGGEST_ENABLED_PREF);
UrlbarPrefs.clear(QUICKACTIONS_URLBAR_PREF);
});
SearchService.setDefault(engine, SearchService.CHANGE_REASON.UNKNOWN);
Services.prefs.setBoolPref(RICH_SUGGESTIONS_PREF, true);
Services.prefs.setBoolPref(SUGGEST_ENABLED_PREF, true);
UrlbarPrefs.set(QUICKACTIONS_URLBAR_PREF, false);
});
/**
* Test that suggestions with rich data are still shown
*/
add_task(async function test_richsuggestions_disabled() {
Services.prefs.setBoolPref(RICH_SUGGESTIONS_PREF, false);
const query = "what time is it in t";
let context = createContext(query, { isPrivate: false });
await check_results({
context,
matches: [
makeSearchResult(context, {
engineName: TAIL_SUGGESTIONS_ENGINE_NAME,
heuristic: true,
}),
makeSearchResult(context, {
engineName: TAIL_SUGGESTIONS_ENGINE_NAME,
suggestion: query + "oronto",
}),
makeSearchResult(context, {
engineName: TAIL_SUGGESTIONS_ENGINE_NAME,
suggestion: query + "unisia",
}),
makeSearchResult(context, {
engineName: TAIL_SUGGESTIONS_ENGINE_NAME,
suggestion: query + "acoma",
}),
makeSearchResult(context, {
engineName: TAIL_SUGGESTIONS_ENGINE_NAME,
suggestion: query + "aipei",
}),
],
});
});