Bug 1411867 - Linux repacks detected as unofficial builds. r=k88hudson, a=gchang
authorAndrei Oprea <andrei.br92@gmail.com>
Thu, 30 Nov 2017 18:24:12 +0100
changeset 442664 7fe3a16c32f703bc9ff5f8a8906e11b1f44d6664
parent 442663 acde061a61096717fc3ccc904d78298f72645adc
child 442665 6ff9a23d3212300a97e3779364e5afa66cfc280b
push id8293
push userryanvm@gmail.com
push dateSat, 02 Dec 2017 23:04:14 +0000
treeherdermozilla-beta@18524c7a40b3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersk88hudson, gchang
bugs1411867
milestone58.0
Bug 1411867 - Linux repacks detected as unofficial builds. r=k88hudson, a=gchang MozReview-Commit-ID: 7itcGkDxKZx
browser/extensions/activity-stream/lib/ActivityStreamPrefs.jsm
browser/extensions/activity-stream/test/unit/lib/ActivityStreamPrefs.test.js
browser/extensions/activity-stream/test/unit/unit-entry.js
--- a/browser/extensions/activity-stream/lib/ActivityStreamPrefs.jsm
+++ b/browser/extensions/activity-stream/lib/ActivityStreamPrefs.jsm
@@ -1,14 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 const {utils: Cu} = Components;
+Cu.import("resource://gre/modules/AppConstants.jsm");
 Cu.import("resource://gre/modules/Preferences.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 const ACTIVITY_STREAM_PREF_BRANCH = "browser.newtabpage.activity-stream.";
 
 this.Prefs = class Prefs extends Preferences {
   /**
    * Prefs - A wrapper around Preferences that always sets the branch to
@@ -70,19 +71,18 @@ this.DefaultPrefs = class DefaultPrefs {
         break;
     }
   }
 
   /**
    * init - Set default prefs for all prefs in the config
    */
   init() {
-    // If Firefox is a locally built version or a testing build on try, etc.
-    // the value of the app.update.channel pref should be "default"
-    const IS_UNOFFICIAL_BUILD = Services.prefs.getStringPref("app.update.channel") === "default";
+    // Local developer builds (with the default mozconfig) aren't OFFICIAL
+    const IS_UNOFFICIAL_BUILD = !AppConstants.MOZILLA_OFFICIAL;
 
     for (const pref of this._config.keys()) {
       const prefConfig = this._config.get(pref);
       let value;
       if (IS_UNOFFICIAL_BUILD && "value_local_dev" in prefConfig) {
         value = prefConfig.value_local_dev;
       } else {
         value = prefConfig.value;
--- a/browser/extensions/activity-stream/test/unit/lib/ActivityStreamPrefs.test.js
+++ b/browser/extensions/activity-stream/test/unit/lib/ActivityStreamPrefs.test.js
@@ -96,18 +96,22 @@ describe("ActivityStreamPrefs", () => {
       it("should initialize a string pref", () => {
         defaultPrefs.init();
         assert.calledWith(defaultPrefs.branch.setStringPref, "bar", "BAR");
       });
       it("should initialize a integer pref", () => {
         defaultPrefs.init();
         assert.calledWith(defaultPrefs.branch.setIntPref, "baz", 1);
       });
+      it("should initialize a pref with value if Firefox is not a local build", () => {
+        defaultPrefs.init();
+        assert.calledWith(defaultPrefs.branch.setStringPref, "qux", "foo");
+      });
       it("should initialize a pref with value_local_dev if Firefox is a local build", () => {
-        sandbox.stub(global.Services.prefs, "getStringPref").returns("default");
+        sandbox.stub(global.AppConstants, "MOZILLA_OFFICIAL").value(false);
         defaultPrefs.init();
         assert.calledWith(defaultPrefs.branch.setStringPref, "qux", "foofoo");
       });
     });
     describe("#reset", () => {
       it("should clear user preferences for each pref in the config", () => {
         const defaultPrefs = new DefaultPrefs(TEST_PREF_CONFIG);
         sinon.spy(defaultPrefs.branch, "clearUserPref");
--- a/browser/extensions/activity-stream/test/unit/unit-entry.js
+++ b/browser/extensions/activity-stream/test/unit/unit-entry.js
@@ -7,16 +7,17 @@ const files = req.keys();
 // This exposes sinon assertions to chai.assert
 sinon.assert.expose(assert, {prefix: ""});
 
 chai.use(chaiAssertions);
 
 let overrider = new GlobalOverrider();
 
 overrider.set({
+  AppConstants: {MOZILLA_OFFICIAL: true},
   Components: {
     classes: {},
     interfaces: {},
     utils: {
       import() {},
       importGlobalProperties() {},
       reportError() {},
       now: () => window.performance.now()