Bug 1180673 - Part 1 - Use a different URL pref for healthreport when Unified Telemetry is on and opt-out. r=bsmedberg
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Wed, 29 Jul 2015 16:59:52 +0200
changeset 288243 0557c248da59c0e4d3a0505d0936dc001d24d78e
parent 288242 9fc0f0ba0cca12c09379aa95bdb798ac0fc937be
child 288244 7e98222202e4f9079cba2ccda07c624516d13a77
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs1180673
milestone42.0a1
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
Bug 1180673 - Part 1 - Use a different URL pref for healthreport when Unified Telemetry is on and opt-out. r=bsmedberg
browser/base/content/abouthealthreport/abouthealth.js
browser/base/content/test/general/browser_aboutHealthReport.js
services/healthreport/docs/architecture.rst
services/healthreport/healthreport-prefs.js
testing/profiles/prefs_general.js
--- a/browser/base/content/abouthealthreport/abouthealth.js
+++ b/browser/base/content/abouthealthreport/abouthealth.js
@@ -6,16 +6,23 @@
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/Preferences.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 const prefs = new Preferences("datareporting.healthreport.");
 
+const PREF_UNIFIED = "toolkit.telemetry.unified";
+const PREF_UNIFIED_OPTIN = "toolkit.telemetry.unifiedIsOptIn";
+
+// Whether v4 behavior is enabled, i.e. unified Telemetry features are on by default.
+const IS_V4 = Preferences.get(PREF_UNIFIED, false) &&
+              !Preferences.get(PREF_UNIFIED_OPTIN, false);
+
 let healthReportWrapper = {
   init: function () {
     let iframe = document.getElementById("remote-report");
     iframe.addEventListener("load", healthReportWrapper.initRemotePage, false);
     iframe.src = this._getReportURI().spec;
     iframe.onload = () => {
       MozSelfSupport.getHealthReportPayload().then(this.updatePayload,
                                                    this.handleInitFailure);
@@ -23,17 +30,19 @@ let healthReportWrapper = {
     prefs.observe("uploadEnabled", this.updatePrefState, healthReportWrapper);
   },
 
   uninit: function () {
     prefs.ignore("uploadEnabled", this.updatePrefState, healthReportWrapper);
   },
 
   _getReportURI: function () {
-    let url = Services.urlFormatter.formatURLPref("datareporting.healthreport.about.reportUrl");
+    const pref = IS_V4 ? "datareporting.healthreport.about.reportUrl"
+                       : "datareporting.healthreport.about.reportUrlUnified";
+    let url = Services.urlFormatter.formatURLPref(pref);
     return Services.io.newURI(url, null, null);
   },
 
   setDataSubmission: function (enabled) {
     MozSelfSupport.healthReportDataSubmissionEnabled = enabled;
     this.updatePrefState();
   },
 
--- a/browser/base/content/test/general/browser_aboutHealthReport.js
+++ b/browser/base/content/test/general/browser_aboutHealthReport.js
@@ -8,26 +8,30 @@ XPCOMUtils.defineLazyModuleGetter(this, 
   "resource://gre/modules/Task.jsm");
 
 const CHROME_BASE = "chrome://mochitests/content/browser/browser/base/content/test/general/";
 const HTTPS_BASE = "https://example.com/browser/browser/base/content/test/general/";
 
 const TELEMETRY_LOG_PREF = "toolkit.telemetry.log.level";
 const telemetryOriginalLogPref = Preferences.get(TELEMETRY_LOG_PREF, null);
 
+const originalReportUrl = Services.prefs.getCharPref("datareporting.healthreport.about.reportUrl");
+const originalReportUrlUnified = Services.prefs.getCharPref("datareporting.healthreport.about.reportUrlUnified");
+
 registerCleanupFunction(function() {
   // Ensure we don't pollute prefs for next tests.
   if (telemetryOriginalLogPref) {
     Preferences.set(TELEMETRY_LOG_PREF, telemetryOriginalLogPref);
   } else {
     Preferences.reset(TELEMETRY_LOG_PREF);
   }
 
   try {
-    Services.prefs.clearUserPref("datareporting.healthreport.about.reportUrl");
+    Services.prefs.setCharPref("datareporting.healthreport.about.reportUrl", originalReportUrl);
+    Services.prefs.setCharPref("datareporting.healthreport.about.reportUrlUnified", originalReportUrlUnified);
     let policy = Cc["@mozilla.org/datareporting/service;1"]
                  .getService(Ci.nsISupports)
                  .wrappedJSObject
                  .policy;
     policy.recordHealthReportUploadEnabled(true,
                                            "Resetting after tests.");
   } catch (ex) {}
 });
@@ -65,16 +69,18 @@ let gTests = [
 {
   desc: "Test the remote commands",
   setup: Task.async(function*()
   {
     Preferences.set(TELEMETRY_LOG_PREF, "Trace");
     yield setupPingArchive();
     Preferences.set("datareporting.healthreport.about.reportUrl",
                     HTTPS_BASE + "healthreport_testRemoteCommands.html");
+    Preferences.set("datareporting.healthreport.about.reportUrlUnified",
+                    HTTPS_BASE + "healthreport_testRemoteCommands.html");
   }),
   run: function (iframe)
   {
     let deferred = Promise.defer();
 
     let policy = Cc["@mozilla.org/datareporting/service;1"]
                  .getService(Ci.nsISupports)
                  .wrappedJSObject
--- a/services/healthreport/docs/architecture.rst
+++ b/services/healthreport/docs/architecture.rst
@@ -78,16 +78,19 @@ documentServerNamespace
 
 infoURL
    The URL of a page containing more info about FHR, it's privacy
    policy, etc.
 
 about.reportUrl
    The URL to load in ``about:healthreport``.
 
+about.reportUrlUnified
+   The URL to load in ``about:healthreport``. This is used instead of ``reportUrl`` for UnifiedTelemetry when it is not opt-in.
+
 service.providerCategories
    A comma-delimited list of category manager categories that contain
    registered ``Metrics.Provider`` records. Read below for how provider
    registration works.
 
 If the entire service is disabled, you lose data collection. This means
 that **local** data analysis won't be available because there is no data
 to analyze! Keep in mind that Firefox Health Report can be useful even
--- a/services/healthreport/healthreport-prefs.js
+++ b/services/healthreport/healthreport-prefs.js
@@ -29,9 +29,10 @@ pref("datareporting.healthreport.service
     "healthreport-js-provider-default"
 #elif MOZ_UPDATE_CHANNEL == default
     "healthreport-js-provider-default"
 #else
     "healthreport-js-provider-default,healthreport-js-provider-@MOZ_UPDATE_CHANNEL@"
 #endif
     );
 
-pref("datareporting.healthreport.about.reportUrl",   "https://fhr.cdn.mozilla.net/%LOCALE%/");
+pref("datareporting.healthreport.about.reportUrl", "https://fhr.cdn.mozilla.net/%LOCALE%/");
+pref("datareporting.healthreport.about.reportUrlUnified", "https://fhr.cdn.mozilla.net/%LOCALE%/");
--- a/testing/profiles/prefs_general.js
+++ b/testing/profiles/prefs_general.js
@@ -136,16 +136,17 @@ user_pref("network.activity.blipInterval
 // cause other tests to fail. Tests that wish to test the notification functionality
 // should explicitly disable this pref.
 user_pref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
 
 // Point Firefox Health Report at a local server. We don't care if it actually
 // works. It just can't hit the default production endpoint.
 user_pref("datareporting.healthreport.documentServerURI", "http://%(server)s/healthreport/");
 user_pref("datareporting.healthreport.about.reportUrl", "http://%(server)s/abouthealthreport/");
+user_pref("datareporting.healthreport.about.reportUrlUnified", "http://%(server)s/abouthealthreport/v4/");
 
 // Make sure CSS error reporting is enabled for tests
 user_pref("layout.css.report_errors", true);
 
 // Enable CSS Grid for testing
 user_pref("layout.css.grid.enabled", true);
 
 // Enable CSS 'contain' for testing