Bug 1306699 - Only invoke attribution code functionality in desktop Firefox; r=gfritzsche
authorMatt Howell <mhowell@mozilla.com>
Sun, 02 Oct 2016 10:48:47 -0700
changeset 316391 f3f755f8c1e4
parent 316390 122e1eaf7a4c
child 316392 b66170ee0000
push id20656
push userkwierso@gmail.com
push dateWed, 05 Oct 2016 00:44:03 +0000
treeherderfx-team@ea104eeb14cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1306699
milestone52.0a1
Bug 1306699 - Only invoke attribution code functionality in desktop Firefox; r=gfritzsche MozReview-Commit-ID: JMGuP9kI6gD
toolkit/components/telemetry/TelemetryEnvironment.jsm
toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
--- a/toolkit/components/telemetry/TelemetryEnvironment.jsm
+++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm
@@ -764,17 +764,19 @@ function EnvironmentCache() {
     };
   } else {
     this._addonBuilder = new EnvironmentAddonBuilder(this);
     p = [ this._addonBuilder.init() ];
   }
 
   this._currentEnvironment.profile = {};
   p.push(this._updateProfile());
-  p.push(this._updateAttribution());
+  if (AppConstants.MOZ_BUILD_APP == "browser") {
+    p.push(this._updateAttribution());
+  }
 
   let setup = () => {
     this._initTask = null;
     this._startWatchingPrefs();
     this._addonBuilder.watchForChanges();
     this._updateGraphicsFeatures();
     return this.currentEnvironment;
   };
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
@@ -1,22 +1,25 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 Cu.import("resource://gre/modules/AddonManager.jsm");
-Cu.import("resource:///modules/AttributionCode.jsm");
 Cu.import("resource://gre/modules/TelemetryEnvironment.jsm", this);
 Cu.import("resource://gre/modules/Preferences.jsm", this);
 Cu.import("resource://gre/modules/PromiseUtils.jsm", this);
 Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
 Cu.import("resource://testing-common/AddonManagerTesting.jsm");
 Cu.import("resource://testing-common/httpd.js");
 Cu.import("resource://testing-common/MockRegistrar.jsm", this);
 Cu.import("resource://gre/modules/FileUtils.jsm");
 
+// AttributionCode is only needed for Firefox
+XPCOMUtils.defineLazyModuleGetter(this, "AttributionCode",
+                                  "resource:///modules/AttributionCode.jsm");
+
 // Lazy load |LightweightThemeManager|, we won't be using it on Gonk.
 XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
                                   "resource://gre/modules/LightweightThemeManager.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "ProfileAge",
                                   "resource://gre/modules/ProfileAge.jsm");
 
 // The webserver hosting the addons.
@@ -797,18 +800,21 @@ function run_test() {
   gDataRoot = gHttpRoot + "data/";
   gHttpServer.registerDirectory("/data/", do_get_cwd());
   do_register_cleanup(() => gHttpServer.stop(() => {}));
 
   // Spoof the the hotfixVersion
   Preferences.set("extensions.hotfix.lastVersion", APP_HOTFIX_VERSION);
 
   // Create the attribution data file, so that settings.attribution will exist.
-  spoofAttributionData();
-  do_register_cleanup(cleanupAttributionData);
+  // The attribution functionality only exists in Firefox.
+  if (AppConstants.MOZ_BUILD_APP == "browser") {
+    spoofAttributionData();
+    do_register_cleanup(cleanupAttributionData);
+  }
 
   run_next_test();
 }
 
 function isRejected(promise) {
   return new Promise((resolve, reject) => {
     promise.then(() => resolve(false), () => resolve(true));
   });