Bug 1526051 - History tagged results should be returned by the Quantum Bar even if bookmarks are filtered out. r=adw
authorMarco Bonardo <mbonardo@mozilla.com>
Fri, 01 Mar 2019 19:46:52 +0000
changeset 519930 f8f4200ccbb9b054ec7196761287d688e0a55742
parent 519929 86fe7556c9af2059d858e9eb0c7afca4c1ba65d0
child 519931 b64ae766201230bf4215b6ddada1fd4b52ed9e1c
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1526051
milestone67.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 1526051 - History tagged results should be returned by the Quantum Bar even if bookmarks are filtered out. r=adw Differential Revision: https://phabricator.services.mozilla.com/D21702
browser/components/urlbar/UrlbarProviderUnifiedComplete.jsm
browser/components/urlbar/tests/browser/browser_autocomplete_tag_star_visibility.js
--- a/browser/components/urlbar/UrlbarProviderUnifiedComplete.jsm
+++ b/browser/components/urlbar/UrlbarProviderUnifiedComplete.jsm
@@ -331,20 +331,22 @@ function makeUrlbarResult(tokens, info) 
       })
     );
   }
 
   // This is a normal url/title tuple.
   let source;
   let tags = [];
   let comment = info.comment;
-  let hasTags = info.style.includes("tag");
-  if (info.style.includes("bookmark") || hasTags) {
+  // UnifiedComplete may return "bookmark", "bookmark-tag" or "tag". In the last
+  // case it should not be considered a bookmark, but an history item with tags.
+  // We don't show tags for non bookmarked items though.
+  if (info.style.includes("bookmark")) {
     source = UrlbarUtils.RESULT_SOURCE.BOOKMARKS;
-    if (hasTags) {
+    if (info.style.includes("tag")) {
       // Split title and tags.
       [comment, tags] = info.comment.split(TITLE_TAGS_SEPARATOR);
       // Tags are separated by a comma and in a random order.
       // We should also just include tags that match the searchString.
       tags = tags.split(",").map(t => t.trim()).filter(tag => {
         return tokens.some(token => tag.includes(token.value));
       }).sort();
     }
--- a/browser/components/urlbar/tests/browser/browser_autocomplete_tag_star_visibility.js
+++ b/browser/components/urlbar/tests/browser/browser_autocomplete_tag_star_visibility.js
@@ -76,39 +76,38 @@ add_task(async function() {
     },
     input: "^ tagtest5",
     expected: {
       typeImageVisible: false,
     },
   }];
 
   for (let testcase of testcases) {
-    // TODO: Bug 1526051 - Fix searching for tags when suggest.bookmark is false.
-    if (UrlbarPrefs.get("quantumbar") &&
-        (testcase.tagName == "tagtest2" ||
-         testcase.tagName == "tagtest5")) {
-      continue;
-    }
     info(`Test case: ${testcase.description}`);
 
     await addTagItem(testcase.tagName);
     for (let prefName of Object.keys(testcase.prefs)) {
       Services.prefs.setBoolPref(`browser.urlbar.${prefName}`, testcase.prefs[prefName]);
     }
 
     await promiseAutocompleteResultPopup(testcase.input);
 
     Assert.greaterOrEqual(UrlbarTestUtils.getResultCount(window), 2,
       "Should be at least two results");
 
     let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
 
     Assert.equal(result.type, UrlbarUtils.RESULT_TYPE.URL,
       "Should have a URL result type");
-    Assert.deepEqual(result.tags, [testcase.tagName],
+    // The Quantum Bar differs from the legacy urlbar in the fact that, if
+    // bookmarks are filtered out, it won't show tags for history results.
+    let expected_tags = UrlbarPrefs.get("quantumbar") &&
+                        !testcase.expected.typeImageVisible ?
+                        [] : [testcase.tagName];
+    Assert.deepEqual(result.tags, expected_tags,
       "Should have the expected tag");
 
     if (testcase.expected.typeImageVisible) {
       Assert.equal(result.displayed.typeIcon, "url(\"chrome://browser/skin/bookmark.svg\")",
         "Should have the star image displayed or not as expected");
     } else {
       Assert.equal(result.displayed.typeIcon, "none",
         "Should have the star image displayed or not as expected");