Bug 1411867 - Linux repacks detected as unofficial builds. r=k88hudson
MozReview-Commit-ID: 7itcGkDxKZx
--- 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()