Bug 1577031 - make Protection Report page sharable via UITour. r=johannh a=lizzard
authorErica Wright <ewright@mozilla.com>
Fri, 06 Sep 2019 15:45:28 +0000
changeset 554975 4ab713decd5adeb2c6da46fa67e3f19b92169dc6
parent 554974 6fb937a562b9d5852f88e9ce02f6c9511b2f6874
child 554976 dff98f24b46ba24955d8f3ec9fbc3e21a21189ac
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh, lizzard
bugs1577031
milestone70.0
Bug 1577031 - make Protection Report page sharable via UITour. r=johannh a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D44249
browser/components/uitour/UITour-lib.js
browser/components/uitour/UITour.jsm
browser/components/uitour/test/browser.ini
browser/components/uitour/test/browser_UITour_showProtectionReport.js
--- a/browser/components/uitour/UITour-lib.js
+++ b/browser/components/uitour/UITour-lib.js
@@ -367,16 +367,24 @@ if (typeof Mozilla == "undefined") {
    * Loads about:newtab in the tour tab.
    * @since 51
    */
   Mozilla.UITour.showNewTab = function() {
     _sendEvent("showNewTab");
   };
 
   /**
+   * Loads about:protections in the tour tab.
+   * @since 70
+   */
+  Mozilla.UITour.showProtectionReport = function() {
+    _sendEvent("showProtectionReport");
+  };
+
+  /**
    * @typedef Mozilla.UITour.ConfigurationName
    * @description Valid values:<ul>
    * <li>{@link Mozilla.UITour.Configuration.AppInfo|appinfo}</li>
    * <li>{@link Mozilla.UITour.Configuration.CanReset|canReset}</li>
    * <li>{@link Mozilla.UITour.Configuration.AvailableTargets|availableTargets}</li>
    * <li>{@link Mozilla.UITour.Configuration.Search|search}</li>
    * <li>{@link Mozilla.UITour.Configuration.Search|selectedSearchEngine}
    * - DEPRECATED, use 'search'</li>
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -704,16 +704,21 @@ var UITour = {
         // is windowless, just ignore the request to close the tab. The request
         // is also ignored if this is the only tab in the window.
         let tabBrowser = browser.ownerGlobal.gBrowser;
         if (tabBrowser && tabBrowser.browsers.length > 1) {
           tabBrowser.removeTab(tabBrowser.getTabForBrowser(browser));
         }
         break;
       }
+
+      case "showProtectionReport": {
+        this.showProtectionReport(window, browser);
+        break;
+      }
     }
 
     // For performance reasons, only call initForBrowser if we did something
     // that will require a teardownTourForBrowser call later.
     // getConfiguration (called from about:home) doesn't require any future
     // uninitialization.
     if (action != "getConfiguration") {
       this.initForBrowser(browser, window);
@@ -1549,16 +1554,27 @@ var UITour = {
       targetBrowser: aBrowser,
       triggeringPrincipal: Services.scriptSecurityManager.createContentPrincipal(
         Services.io.newURI(url),
         {}
       ),
     });
   },
 
+  showProtectionReport(aWindow, aBrowser) {
+    let url = "about:protections";
+    aWindow.openLinkIn(url, "current", {
+      targetBrowser: aBrowser,
+      triggeringPrincipal: Services.scriptSecurityManager.createContentPrincipal(
+        Services.io.newURI(url),
+        {}
+      ),
+    });
+  },
+
   _hideAnnotationsForPanel(aEvent, aShouldClosePanel, aTargetPositionCallback) {
     let win = aEvent.target.ownerGlobal;
     let hideHighlightMethod = null;
     let hideInfoMethod = null;
     if (aShouldClosePanel) {
       hideHighlightMethod = aWin => this.hideHighlight(aWin);
       hideInfoMethod = aWin => this.hideInfo(aWin);
     } else {
--- a/browser/components/uitour/test/browser.ini
+++ b/browser/components/uitour/test/browser.ini
@@ -33,11 +33,13 @@ skip-if = os != "mac" # modal dialog dis
 [browser_UITour_panel_close_annotation.js]
 skip-if = true # Disabled due to frequent failures, bugs 1026310 and 1032137
 [browser_UITour_pocket.js]
 skip-if = true # Disabled pending removal of pocket UI Tour
 [browser_UITour_resetProfile.js]
 skip-if = (verify && !debug && (os == 'linux'))
 [browser_UITour_showNewTab.js]
 skip-if = (verify && !debug && (os == 'linux'))
+[browser_UITour_showProtectionReport.js]
+skip-if = (verify && !debug && (os == 'linux'))
 [browser_UITour_sync.js]
 [browser_UITour_toggleReaderMode.js]
 skip-if = (verify && !debug && (os == 'linux'))
new file mode 100644
--- /dev/null
+++ b/browser/components/uitour/test/browser_UITour_showProtectionReport.js
@@ -0,0 +1,48 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+var gTestTab;
+var gContentAPI;
+var gContentWindow;
+
+add_task(setup_UITourTest);
+
+add_task(async function setup() {
+  await SpecialPowers.pushPrefEnv({
+    set: [
+      ["browser.contentblocking.database.enabled", false],
+      ["browser.contentblocking.report.monitor.enabled", false],
+      ["browser.contentblocking.report.lockwise.enabled", false],
+      ["browser.contentblocking.report.proxy.enabled", false],
+    ],
+  });
+});
+
+// Test that we can switch to about:protections
+add_UITour_task(async function test_openProtectionReport() {
+  let aboutProtectionsLoaded = BrowserTestUtils.browserLoaded(
+    gBrowser.selectedBrowser,
+    false,
+    "about:protections"
+  );
+  info("Showing about:protections");
+  await gContentAPI.showProtectionReport();
+  info("Waiting for about:protections to load");
+  await aboutProtectionsLoaded;
+  // When the graph is built it means the messaging has finished,
+  // we can close the tab.
+  await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
+    await ContentTaskUtils.waitForCondition(() => {
+      let bars = content.document.querySelectorAll(".graph-bar");
+      return bars.length;
+    }, "The graph has been built");
+  });
+
+  is(
+    gBrowser.selectedBrowser.currentURI.spec,
+    "about:protections",
+    "Loaded about:protections"
+  );
+});