Bug 1925988: Use bookmark title if no visit_date r=urlbar-reviewers,mak
Differential Revision: https://phabricator.services.mozilla.com/D226829
This commit is contained in:
@@ -90,8 +90,9 @@ class ProviderHistoryUrlHeuristic extends UrlbarProvider {
|
||||
const connection = await lazy.PlacesUtils.promiseLargeCacheDBConnection();
|
||||
const resultSet = await connection.executeCached(
|
||||
`
|
||||
SELECT url, title, frecency
|
||||
FROM moz_places
|
||||
SELECT url, IIF(last_visit_date NOTNULL, h.title, b.title) AS _title, frecency
|
||||
FROM moz_places h
|
||||
LEFT JOIN moz_bookmarks b ON b.fk = h.id
|
||||
WHERE
|
||||
url_hash IN (
|
||||
hash('https://' || :strippedURL),
|
||||
@@ -101,11 +102,11 @@ class ProviderHistoryUrlHeuristic extends UrlbarProvider {
|
||||
)
|
||||
AND frecency <> 0
|
||||
ORDER BY
|
||||
title IS NOT NULL DESC,
|
||||
title || '/' <> :strippedURL DESC,
|
||||
url = :inputedURL DESC,
|
||||
frecency DESC,
|
||||
id DESC
|
||||
_title NOTNULL DESC,
|
||||
_title || '/' <> :strippedURL DESC,
|
||||
h.url = :inputedURL DESC,
|
||||
h.frecency DESC,
|
||||
h.id DESC
|
||||
LIMIT 1
|
||||
`,
|
||||
{ inputedURL, strippedURL }
|
||||
@@ -115,7 +116,7 @@ class ProviderHistoryUrlHeuristic extends UrlbarProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
const title = resultSet[0].getResultByName("title");
|
||||
const title = resultSet[0].getResultByName("_title");
|
||||
if (!title) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -6,14 +6,68 @@
|
||||
// Test for the behavior of UrlbarProviderHistoryUrlHeuristic.
|
||||
|
||||
add_setup(async function () {
|
||||
Services.prefs.setBoolPref("browser.search.suggest.enabled", false);
|
||||
Services.prefs.setBoolPref("browser.urlbar.autoFill", false);
|
||||
Services.prefs.setBoolPref("browser.urlbar.suggest.quickactions", false);
|
||||
registerCleanupFunction(() => {
|
||||
registerCleanupFunction(async () => {
|
||||
Services.prefs.clearUserPref("browser.search.suggest.enabled");
|
||||
Services.prefs.clearUserPref("browser.urlbar.autoFill");
|
||||
Services.prefs.clearUserPref("browser.urlbar.suggest.quickactions");
|
||||
await PlacesUtils.history.clear();
|
||||
await PlacesUtils.bookmarks.eraseEverything();
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_after_clear_history() {
|
||||
await PlacesTestUtils.addVisits([
|
||||
{ uri: "https://example.com/", title: "VISIT" },
|
||||
]);
|
||||
await PlacesTestUtils.addBookmarkWithDetails({
|
||||
uri: "https://example.com/",
|
||||
title: "BOOKMARK",
|
||||
});
|
||||
|
||||
const before = createContext("example.com", { isPrivate: false });
|
||||
await check_results({
|
||||
context: before,
|
||||
matches: [
|
||||
makeVisitResult(before, {
|
||||
uri: "http://example.com/",
|
||||
title: "VISIT",
|
||||
iconUri: "page-icon:https://example.com/",
|
||||
heuristic: true,
|
||||
providerName: "HistoryUrlHeuristic",
|
||||
}),
|
||||
makeBookmarkResult(before, {
|
||||
uri: "https://example.com/",
|
||||
title: "BOOKMARK",
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
await PlacesUtils.history.clear();
|
||||
|
||||
const after = createContext("example.com", { isPrivate: false });
|
||||
await check_results({
|
||||
context: after,
|
||||
matches: [
|
||||
makeVisitResult(after, {
|
||||
uri: "http://example.com/",
|
||||
title: "BOOKMARK",
|
||||
iconUri: "page-icon:https://example.com/",
|
||||
heuristic: true,
|
||||
providerName: "HistoryUrlHeuristic",
|
||||
}),
|
||||
makeBookmarkResult(after, {
|
||||
uri: "https://example.com/",
|
||||
title: "BOOKMARK",
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
await PlacesUtils.bookmarks.eraseEverything();
|
||||
});
|
||||
|
||||
add_task(async function test_basic() {
|
||||
await PlacesTestUtils.addVisits([
|
||||
{ uri: "https://example.com/", title: "Example COM" },
|
||||
|
||||
Reference in New Issue
Block a user