Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test runs only with pattern: os != 'android'
- Manifest: browser/components/urlbar/tests/unit/xpcshell.toml
/* Any copyright is dedicated to the Public Domain.
// Tests that when adaptive autofill is enabled, bookmarks no longer make a
// URL or origin an autofill candidate on their own. A bookmark with at least
// one typed visit can still autofill.
"use strict";
registerCleanupFunction(async () => {
Services.prefs.clearUserPref(
"browser.urlbar.autoFill.adaptiveHistory.enabled"
);
});
Services.prefs.setBoolPref(
"browser.urlbar.autoFill.adaptiveHistory.enabled",
true
);
testEngine_setup();
add_task(async function origin_unvisited_bookmark_blocked_when_adaptive_on() {
await PlacesUtils.history.clear();
await PlacesUtils.bookmarks.eraseEverything();
let bookmark = await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
});
let context = createContext("exam", { isPrivate: false });
await check_results({
context,
matches: [
makeSearchResult(context, {
engineName: SearchService.defaultEngine.name,
heuristic: true,
}),
makeBookmarkResult(context, {
title: "",
}),
],
});
await PlacesUtils.bookmarks.remove(bookmark);
});
add_task(async function origin_visited_bookmark_autofills_when_adaptive_on() {
await PlacesUtils.history.clear();
await PlacesUtils.bookmarks.eraseEverything();
let bookmark = await PlacesUtils.bookmarks.insert({
url,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
});
await PlacesTestUtils.addVisits({
uri: url,
transition: PlacesUtils.history.TRANSITION_TYPED,
});
await PlacesFrecencyRecalculator.recalculateAnyOutdatedFrecencies();
let context = createContext("exam", { isPrivate: false });
await check_results({
context,
autofilled: "example.com/",
completed: url,
matches: [
makeVisitResult(context, {
uri: url,
title: "test visit for " + url,
heuristic: true,
}),
],
});
await PlacesUtils.bookmarks.remove(bookmark);
await PlacesUtils.history.clear();
});