Bug 1096248 - Disable restyling of autocomplete search page items. r=paolo
☠☠ backed out by 5873d2c735d1 ☠ ☠
authorBlair McBride <bmcbride@mozilla.com>
Wed, 12 Nov 2014 23:24:28 +1300
changeset 215268 ed42b5ee3c943bf7bbeff0584a3f19fb6fdd971e
parent 215267 fb67e4e32ef20154f9ac5021319a9391ddd39d5c
child 215269 210b1691f0c71a662adccb43d766e335c4135e3e
push id51731
push userryanvm@gmail.com
push dateWed, 12 Nov 2014 20:52:34 +0000
treeherdermozilla-inbound@90731dbaab2d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo
bugs1096248
milestone36.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 1096248 - Disable restyling of autocomplete search page items. r=paolo
toolkit/components/places/UnifiedComplete.js
toolkit/components/places/tests/unifiedcomplete/test_searchEngine_restyle.js
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -17,16 +17,17 @@ const DEFAULT_BEHAVIOR = 0;
 
 const PREF_BRANCH = "browser.urlbar.";
 
 // Prefs are defined as [pref name, default value].
 const PREF_ENABLED =                [ "autocomplete.enabled",   true ];
 const PREF_AUTOFILL =               [ "autoFill",               true ];
 const PREF_AUTOFILL_TYPED =         [ "autoFill.typed",         true ];
 const PREF_AUTOFILL_SEARCHENGINES = [ "autoFill.searchEngines", true ];
+const PREF_RESTYLESEARCHES        = [ "restyleSearches",        false ];
 const PREF_DELAY =                  [ "delay",                  50 ];
 const PREF_BEHAVIOR =               [ "matchBehavior", MATCH_BOUNDARY_ANYWHERE ];
 const PREF_DEFAULT_BEHAVIOR =       [ "default.behavior", DEFAULT_BEHAVIOR ];
 const PREF_EMPTY_BEHAVIOR =         [ "default.behavior.emptyRestriction",
                                       Ci.mozIPlacesAutoComplete.BEHAVIOR_HISTORY |
                                       Ci.mozIPlacesAutoComplete.BEHAVIOR_TYPED ];
 const PREF_FILTER_JS =              [ "filter.javascript",      true ];
 const PREF_MAXRESULTS =             [ "maxRichResults",         25 ];
@@ -366,16 +367,17 @@ XPCOMUtils.defineLazyGetter(this, "Switc
 XPCOMUtils.defineLazyGetter(this, "Prefs", () => {
   let prefs = new Preferences(PREF_BRANCH);
 
   function loadPrefs() {
     store.enabled = prefs.get(...PREF_ENABLED);
     store.autofill = prefs.get(...PREF_AUTOFILL);
     store.autofillTyped = prefs.get(...PREF_AUTOFILL_TYPED);
     store.autofillSearchEngines = prefs.get(...PREF_AUTOFILL_SEARCHENGINES);
+    store.restyleSearches = prefs.get(...PREF_RESTYLESEARCHES);
     store.delay = prefs.get(...PREF_DELAY);
     store.matchBehavior = prefs.get(...PREF_BEHAVIOR);
     store.filterJavaScript = prefs.get(...PREF_FILTER_JS);
     store.maxRichResults = prefs.get(...PREF_MAXRESULTS);
     store.restrictHistoryToken = prefs.get(...PREF_RESTRICT_HISTORY);
     store.restrictBookmarkToken = prefs.get(...PREF_RESTRICT_BOOKMARKS);
     store.restrictTypedToken = prefs.get(...PREF_RESTRICT_TYPED);
     store.restrictTagToken = prefs.get(...PREF_RESTRICT_TAG);
@@ -1039,17 +1041,17 @@ Search.prototype = {
         this._usedPlaceIds.add(match.placeId);
       this._usedURLs.add(urlMapKey);
 
       if (!match.style) {
         match.style = "favicon";
       }
 
       // Restyle past searches, unless they are bookmarks or special results.
-      if (match.style == "favicon") {
+      if (Prefs.restyleSearches && match.style == "favicon") {
         this._maybeRestyleSearchMatch(match);
       }
 
       this._result.appendMatch(match.value,
                                match.comment,
                                match.icon || PlacesUtils.favicons.defaultFavicon.spec,
                                match.style,
                                match.finalCompleteValue || "");
--- a/toolkit/components/places/tests/unifiedcomplete/test_searchEngine_restyle.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_searchEngine_restyle.js
@@ -10,16 +10,25 @@ add_task(function* test_searchEngine() {
   do_register_cleanup(() => Services.search.removeEngine(engine));
 
   let uri1 = NetUtil.newURI("http://s.example.com/search?q=Terms&client=1");
   let uri2 = NetUtil.newURI("http://s.example.com/search?q=Terms&client=2");
   yield promiseAddVisits({ uri: uri1, title: "Terms - SearchEngine Search" });
   addBookmark({ uri: uri2, title: "Terms - SearchEngine Search" });
 
   do_log_info("Past search terms should be styled, unless bookmarked");
+  Services.prefs.setBoolPref("browser.urlbar.restyleSearches", true);
   yield check_autocomplete({
     search: "term",
     matches: [ { uri: uri1, title: "Terms", searchEngine: "SearchEngine", style: ["favicon", "search"] },
                { uri: uri2, title: "Terms - SearchEngine Search", style: ["bookmark"] } ]
   });
 
+  do_log_info("Past search terms should not be styled if restyling is disabled");
+  Services.prefs.setBoolPref("browser.urlbar.restyleSearches", false);
+  yield check_autocomplete({
+    search: "term",
+    matches: [ { uri: uri1, title: "Terms - SearchEngine Search" },
+               { uri: uri2, title: "Terms - SearchEngine Search", style: ["bookmark"] } ]
+  });
+
   yield cleanup();
 });