Bug 1520833 - Quantumbar history results show the URL instead of the title. r=adw
☠☠ backed out by 57dc8bbbc38f ☠ ☠
authorMarco Bonardo <mbonardo@mozilla.com>
Fri, 18 Jan 2019 20:14:48 +0000
changeset 514474 2227c747a95b2e907460217a3c0860f54cf36243
parent 514473 1e0f41f31abe7f400525b736151cbbb73b83d4fd
child 514475 1b73f4cd7208ac91d88a0b1c98e87cd407f10f43
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([
+    "engine-suggestions.xml",
+    "engine-suggestions.xml",
+    "engine-suggestions.xml",
+    "Test bookmark",
+    "Test tab",
+    "Test history",
+  ], context.results.map(m => m.title), "Check match titles");
 });