Bug 1520833 - Quantumbar history results show the URL instead of the title. r=adw
authorMarco Bonardo <mbonardo@mozilla.com>
Sat, 19 Jan 2019 15:54:44 +0000
changeset 514588 936e2b78ce7cb84299fd66f34b067c36135258d6
parent 514587 ad12ab81d5700ffbbb900eba3c9079d258c58dbc
child 514589 50cc5c5bd5efdb15adda6b1490ecf907f5fe100b
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1520833
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1520833 - Quantumbar history results show the URL instead of the title. r=adw Differential Revision: https://phabricator.services.mozilla.com/D16978
browser/components/urlbar/UrlbarProviderUnifiedComplete.jsm
browser/components/urlbar/tests/unit/test_providerUnifiedComplete.js
--- a/browser/components/urlbar/UrlbarProviderUnifiedComplete.jsm
+++ b/browser/components/urlbar/UrlbarProviderUnifiedComplete.jsm
@@ -300,21 +300,23 @@ function makeUrlbarMatch(tokens, info) {
       ...UrlbarMatch.payloadAndSimpleHighlights(tokens, {
         engine: [info.comment, true],
         icon: [info.icon, false],
       })
     );
   }
 
   // This is a normal url/title tuple.
-  let source, tags, comment;
+  let source;
+  let tags = [];
+  let comment = info.comment;
   let hasTags = info.style.includes("tag");
   if (info.style.includes("bookmark") || hasTags) {
     source = UrlbarUtils.MATCH_SOURCE.BOOKMARKS;
-    if (info.style.includes("tag")) {
+    if (hasTags) {
       // Split title and tags.
       [comment, tags] = info.comment.split(TITLE_TAGS_SEPARATOR);
       tags = tags.split(",").map(t => t.trim());
     }
   } else if (info.style.includes("preloaded-top-sites")) {
     source = UrlbarUtils.MATCH_SOURCE.OTHER_LOCAL;
   } else {
     source = UrlbarUtils.MATCH_SOURCE.HISTORY;
--- a/browser/components/urlbar/tests/unit/test_providerUnifiedComplete.js
+++ b/browser/components/urlbar/tests/unit/test_providerUnifiedComplete.js
@@ -27,28 +27,42 @@ add_task(async function test_unifiedComp
       location: {
         href: AppConstants.BROWSER_CHROME_URL,
       },
     },
   });
   let context = createContext("moz", {isPrivate: false});
 
   // Add entries from multiple sources.
-  await PlacesTestUtils.addVisits("https://history.mozilla.org/");
   await PlacesUtils.bookmarks.insert({
     url: "https://bookmark.mozilla.org/",
+    title: "Test bookmark",
     parentGuid: PlacesUtils.bookmarks.unfiledGuid,
   });
-  await PlacesTestUtils.addVisits("https://tab.mozilla.org/");
+  await PlacesTestUtils.addVisits([
+    {uri: "https://history.mozilla.org/", title: "Test history"},
+    {uri: "https://tab.mozilla.org/", title: "Test tab"},
+  ]);
   UrlbarProviderOpenTabs.registerOpenTab("https://tab.mozilla.org/", 0);
 
   await controller.startQuery(context);
-  dump(context.results.map(m => m.title + " " + m.payload.url) + "\n");
+
+  info("Results:\n" + context.results.map(m => `${m.title} - ${m.payload.url}`).join("\n"));
+  Assert.equal(context.results.length, 6, "Found the expected number of matches");
+
   Assert.deepEqual([
     UrlbarUtils.MATCH_TYPE.SEARCH,
     UrlbarUtils.MATCH_TYPE.SEARCH,
     UrlbarUtils.MATCH_TYPE.SEARCH,
     UrlbarUtils.MATCH_TYPE.URL,
     UrlbarUtils.MATCH_TYPE.TAB_SWITCH,
     UrlbarUtils.MATCH_TYPE.URL,
-  ], context.results.map(m => m.type), "Check matches");
-  Assert.equal(context.results.length, 6, "Found the expected number of matches");
+  ], context.results.map(m => m.type), "Check match types");
+
+  Assert.deepEqual([
+    "moz",
+    "moz foo",
+    "moz bar",
+    "Test bookmark",
+    "Test tab",
+    "Test history",
+  ], context.results.map(m => m.title), "Check match titles");
 });