Bug 1289240 - Search plugins from an in-use langpack should be treated as default plugins. r=adw, a=sledru
authorFlorian Quèze <florian@queze.net>
Wed, 27 Jul 2016 19:28:33 +0200
changeset 340149 de2e1b678ebdf59843d0438cedf893cc8e3df132
parent 340148 ef0e06a0e51afd014ba6f880f686dbb1c3a00272
child 340150 1a2331a741876542f14ad82f4c5264d70f98c832
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw, sledru
bugs1289240
milestone49.0a2
Bug 1289240 - Search plugins from an in-use langpack should be treated as default plugins. r=adw, a=sledru
toolkit/components/search/nsSearchService.js
--- a/toolkit/components/search/nsSearchService.js
+++ b/toolkit/components/search/nsSearchService.js
@@ -2293,35 +2293,35 @@ Engine.prototype = {
     if (!this._shortName)
       return false;
 
     // An engine is a default one if we initially loaded it from the application
     // or distribution directory.
     if (/^(?:jar:)?(?:\[app\]|\[distribution\])/.test(this._loadPath))
       return true;
 
-    // If we are in the xpcshell test case, we'll accept as a 'default' engine
-    // anything that has been registered at resource://search-plugins/ even if
-    // the file doesn't come from the application folder.
-    // If not, skip costly additional checks.
-    if (!gEnvironment.get("XPCSHELL_TEST_PROFILE_DIR"))
+    // If we are using a non-default locale or in the xpcshell test case,
+    // we'll accept as a 'default' engine anything that has been registered at
+    // resource://search-plugins/ even if the file doesn't come from the
+    // application folder.  If not, skip costly additional checks.
+    if (!Services.prefs.prefHasUserValue(LOCALE_PREF) &&
+        !gEnvironment.get("XPCSHELL_TEST_PROFILE_DIR"))
       return false;
 
     // Some xpcshell tests use the search service without registering
     // resource://search-plugins/.
     if (!Services.io.getProtocolHandler("resource")
                  .QueryInterface(Ci.nsIResProtocolHandler)
                  .hasSubstitution("search-plugins"))
       return false;
 
     let uri = makeURI(APP_SEARCH_PREFIX + this._shortName + ".xml");
     if (this.getAnonymizedLoadPath(null, uri) == this._loadPath) {
       // This isn't a real default engine, but it's very close.
-      LOG("_isDefault, pretending " + this._loadPath +
-          " is a default engine for testing purposes");
+      LOG("_isDefault, pretending " + this._loadPath + " is a default engine");
       return true;
     }
 
     return false;
   },
 
   get _hasUpdates() {
     // Whether or not the engine has an update URL
@@ -2428,16 +2428,17 @@ Engine.prototype = {
     if (!aResponseType) {
       aResponseType = URLTYPE_SEARCH_HTML;
     }
 
     if (aResponseType == URLTYPE_SEARCH_HTML &&
         Services.prefs.getDefaultBranch(BROWSER_SEARCH_PREF).getBoolPref("reset.enabled") &&
         this.name == Services.search.currentEngine.name &&
         !this._isDefault &&
+        this.name != Services.search.originalDefaultEngine.name &&
         (!this.getAttr("loadPathHash") ||
          this.getAttr("loadPathHash") != getVerificationHash(this._loadPath)) &&
         !this._isWhiteListed) {
       let url = "about:searchreset";
       let data = [];
       if (aData)
         data.push("data=" + encodeURIComponent(aData));
       if (aPurpose)