Backed out changeset 55278c1dc745 (bug 1203161) for browser_searchbar_keyboard_navigation.js failures CLOSED TREE
authorWes Kocher <wkocher@mozilla.com>
Fri, 11 Sep 2015 11:08:29 -0700
changeset 294743 dde32e10af8bb50d897f8f40986efb57b3a1595c
parent 294742 7ae566736bc0125dfd77872768ed29ae274b1d63
child 294744 6dbfe6719621efde26304de20ebf9c6e2cf1f1b2
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1203161
milestone43.0a1
backs out55278c1dc745849da20726f569407a25eacacbac
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
Backed out changeset 55278c1dc745 (bug 1203161) for browser_searchbar_keyboard_navigation.js failures CLOSED TREE
toolkit/components/search/nsSearchService.js
--- a/toolkit/components/search/nsSearchService.js
+++ b/toolkit/components/search/nsSearchService.js
@@ -2069,64 +2069,67 @@ Engine.prototype = {
         if (aWidth && aHeight) {
           this._addIconToMap(aWidth, aHeight, aIconURL)
         }
         break;
       case "http":
       case "https":
       case "ftp":
         // No use downloading the icon if the engine file is read-only
-        LOG("_setIcon: Downloading icon: \"" + uri.spec +
-            "\" for engine: \"" + this.name + "\"");
-        var chan = NetUtil.ioService.newChannelFromURI2(uri,
-                                                        null,      // aLoadingNode
-                                                        Services.scriptSecurityManager.getSystemPrincipal(),
-                                                        null,      // aTriggeringPrincipal
-                                                        Ci.nsILoadInfo.SEC_NORMAL,
-                                                        Ci.nsIContentPolicy.TYPE_IMAGE);
-
-        let iconLoadCallback = function (aByteArray, aEngine) {
-          // This callback may run after we've already set a preferred icon,
-          // so check again.
-          if (aEngine._hasPreferredIcon && !aIsPreferred)
-            return;
-
-          if (!aByteArray || aByteArray.length > MAX_ICON_SIZE) {
-            LOG("iconLoadCallback: load failed, or the icon was too large!");
-            return;
+        if (!this._readOnly ||
+            getBoolPref(BROWSER_SEARCH_PREF + "cache.enabled", true)) {
+          LOG("_setIcon: Downloading icon: \"" + uri.spec +
+              "\" for engine: \"" + this.name + "\"");
+          var chan = NetUtil.ioService.newChannelFromURI2(uri,
+                                                          null,      // aLoadingNode
+                                                          Services.scriptSecurityManager.getSystemPrincipal(),
+                                                          null,      // aTriggeringPrincipal
+                                                          Ci.nsILoadInfo.SEC_NORMAL,
+                                                          Ci.nsIContentPolicy.TYPE_IMAGE);
+
+          let iconLoadCallback = function (aByteArray, aEngine) {
+            // This callback may run after we've already set a preferred icon,
+            // so check again.
+            if (aEngine._hasPreferredIcon && !aIsPreferred)
+              return;
+
+            if (!aByteArray || aByteArray.length > MAX_ICON_SIZE) {
+              LOG("iconLoadCallback: load failed, or the icon was too large!");
+              return;
+            }
+
+            var str = btoa(String.fromCharCode.apply(null, aByteArray));
+            let dataURL = ICON_DATAURL_PREFIX + str;
+            aEngine._iconURI = makeURI(dataURL);
+
+            if (aWidth && aHeight) {
+              aEngine._addIconToMap(aWidth, aHeight, dataURL)
+            }
+
+            // The engine might not have a file yet, if it's being downloaded,
+            // because the request for the engine file itself (_onLoad) may not
+            // yet be complete. In that case, this change will be written to
+            // file when _onLoad is called. For readonly engines, we'll store
+            // the changes in the cache once notified below.
+            if (aEngine._file && !aEngine._readOnly)
+              aEngine._serializeToFile();
+
+            notifyAction(aEngine, SEARCH_ENGINE_CHANGED);
+            aEngine._hasPreferredIcon = aIsPreferred;
           }
 
-          var str = btoa(String.fromCharCode.apply(null, aByteArray));
-          let dataURL = ICON_DATAURL_PREFIX + str;
-          aEngine._iconURI = makeURI(dataURL);
-
-          if (aWidth && aHeight) {
-            aEngine._addIconToMap(aWidth, aHeight, dataURL)
-          }
-
-          // The engine might not have a file yet, if it's being downloaded,
-          // because the request for the engine file itself (_onLoad) may not
-          // yet be complete. In that case, this change will be written to
-          // file when _onLoad is called. For readonly engines, we'll store
-          // the changes in the cache once notified below.
-          if (aEngine._file && !aEngine._readOnly)
-            aEngine._serializeToFile();
-
-          notifyAction(aEngine, SEARCH_ENGINE_CHANGED);
-          aEngine._hasPreferredIcon = aIsPreferred;
+          // If we're currently acting as an "update engine", then the callback
+          // should set the icon on the engine we're updating and not us, since
+          // |this| might be gone by the time the callback runs.
+          var engineToSet = this._engineToUpdate || this;
+
+          var listener = new loadListener(chan, engineToSet, iconLoadCallback);
+          chan.notificationCallbacks = listener;
+          chan.asyncOpen(listener, null);
         }
-
-        // If we're currently acting as an "update engine", then the callback
-        // should set the icon on the engine we're updating and not us, since
-        // |this| might be gone by the time the callback runs.
-        var engineToSet = this._engineToUpdate || this;
-
-        var listener = new loadListener(chan, engineToSet, iconLoadCallback);
-        chan.notificationCallbacks = listener;
-        chan.asyncOpen(listener, null);
         break;
     }
   },
 
   /**
    * Initialize this Engine object from the collected data.
    */
   _initFromData: function SRCH_ENG_initFromData() {
@@ -3606,16 +3609,19 @@ SearchService.prototype = {
     return this.getEngineByName(defaultEngine);
   },
 
   resetToOriginalDefaultEngine: function SRCH_SVC__resetToOriginalDefaultEngine() {
     this.currentEngine = this._originalDefaultEngine;
   },
 
   _buildCache: function SRCH_SVC__buildCache() {
+    if (!getBoolPref(BROWSER_SEARCH_PREF + "cache.enabled", true))
+      return;
+
     TelemetryStopwatch.start("SEARCH_SERVICE_BUILD_CACHE_MS");
     let cache = {};
     let locale = getLocale();
     let buildID = Services.appinfo.platformBuildID;
 
     // Allows us to force a cache refresh should the cache format change.
     cache.version = CACHE_VERSION;
     // We don't want to incur the costs of stat()ing each plugin on every
@@ -3686,20 +3692,23 @@ SearchService.prototype = {
     }
     TelemetryStopwatch.finish("SEARCH_SERVICE_BUILD_CACHE_MS");
   },
 
   _syncLoadEngines: function SRCH_SVC__syncLoadEngines() {
     LOG("_syncLoadEngines: start");
     // See if we have a cache file so we don't have to parse a bunch of XML.
     let cache = {};
-    let cacheFile = getDir(NS_APP_USER_PROFILE_50_DIR);
-    cacheFile.append("search.json");
-    if (cacheFile.exists())
-      cache = this._readCacheFile(cacheFile);
+    let cacheEnabled = getBoolPref(BROWSER_SEARCH_PREF + "cache.enabled", true);
+    if (cacheEnabled) {
+      let cacheFile = getDir(NS_APP_USER_PROFILE_50_DIR);
+      cacheFile.append("search.json");
+      if (cacheFile.exists())
+        cache = this._readCacheFile(cacheFile);
+    }
 
     let [chromeFiles, chromeURIs] = this._findJAREngines();
 
     let distDirs = [];
     let locations;
     try {
       locations = getDir(NS_APP_DISTRIBUTION_SEARCH_DIR_LIST,
                          Ci.nsISimpleEnumerator);
@@ -3742,25 +3751,26 @@ SearchService.prototype = {
                        cache.locale != getLocale() ||
                        cache.buildID != buildID ||
                        cachePaths.length != toLoad.length ||
                        toLoad.some(notInCachePath) ||
                        cache.visibleDefaultEngines.length != this._visibleDefaultEngines.length ||
                        this._visibleDefaultEngines.some(notInCacheVisibleEngines) ||
                        toLoad.some(modifiedDir);
 
-    if (rebuildCache) {
+    if (!cacheEnabled || rebuildCache) {
       LOG("_loadEngines: Absent or outdated cache. Loading engines from disk.");
       distDirs.forEach(this._loadEnginesFromDir, this);
 
       this._loadFromChromeURLs(chromeURIs);
 
       otherDirs.forEach(this._loadEnginesFromDir, this);
 
-      this._buildCache();
+      if (cacheEnabled)
+        this._buildCache();
       return;
     }
 
     LOG("_loadEngines: loading from cache directories");
     for each (let dir in cache.directories)
       this._loadEnginesFromCache(dir);
 
     LOG("_loadEngines: done");
@@ -3772,18 +3782,21 @@ SearchService.prototype = {
    * @returns {Promise} A promise, resolved successfully if loading data
    * succeeds.
    */
   _asyncLoadEngines: function SRCH_SVC__asyncLoadEngines() {
     return Task.spawn(function() {
       LOG("_asyncLoadEngines: start");
       // See if we have a cache file so we don't have to parse a bunch of XML.
       let cache = {};
-      let cacheFilePath = OS.Path.join(OS.Constants.Path.profileDir, "search.json");
-      cache = yield checkForSyncCompletion(this._asyncReadCacheFile(cacheFilePath));
+      let cacheEnabled = getBoolPref(BROWSER_SEARCH_PREF + "cache.enabled", true);
+      if (cacheEnabled) {
+        let cacheFilePath = OS.Path.join(OS.Constants.Path.profileDir, "search.json");
+        cache = yield checkForSyncCompletion(this._asyncReadCacheFile(cacheFilePath));
+      }
 
       Services.obs.notifyObservers(null, SEARCH_SERVICE_TOPIC, "find-jar-engines");
       let [chromeFiles, chromeURIs] =
         yield checkForSyncCompletion(this._asyncFindJAREngines());
 
       // Get the non-empty distribution directories into distDirs...
       let distDirs = [];
       let locations;
@@ -3864,17 +3877,17 @@ SearchService.prototype = {
                          cache.locale != getLocale() ||
                          cache.buildID != buildID ||
                          cachePaths.length != toLoad.length ||
                          toLoad.some(notInCachePath) ||
                          cache.visibleDefaultEngines.length != this._visibleDefaultEngines.length ||
                          this._visibleDefaultEngines.some(notInCacheVisibleEngines) ||
                          (yield checkForSyncCompletion(hasModifiedDir(toLoad)));
 
-      if (rebuildCache) {
+      if (!cacheEnabled || rebuildCache) {
         LOG("_asyncLoadEngines: Absent or outdated cache. Loading engines from disk.");
         let engines = [];
         for (let loadDir of distDirs) {
           let enginesFromDir =
             yield checkForSyncCompletion(this._asyncLoadEnginesFromDir(loadDir));
           engines = engines.concat(enginesFromDir);
         }
         let enginesFromURLs =
@@ -3884,17 +3897,18 @@ SearchService.prototype = {
           let enginesFromDir =
             yield checkForSyncCompletion(this._asyncLoadEnginesFromDir(loadDir));
           engines = engines.concat(enginesFromDir);
         }
 
         for (let engine of engines) {
           this._addEngineToStore(engine);
         }
-        this._buildCache();
+        if (cacheEnabled)
+          this._buildCache();
         return;
       }
 
       LOG("_asyncLoadEngines: loading from cache directories");
       for each (let dir in cache.directories)
         this._loadEnginesFromCache(dir);
 
       LOG("_asyncLoadEngines: done");
@@ -5526,16 +5540,22 @@ var engineUpdateService = {
   },
 
   update: function eus_Update(aEngine) {
     let engine = aEngine.wrappedJSObject;
     ULOG("update called for " + aEngine._name);
     if (!getBoolPref(BROWSER_SEARCH_PREF + "update", true) || !engine._hasUpdates)
       return;
 
+    // We use the cache to store updated app engines, so refuse to update if the
+    // cache is disabled.
+    if (engine._readOnly &&
+        !getBoolPref(BROWSER_SEARCH_PREF + "cache.enabled", true))
+      return;
+
     let testEngine = null;
     let updateURL = engine._getURLOfType(URLTYPE_OPENSEARCH);
     let updateURI = (updateURL && updateURL._hasRelation("self")) ?
                      updateURL.getSubmission("", engine).uri :
                      makeURI(engine._updateURL);
     if (updateURI) {
       if (engine._isDefault && !updateURI.schemeIs("https")) {
         ULOG("Invalid scheme for default engine update");