Bug 1367076 - Set datareporting.policy.firstRunURL by default to replace data choices infobar with privacy policy in a background tab on first run. r?gfritzsche,gijs draft
authorDão Gottwald <dao@mozilla.com>
Wed, 31 May 2017 13:48:06 +0200
changeset 587032 e6fee14b209b0c2413df3f8325d2457ef6836a3b
parent 586973 7b8937970f9ca85db88cb2496f2112175fd847c8
child 631169 2ab33527aedef4c4d591bea24977ca21683b00a4
push id61598
push userdgottwald@mozilla.com
push dateWed, 31 May 2017 11:49:08 +0000
reviewersgfritzsche, gijs
bugs1367076
milestone55.0a1
Bug 1367076 - Set datareporting.policy.firstRunURL by default to replace data choices infobar with privacy policy in a background tab on first run. r?gfritzsche,gijs MozReview-Commit-ID: 9r5el0I2HrA
browser/components/migration/tests/marionette/test_refresh_firefox.py
layout/tools/reftest/reftest-preferences.js
testing/marionette/components/marionette.js
testing/mozbase/mozprofile/mozprofile/profile.py
toolkit/components/telemetry/TelemetryReportingPolicy.jsm
toolkit/components/telemetry/datareporting-prefs.js
--- a/browser/components/migration/tests/marionette/test_refresh_firefox.py
+++ b/browser/components/migration/tests/marionette/test_refresh_firefox.py
@@ -372,25 +372,23 @@ class TestFirefoxRefresh(MarionetteTestC
           // Ensure the current (temporary) profile is in profiles.ini:
           let profD = Services.dirsvc.get("ProfD", Ci.nsIFile);
           let profileName = arguments[1];
           let myProfile = global.profSvc.createProfile(profD, profileName);
           global.profSvc.flush()
 
           // Now add the reset parameters:
           let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
-          let allMarionettePrefs = Services.prefs.getChildList("marionette.");
+          let prefsToKeep = Array.from(Services.prefs.getChildList("marionette."));
+          prefsToKeep.push("datareporting.policy.dataSubmissionPolicyBypassNotification");
           let prefObj = {};
-          for (let pref of allMarionettePrefs) {
-            let prefSuffix = pref.substr("marionette.".length);
-            let prefVal = global.Preferences.get(pref);
-            prefObj[prefSuffix] = prefVal;
+          for (let pref of prefsToKeep) {
+            prefObj[pref] = global.Preferences.get(pref);
           }
-          let marionetteInfo = JSON.stringify(prefObj);
-          env.set("MOZ_MARIONETTE_PREF_STATE_ACROSS_RESTARTS", marionetteInfo);
+          env.set("MOZ_MARIONETTE_PREF_STATE_ACROSS_RESTARTS", JSON.stringify(prefObj));
           env.set("MOZ_RESET_PROFILE_RESTART", "1");
           env.set("XRE_PROFILE_PATH", arguments[0]);
           env.set("XRE_PROFILE_NAME", profileName);
         """, script_args=[self.marionette.instance.profile.profile, profileName])
 
         profileLeafName = os.path.basename(os.path.normpath(self.marionette.instance.profile.profile))
 
         # Now restart the browser to get it reset:
--- a/layout/tools/reftest/reftest-preferences.js
+++ b/layout/tools/reftest/reftest-preferences.js
@@ -71,16 +71,19 @@ user_pref("browser.startup.page", 0);
 
 // Allow XUL and XBL files to be opened from file:// URIs
 user_pref("dom.allow_XUL_XBL_for_file", true);
 
 // Allow view-source URIs to be opened from URIs that share
 // their protocol with the inner URI of the view-source URI
 user_pref("security.view-source.reachable-from-inner-protocol", true);
 
+// Skip data reporting policy notifications.
+user_pref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
+
 // Ensure that telemetry is disabled, so we don't connect to the telemetry
 // server in the middle of the tests.
 user_pref("toolkit.telemetry.enabled", false);
 user_pref("toolkit.telemetry.unified", false);
 // Likewise for safebrowsing.
 user_pref("browser.safebrowsing.phishing.enabled", false);
 user_pref("browser.safebrowsing.malware.enabled", false);
 user_pref("browser.safebrowsing.blockedURIs.enabled", false);
--- a/testing/marionette/components/marionette.js
+++ b/testing/marionette/components/marionette.js
@@ -103,17 +103,17 @@ const prefs = {
         Cu.reportError(
             "Invalid Marionette preferences in environment; " +
             "preferences will not have been applied");
         Cu.reportError(e);
       }
 
       if (prefs) {
         for (let prefName of Object.keys(prefs)) {
-          Preferences.set("marionette." + prefName, prefs[prefName]);
+          Preferences.set(prefName, prefs[prefName]);
         }
       }
     }
   },
 };
 
 function MarionetteComponent() {
   this.enabled = env.exists(ENV_ENABLED);
--- a/testing/mozbase/mozprofile/mozprofile/profile.py
+++ b/testing/mozbase/mozprofile/mozprofile/profile.py
@@ -348,16 +348,18 @@ class FirefoxProfile(Profile):
         # Don't check for the default web browser during startup
         'browser.shell.checkDefaultBrowser': False,
         # Don't warn on exit when multiple tabs are open
         'browser.tabs.warnOnClose': False,
         # Don't warn when exiting the browser
         'browser.warnOnQuit': False,
         # Don't send Firefox health reports to the production server
         'datareporting.healthreport.documentServerURI': 'http://%(server)s/healthreport/',
+        # Skip data reporting policy notifications
+        'datareporting.policy.dataSubmissionPolicyBypassNotification': True,
         # Only install add-ons from the profile and the application scope
         # Also ensure that those are not getting disabled.
         # see: https://developer.mozilla.org/en/Installing_extensions
         'extensions.enabledScopes': 5,
         'extensions.autoDisableScopes': 10,
         # Don't send the list of installed addons to AMO
         'extensions.getAddons.cache.enabled': False,
         # Don't install distribution add-ons from the app folder
--- a/toolkit/components/telemetry/TelemetryReportingPolicy.jsm
+++ b/toolkit/components/telemetry/TelemetryReportingPolicy.jsm
@@ -379,33 +379,43 @@ var TelemetryReportingPolicyImpl = {
   _migratePreferences() {
     // Current prefs are mostly the same than the old ones, except for some deprecated ones.
     for (let pref of DEPRECATED_FHR_PREFS) {
       Preferences.reset(pref);
     }
   },
 
   /**
-   * Show the data choices infobar if the user wasn't already notified and data submission
-   * is enabled.
+   * Determine whether the user should be notified.
    */
-  _showInfobar() {
+  _shouldNotify() {
     if (!this.dataSubmissionEnabled) {
-      this._log.trace("_showInfobar - Data submission disabled by the policy.");
-      return;
+      this._log.trace("_shouldNotify - Data submission disabled by the policy.");
+      return false;
     }
 
     const bypassNotification = Preferences.get(PREF_BYPASS_NOTIFICATION, false);
     if (this.isUserNotifiedOfCurrentPolicy || bypassNotification) {
-      this._log.trace("_showInfobar - User already notified or bypassing the policy.");
-      return;
+      this._log.trace("_shouldNotify - User already notified or bypassing the policy.");
+      return false;
     }
 
     if (this._notificationInProgress) {
-      this._log.trace("_showInfobar - User not notified, notification already in progress.");
+      this._log.trace("_shouldNotify - User not notified, notification already in progress.");
+      return false;
+    }
+
+    return true;
+  },
+
+  /**
+   * Show the data choices infobar if needed.
+   */
+  _showInfobar() {
+    if (!this._shouldNotify()) {
       return;
     }
 
     this._log.trace("_showInfobar - User not notified, notifying now.");
     this._notificationInProgress = true;
     let request = new NotifyPolicyRequest(this._log);
     Observers.notify("datareporting:notify-data-policy:request", request);
   },
@@ -430,16 +440,20 @@ var TelemetryReportingPolicyImpl = {
     // is no longer in progress.
     this._notificationInProgress = false;
   },
 
   /**
    * Try to open the privacy policy in a background tab instead of showing the infobar.
    */
   _openFirstRunPage() {
+    if (!this._shouldNotify()) {
+      return false;
+    }
+
     let firstRunPolicyURL = Preferences.get(PREF_FIRST_RUN_URL, "");
     if (!firstRunPolicyURL) {
       return false;
     }
     firstRunPolicyURL = Services.urlFormatter.formatURL(firstRunPolicyURL);
 
     let win;
     try {
--- a/toolkit/components/telemetry/datareporting-prefs.js
+++ b/toolkit/components/telemetry/datareporting-prefs.js
@@ -6,9 +6,9 @@
 
 pref("datareporting.policy.dataSubmissionEnabled", true);
 pref("datareporting.policy.dataSubmissionPolicyNotifiedTime", "0");
 pref("datareporting.policy.dataSubmissionPolicyAcceptedVersion", 0);
 pref("datareporting.policy.dataSubmissionPolicyBypassNotification", false);
 pref("datareporting.policy.currentPolicyVersion", 2);
 pref("datareporting.policy.minimumPolicyVersion", 1);
 pref("datareporting.policy.minimumPolicyVersion.channel-beta", 2);
-pref("datareporting.policy.firstRunURL", "");
+pref("datareporting.policy.firstRunURL", "https://www.mozilla.org/privacy/firefox/");