Bug 1548626 - Delay showing the Privacy-UI onboarding by 30 min for new users. r=johannh a=pascalc
authorErica Wright <ewright@mozilla.com>
Mon, 06 May 2019 00:37:05 +0000
changeset 526501 0deba92b39fd52160009e0296dd096c18f33830f
parent 526500 6083df09e9dbefa10a96efbc2fc0b6dc529ad58c
child 526502 70403bae88b8486cd20c74c693ad85f79a030a00
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh, pascalc
bugs1548626
milestone67.0
Bug 1548626 - Delay showing the Privacy-UI onboarding by 30 min for new users. r=johannh a=pascalc Wait 30 min after a new profile is created before showing the onbording. Differential Revision: https://phabricator.services.mozilla.com/D29762
browser/app/profile/firefox.js
browser/base/content/browser-contentblocking.js
browser/components/uitour/test/browser_contentBlocking.js
browser/components/uitour/test/browser_trackingProtection.js
browser/components/uitour/test/browser_trackingProtection_tour.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1588,16 +1588,19 @@ pref("browser.contentblocking.reportBrea
 pref("browser.contentblocking.rejecttrackers.reportBreakage.enabled", true);
 
 pref("browser.contentblocking.reportBreakage.url", "https://tracking-protection-issues.herokuapp.com/new");
 
 pref("browser.contentblocking.introCount", 0);
 
 pref("privacy.trackingprotection.introURL", "https://www.mozilla.org/%LOCALE%/firefox/%VERSION%/content-blocking/start/");
 
+// 1800 = 30 min in seconds
+pref("browser.contentblocking.introDelaySeconds", 1800);
+
 // Workaround for Google Recaptcha
 pref("urlclassifier.trackingAnnotationSkipURLs", "google.com/recaptcha/,*.google.com/recaptcha/");
 
 // Always enable newtab segregation using containers
 pref("privacy.usercontext.about_newtab_segregation.enabled", true);
 // Enable Contextual Identity Containers
 #ifdef NIGHTLY_BUILD
 pref("privacy.userContext.enabled", true);
--- a/browser/base/content/browser-contentblocking.js
+++ b/browser/base/content/browser-contentblocking.js
@@ -1088,17 +1088,21 @@ var ContentBlocking = {
       this.iconBox.removeAttribute("animate");
     // Only play the animation when the shield is not already shown on the page (the visibility
     // of the shield based on this onSecurityChange be determined afterwards).
     } else if (anyBlocking && !this.iconBox.hasAttribute("active")) {
       this.iconBox.setAttribute("animate", "true");
 
       if (!isBrowserPrivate) {
         let introCount = Services.prefs.getIntPref(this.prefIntroCount);
-        if (introCount < this.MAX_INTROS) {
+        let installStamp = Services.prefs.getIntPref(
+          "browser.laterrun.bookkeeping.profileCreationTime", Date.now() / 1000);
+        let delayLength = Services.prefs.getIntPref("browser.contentblocking.introDelaySeconds");
+        let delayFulfilled = delayLength < (Date.now() / 1000 - installStamp);
+        if (introCount < this.MAX_INTROS && delayFulfilled) {
           Services.prefs.setIntPref(this.prefIntroCount, ++introCount);
           Services.prefs.savePrefFile(null);
           this.showIntroPanel();
         }
       }
     }
 
     // We consider the shield state "active" when some kind of blocking activity
--- a/browser/components/uitour/test/browser_contentBlocking.js
+++ b/browser/components/uitour/test/browser_contentBlocking.js
@@ -1,31 +1,34 @@
 "use strict";
 
+const PREF_INTRO_DELAY = "browser.contentblocking.introDelaySeconds";
 const PREF_INTRO_COUNT = "browser.contentblocking.introCount";
 const PREF_TP_ENABLED = "privacy.trackingprotection.enabled";
 const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/benignPage.html";
 const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
 const TOOLTIP_PANEL = document.getElementById("UITourTooltip");
 const TOOLTIP_ANCHOR = document.getElementById("tracking-protection-icon-animatable-box");
 
 var {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm");
 
 registerCleanupFunction(function() {
   UrlClassifierTestUtils.cleanupTestTrackers();
   Services.prefs.clearUserPref(PREF_TP_ENABLED);
   Services.prefs.clearUserPref(PREF_INTRO_COUNT);
+  Services.prefs.clearUserPref(PREF_INTRO_DELAY);
 });
 
 function allowOneIntro() {
   Services.prefs.setIntPref(PREF_INTRO_COUNT, window.ContentBlocking.MAX_INTROS - 1);
 }
 
 add_task(async function setup_test() {
   Services.prefs.setBoolPref(PREF_TP_ENABLED, true);
+  Services.prefs.setIntPref(PREF_INTRO_DELAY, 0);
   await UrlClassifierTestUtils.addTestTrackers();
 });
 
 add_task(async function test_benignPage() {
   info("Load a test page not containing tracking elements");
   allowOneIntro();
   await BrowserTestUtils.withNewTab(BENIGN_PAGE, async function() {
     await Assert.rejects(waitForConditionPromise(() => {
--- a/browser/components/uitour/test/browser_trackingProtection.js
+++ b/browser/components/uitour/test/browser_trackingProtection.js
@@ -1,30 +1,33 @@
 "use strict";
 
+const PREF_INTRO_DELAY = "browser.contentblocking.introDelaySeconds";
 const PREF_INTRO_COUNT = "browser.contentblocking.introCount";
 const PREF_TP_ENABLED = "privacy.trackingprotection.enabled";
 const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/benignPage.html";
 const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
 const TOOLTIP_PANEL = document.getElementById("UITourTooltip");
 const TOOLTIP_ANCHOR = document.getElementById("tracking-protection-icon-animatable-box");
 
 var {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm");
 
 registerCleanupFunction(function() {
   UrlClassifierTestUtils.cleanupTestTrackers();
   Services.prefs.clearUserPref(PREF_TP_ENABLED);
+  Services.prefs.clearUserPref(PREF_INTRO_DELAY);
 });
 
 function allowOneIntro() {
   Services.prefs.setIntPref(PREF_INTRO_COUNT, window.ContentBlocking.MAX_INTROS - 1);
 }
 
 add_task(async function setup_test() {
   Services.prefs.setBoolPref(PREF_TP_ENABLED, true);
+  Services.prefs.setIntPref(PREF_INTRO_DELAY, 0);
   await UrlClassifierTestUtils.addTestTrackers();
 });
 
 add_task(async function test_benignPage() {
   info("Load a test page not containing tracking elements");
   allowOneIntro();
   await BrowserTestUtils.withNewTab({gBrowser, url: BENIGN_PAGE}, async function() {
     await waitForConditionPromise(() => {
--- a/browser/components/uitour/test/browser_trackingProtection_tour.js
+++ b/browser/components/uitour/test/browser_trackingProtection_tour.js
@@ -1,27 +1,30 @@
 "use strict";
 
 var gTestTab;
 var gContentAPI;
 var gContentWindow;
 
 const { UrlClassifierTestUtils } = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm");
 
+const PREF_INTRO_DELAY = "browser.contentblocking.introDelaySeconds";
 const TP_ENABLED_PREF = "privacy.trackingprotection.enabled";
 
 add_task(setup_UITourTest);
 
 add_task(async function test_setup() {
   Services.prefs.setBoolPref("privacy.trackingprotection.enabled", true);
+  Services.prefs.setIntPref(PREF_INTRO_DELAY, 0);
   await UrlClassifierTestUtils.addTestTrackers();
 
   registerCleanupFunction(function() {
     UrlClassifierTestUtils.cleanupTestTrackers();
     Services.prefs.clearUserPref("privacy.trackingprotection.enabled");
+    Services.prefs.clearUserPref(PREF_INTRO_DELAY);
   });
 });
 
 add_UITour_task(async function test_unblock_target() {
   await checkToggleTarget("controlCenter-trackingUnblock");
 });
 
 add_UITour_task(function setup_block_target() {