Bug 1545025 - Switch to tab entries having bookmark tags show a title containing tags. r=adw
authorMarco Bonardo <mbonardo@mozilla.com>
Wed, 17 Apr 2019 17:06:01 +0000
changeset 469879 f4eee626f2c84eeac8aa5033ebceeec0a4419706
parent 469878 5506b872b4e58dcaeaa6b887107a2258456a5d70
child 469880 02b89c29412b6c1444fe32a4847e5261e2bb3d00
push id35883
push userbtara@mozilla.com
push dateWed, 17 Apr 2019 21:47:29 +0000
treeherdermozilla-central@02b89c29412b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1545025
milestone68.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 1545025 - Switch to tab entries having bookmark tags show a title containing tags. r=adw Differential Revision: https://phabricator.services.mozilla.com/D27916
toolkit/components/places/UnifiedComplete.jsm
toolkit/components/places/tests/unifiedcomplete/test_tab_matches.js
--- a/toolkit/components/places/UnifiedComplete.jsm
+++ b/toolkit/components/places/UnifiedComplete.jsm
@@ -2226,20 +2226,21 @@ Search.prototype = {
       action = "switchtab";
       if (frecency == null)
         frecency = FRECENCY_DEFAULT;
     }
 
     // Always prefer the bookmark title unless it is empty
     let title = bookmarkTitle || historyTitle;
 
-    // We will always prefer to show tags if we have them.
-    let showTags = !!tags;
+    // Return tags as part of the title, unless the match has an action, like
+    // switch-to-tab, that doesn't care about them.
+    let showTags = !!tags && !action;
 
-    // However, we'll act as if a page is not bookmarked if the user wants
+    // We'll act as if the page is not bookmarked when the user wants
     // only history and not bookmarks and there are no tags.
     if (this.hasBehavior("history") && !this.hasBehavior("bookmark") &&
         !showTags) {
       showTags = false;
       match.style = "favicon";
     }
 
     // If we have tags and should show them, we need to add them to the title.
--- a/toolkit/components/places/tests/unifiedcomplete/test_tab_matches.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_tab_matches.js
@@ -157,10 +157,27 @@ add_task(async function test_tab_matches
     search: UrlbarTokenizer.RESTRICT.OPENPAGE,
     searchParam: "enable-actions",
     matches: [ makeSearchMatch(UrlbarTokenizer.RESTRICT.OPENPAGE, { heuristic: true }),
                makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
                makeSwitchToTabMatch("about:mozilla"),
                makeSwitchToTabMatch("data:text/html,test") ],
   });
 
+  info("tab match should not return tags as part of the title");
+  // Bookmark one of the pages, and add tags to it, to check they don't appear
+  // in the title.
+  let bm = await PlacesUtils.bookmarks.insert({
+    url: uri1,
+    parentGuid: PlacesUtils.bookmarks.toolbarGuid,
+  });
+  PlacesUtils.tagging.tagURI(uri1, ["test-tag"]);
+  await check_autocomplete({
+    search: "abc.com",
+    searchParam: "enable-actions",
+    matches: [ makeVisitMatch("abc.com", "http://abc.com/", { heuristic: true }),
+               makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
+               makeSearchMatch("abc.com", { heuristic: false }) ],
+  });
+  await PlacesUtils.bookmarks.remove(bm);
+
   await cleanup();
 });