Bug 1604563 - Rename trackingProtection trigger event to contentBlocking r=k88hudson
authorAndrei Oprea <andrei.br92@gmail.com>
Fri, 20 Dec 2019 16:25:51 +0000
changeset 508030 b656c8a33a948250362c32678582d902e421ddee
parent 508029 46209bb628feca4953927315f6b4c1cd54ba23fd
child 508031 54a84425dcf0fb18b1908aabfa51a7ccbb020c8c
push id36936
push usercbrindusan@mozilla.com
push dateFri, 20 Dec 2019 21:54:48 +0000
treeherdermozilla-central@e94a014eb27e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersk88hudson
bugs1604563
milestone73.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 1604563 - Rename trackingProtection trigger event to contentBlocking r=k88hudson Differential Revision: https://phabricator.services.mozilla.com/D57628
browser/components/newtab/lib/ASRouterTriggerListeners.jsm
browser/components/newtab/lib/CFRMessageProvider.jsm
browser/components/newtab/test/browser/browser_asrouter_trigger_listeners.js
--- a/browser/components/newtab/lib/ASRouterTriggerListeners.jsm
+++ b/browser/components/newtab/lib/ASRouterTriggerListeners.jsm
@@ -437,17 +437,17 @@ this.ASRouterTriggerListeners = new Map(
     },
   ],
 
   /**
    * Attach listener to count location changes and notify the trigger handler
    * on content blocked event
    */
   [
-    "trackingProtection",
+    "contentBlocking",
     {
       _initialized: false,
       _triggerHandler: null,
       _events: [],
       _sessionPageLoad: 0,
       onLocationChange: null,
 
       init(triggerHandler, params, patterns) {
@@ -499,34 +499,34 @@ this.ASRouterTriggerListeners = new Map(
       },
 
       observe(aSubject, aTopic, aData) {
         switch (aTopic) {
           case "SiteProtection:ContentBlockingEvent":
             const { browser, host, event } = aSubject.wrappedJSObject;
             if (this._events.filter(e => (e & event) === e).length) {
               this._triggerHandler(browser, {
-                id: "trackingProtection",
+                id: "contentBlocking",
                 param: {
                   host,
                   type: event,
                 },
                 context: {
                   pageLoad: this._sessionPageLoad,
                 },
               });
             }
             break;
           case "SiteProtection:ContentBlockingMilestone":
             if (this._events.includes(aSubject.wrappedJSObject.event)) {
               this._triggerHandler(
                 Services.wm.getMostRecentBrowserWindow().gBrowser
                   .selectedBrowser,
                 {
-                  id: "trackingProtection",
+                  id: "contentBlocking",
                   context: {
                     pageLoad: this._sessionPageLoad,
                   },
                   param: {
                     host: aSubject.wrappedJSObject.event,
                   },
                 }
               );
--- a/browser/components/newtab/lib/CFRMessageProvider.jsm
+++ b/browser/components/newtab/lib/CFRMessageProvider.jsm
@@ -660,17 +660,17 @@ const CFR_MESSAGES = [
       },
     },
     targeting: "pageLoad >= 4 && firefoxVersion >= 71",
     frequency: {
       lifetime: 2,
       custom: [{ period: 2 * 86400 * 1000, cap: 1 }],
     },
     trigger: {
-      id: "trackingProtection",
+      id: "contentBlocking",
       params: [
         Ci.nsIWebProgressListener.STATE_BLOCKED_SOCIALTRACKING_CONTENT,
         Ci.nsIWebProgressListener.STATE_LOADED_SOCIALTRACKING_CONTENT |
           Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER,
       ],
     },
   },
   {
@@ -718,17 +718,17 @@ const CFR_MESSAGES = [
       },
     },
     targeting: "pageLoad >= 4 && firefoxVersion >= 71",
     frequency: {
       lifetime: 2,
       custom: [{ period: 2 * 86400 * 1000, cap: 1 }],
     },
     trigger: {
-      id: "trackingProtection",
+      id: "contentBlocking",
       params: [Ci.nsIWebProgressListener.STATE_BLOCKED_FINGERPRINTING_CONTENT],
     },
   },
   {
     id: "CRYPTOMINERS_PROTECTION",
     template: "cfr_doorhanger",
     priority: 3,
     content: {
@@ -772,17 +772,17 @@ const CFR_MESSAGES = [
       },
     },
     targeting: "pageLoad >= 4 && firefoxVersion >= 71",
     frequency: {
       lifetime: 2,
       custom: [{ period: 2 * 86400 * 1000, cap: 1 }],
     },
     trigger: {
-      id: "trackingProtection",
+      id: "contentBlocking",
       params: [Ci.nsIWebProgressListener.STATE_BLOCKED_CRYPTOMINING_CONTENT],
     },
   },
   {
     id: "MILESTONE_MESSAGE",
     template: "milestone_message",
     content: {
       layout: "short_message",
@@ -798,20 +798,20 @@ const CFR_MESSAGES = [
           label: { string_id: "cfr-doorhanger-milestone-ok-button" },
           action: { type: "OPEN_PROTECTION_REPORT" },
           event: "PROTECTION",
         },
       },
     },
     targeting: "pageLoad >= 4",
     frequency: {
-      lifetime: 7, // Length of privacy.trackingprotection.cfr-milestone.milestones pref
+      lifetime: 7, // Length of privacy.contentBlocking.cfr-milestone.milestones pref
     },
     trigger: {
-      id: "trackingProtection",
+      id: "contentBlocking",
       params: ["ContentBlockingMilestone"],
     },
   },
 ];
 
 const CFRMessageProvider = {
   getMessages() {
     return CFR_MESSAGES.filter(msg => !msg.exclude);
--- a/browser/components/newtab/test/browser/browser_asrouter_trigger_listeners.js
+++ b/browser/components/newtab/test/browser/browser_asrouter_trigger_listeners.js
@@ -196,17 +196,17 @@ add_task(async function check_newSavedLo
     async function triggerNewSavedPasswordAfterUninit(browser) {
       Services.obs.notifyObservers(browser, "LoginStats:NewSavedPassword");
       await new Promise(resolve => executeSoon(resolve));
       is(loginsSaved, 1, "shouldn't receive obs. notification after uninit");
     }
   );
 });
 
-add_task(async function check_trackingProtection_listener() {
+add_task(async function check_contentBlocking_listener() {
   const TEST_URL =
     "https://example.com/browser/browser/components/newtab/test/browser/red_page.html";
 
   const event1 = 0x0001;
   const event2 = 0x0010;
   const event3 = 0x0100;
   const event4 = 0x1000;
 
@@ -219,40 +219,40 @@ add_task(async function check_trackingPr
   let observerEvent = 0;
   let pageLoadSum = 0;
   const triggerHandler = (target, trigger) => {
     const {
       id,
       param: { host, type },
       context: { pageLoad },
     } = trigger;
-    is(id, "trackingProtection", "should match event name");
+    is(id, "contentBlocking", "should match event name");
     is(host, TEST_URL, "should match test URL");
     is(
       bindEvents.filter(e => (type & e) === e).length,
       1,
       `event ${type} is valid`
     );
     ok(pageLoadSum <= pageLoad, "pageLoad is non-decreasing");
 
     observerEvent += 1;
     pageLoadSum = pageLoad;
   };
-  const trackingProtectionListener = ASRouterTriggerListeners.get(
-    "trackingProtection"
+  const contentBlockingListener = ASRouterTriggerListeners.get(
+    "contentBlocking"
   );
 
   // Previously initialized by the Router
-  trackingProtectionListener.uninit();
+  contentBlockingListener.uninit();
 
-  await trackingProtectionListener.init(triggerHandler, bindEvents);
+  await contentBlockingListener.init(triggerHandler, bindEvents);
 
   await BrowserTestUtils.withNewTab(
     TEST_URL,
-    async function triggerTrackingProtection(browser) {
+    async function triggercontentBlocking(browser) {
       Services.obs.notifyObservers(
         {
           wrappedJSObject: {
             browser,
             host: TEST_URL,
             event: event1, // won't trigger
           },
         },
@@ -261,17 +261,17 @@ add_task(async function check_trackingPr
     }
   );
 
   is(observerEvent, 0, "shouldn't receive unrelated observer notification");
   is(pageLoadSum, 0, "shouldn't receive unrelated observer notification");
 
   await BrowserTestUtils.withNewTab(
     TEST_URL,
-    async function triggerTrackingProtection(browser) {
+    async function triggercontentBlocking(browser) {
       Services.obs.notifyObservers(
         {
           wrappedJSObject: {
             browser,
             host: TEST_URL,
             event: event3, // will trigger
           },
         },
@@ -316,21 +316,21 @@ add_task(async function check_trackingPr
 
       await new Promise(resolve => executeSoon(resolve));
       is(observerEvent, 2, "shouldn't receive unrelated notification");
       is(pageLoadSum, 2, "shouldn't receive unrelated notification");
     }
   );
 
   // Uninitialise listener
-  trackingProtectionListener.uninit();
+  contentBlockingListener.uninit();
 
   await BrowserTestUtils.withNewTab(
     TEST_URL,
-    async function triggerTrackingProtectionAfterUninit(browser) {
+    async function triggercontentBlockingAfterUninit(browser) {
       Services.obs.notifyObservers(
         {
           wrappedJSObject: {
             browser,
             host: TEST_URL,
             event: event3, // wont trigger after uninit
           },
         },
@@ -338,60 +338,60 @@ add_task(async function check_trackingPr
       );
       await new Promise(resolve => executeSoon(resolve));
       is(observerEvent, 2, "shouldn't receive obs. notification after uninit");
       is(pageLoadSum, 2, "shouldn't receive obs. notification after uninit");
     }
   );
 });
 
-add_task(async function check_trackingProtectionMilestone_listener() {
+add_task(async function check_contentBlockingMilestone_listener() {
   const TEST_URL =
     "https://example.com/browser/browser/components/newtab/test/browser/red_page.html";
 
   let observerEvent = 0;
   const triggerHandler = (target, trigger) => {
     const {
       id,
       param: { host },
     } = trigger;
-    is(id, "trackingProtection", "should match event name");
+    is(id, "contentBlocking", "should match event name");
     is(host, "ContentBlockingMilestone", "Should be the correct event type");
     observerEvent += 1;
   };
-  const trackingProtectionListener = ASRouterTriggerListeners.get(
-    "trackingProtection"
+  const contentBlockingListener = ASRouterTriggerListeners.get(
+    "contentBlocking"
   );
 
   // Previously initialized by the Router
-  trackingProtectionListener.uninit();
+  contentBlockingListener.uninit();
 
   // Initialise listener
-  trackingProtectionListener.init(triggerHandler, ["ContentBlockingMilestone"]);
+  contentBlockingListener.init(triggerHandler, ["ContentBlockingMilestone"]);
 
   await BrowserTestUtils.withNewTab(
     TEST_URL,
-    async function triggerTrackingProtection(browser) {
+    async function triggercontentBlocking(browser) {
       Services.obs.notifyObservers(
         {
           wrappedJSObject: {
             browser,
             event: "Other Event",
           },
         },
         "SiteProtection:ContentBlockingMilestone"
       );
     }
   );
 
   is(observerEvent, 0, "shouldn't receive unrelated observer notification");
 
   await BrowserTestUtils.withNewTab(
     TEST_URL,
-    async function triggerTrackingProtection(browser) {
+    async function triggercontentBlocking(browser) {
       Services.obs.notifyObservers(
         {
           wrappedJSObject: {
             browser,
             event: "ContentBlockingMilestone",
           },
         },
         "SiteProtection:ContentBlockingMilestone"
@@ -401,21 +401,21 @@ add_task(async function check_trackingPr
         () => observerEvent !== 0,
         "Wait for the observer notification to run"
       );
       is(observerEvent, 1, "should receive observer notification");
     }
   );
 
   // Uninitialise listener
-  trackingProtectionListener.uninit();
+  contentBlockingListener.uninit();
 
   await BrowserTestUtils.withNewTab(
     TEST_URL,
-    async function triggerTrackingProtectionAfterUninit(browser) {
+    async function triggercontentBlockingAfterUninit(browser) {
       Services.obs.notifyObservers(
         {
           wrappedJSObject: {
             browser,
             event: "ContentBlockingMilestone",
           },
         },
         "SiteProtection:ContentBlockingMilestone"