Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: browser/components/urlbar/tests/unit/xpcshell.toml
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
// This tests autofill prefix fallback in case multiple origins have the same
// exact frecency.
// We should prefer https, or in case of other prefixes just sort by descending
// id.
add_task(async function () {
registerCleanupFunction(async () => {
Services.prefs.clearUserPref("browser.urlbar.suggest.searches");
Services.prefs.clearUserPref("browser.urlbar.suggest.quickactions");
});
Services.prefs.setBoolPref("browser.urlbar.suggest.searches", false);
Services.prefs.setBoolPref("browser.urlbar.suggest.quickactions", false);
let host = "example.com";
for (let prefix of prefixes) {
await PlacesUtils.bookmarks.insert({
url: `${prefix}${host}`,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
});
}
await checkOriginsOrder(host, prefixes);
// version has been added later so it has an higher id.
let context = createContext("ex", { isPrivate: false });
await check_results({
context,
autofilled: `${host}/`,
matches: [
makeVisitResult(context, {
heuristic: true,
}),
makeBookmarkResult(context, {
title: `${host}`,
}),
],
});
// Remove and reinsert bookmarks in another order.
await PlacesUtils.bookmarks.eraseEverything();
await PlacesUtils.history.clear();
for (let prefix of prefixes) {
await PlacesUtils.bookmarks.insert({
url: `${prefix}${host}`,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
});
}
await checkOriginsOrder(host, prefixes);
await check_results({
context,
autofilled: `${host}/`,
matches: [
makeVisitResult(context, {
heuristic: true,
}),
makeBookmarkResult(context, {
title: `www.${host}`,
}),
],
});
});