Bug 1440574 - Policy: Disable commands to send feedback. r=felipc
☠☠ backed out by e2e7c0ffb21c ☠ ☠
authorYUKI Piro Hiroshi <yuki@clear-code.com>
Mon, 05 Mar 2018 19:13:00 -0500
changeset 406981 7afca6992b724c6bd29b6021cf7f54b56b36b028
parent 406980 6d0dcc642e1a110400c2ad05746c0b2a398a4af5
child 406982 9e97b14fe91fc7aaa74f668dbb5289dddd8a115b
push id33587
push usershindli@mozilla.com
push dateThu, 08 Mar 2018 00:20:14 +0000
treeherdermozilla-central@8a7d069e9b70 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipc
bugs1440574
milestone60.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 1440574 - Policy: Disable commands to send feedback. r=felipc
browser/base/content/browser-safebrowsing.js
browser/base/content/utilityOverlay.js
browser/components/enterprisepolicies/Policies.jsm
browser/components/enterprisepolicies/schemas/policies-schema.json
browser/components/enterprisepolicies/tests/browser/browser.ini
browser/components/enterprisepolicies/tests/browser/browser_policy_disable_feedback_commands.js
--- a/browser/base/content/browser-safebrowsing.js
+++ b/browser/base/content/browser-safebrowsing.js
@@ -18,31 +18,26 @@ var gSafeBrowsing = {
       docURI && docURI.spec.startsWith("about:blocked?e=deceptiveBlocked");
 
     // Show/hide the appropriate menu item.
     document.getElementById("menu_HelpPopup_reportPhishingtoolmenu")
             .hidden = isPhishingPage;
     document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu")
             .hidden = !isPhishingPage;
 
-    var broadcasterId = isPhishingPage
-                        ? "reportPhishingErrorBroadcaster"
-                        : "reportPhishingBroadcaster";
-
-    var broadcaster = document.getElementById(broadcasterId);
-    if (!broadcaster)
-      return;
-
     // Now look at the currentURI to learn which page we were trying
     // to browse to.
-    let uri = gBrowser.currentURI;
-    if (uri && (uri.schemeIs("http") || uri.schemeIs("https")))
-      broadcaster.removeAttribute("disabled");
-    else
-      broadcaster.setAttribute("disabled", true);
+    const uri = gBrowser.currentURI;
+    const isReportablePage = uri && (uri.schemeIs("http") || uri.schemeIs("https"));
+
+    const disabledByPolicy = !Services.policies.isAllowed("feedbackCommands");
+    document.getElementById("reportPhishingBroadcaster")
+            .disabled = disabledByPolicy || isPhishingPage || !isReportablePage;
+    document.getElementById("reportPhishingErrorBroadcaster")
+            .disabled = disabledByPolicy || !isPhishingPage || !isReportablePage;
   },
 
   /**
    * Used to report a phishing page or a false positive
    *
    * @param name
    *        String One of "PhishMistake", "MalwareMistake", or "Phish"
    * @param info
--- a/browser/base/content/utilityOverlay.js
+++ b/browser/base/content/utilityOverlay.js
@@ -824,16 +824,19 @@ function openFeedbackPage() {
 
 function openTourPage() {
   let scope = {};
   ChromeUtils.import("resource:///modules/UITour.jsm", scope);
   openUILinkIn(scope.UITour.url, "tab");
 }
 
 function buildHelpMenu() {
+  document.getElementById("feedbackPage")
+          .disabled = !Services.policies.isAllowed("feedbackCommands");
+
   // Enable/disable the "Report Web Forgery" menu item.
   if (typeof gSafeBrowsing != "undefined") {
     gSafeBrowsing.setReportPhishingMenu();
   }
 }
 
 function isElementVisible(aElement) {
   if (!aElement)
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -135,16 +135,24 @@ var Policies = {
         manager.disallowFeature("devtools");
         manager.disallowFeature("about:devtools");
         manager.disallowFeature("about:debugging");
         manager.disallowFeature("about:devtools-toolbox");
       }
     }
   },
 
+  "DisableFeedbackCommands": {
+    onBeforeUIStartup(manager, param) {
+      if (param) {
+        manager.disallowFeature("feedbackCommands");
+      }
+    }
+  },
+
   "DisableFirefoxAccounts": {
     onBeforeAddons(manager, param) {
       if (param) {
         setAndLockPref("identity.fxaccounts.enabled", false);
       }
     }
   },
 
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -110,16 +110,23 @@
 
     "DisableDeveloperTools": {
       "description": "Prevents access to developer tools.",
       "first_available": "60.0",
 
       "type": "boolean"
     },
 
+    "DisableFeedbackCommands": {
+      "description": "Prevents ability to send feedback for phishing detection and others.",
+      "first_available": "60.0",
+
+      "type": "boolean"
+    },
+
     "DisableFirefoxAccounts": {
       "description": "Disables Firefox Account based services, including Sync.",
       "first_available": "60.0",
 
       "type": "boolean"
     },
 
     "DisableFirefoxScreenshots": {
--- a/browser/components/enterprisepolicies/tests/browser/browser.ini
+++ b/browser/components/enterprisepolicies/tests/browser/browser.ini
@@ -18,16 +18,17 @@ support-files =
 [browser_policy_app_update.js]
 [browser_policy_block_about_addons.js]
 [browser_policy_block_about_config.js]
 [browser_policy_block_about_profiles.js]
 [browser_policy_block_about_support.js]
 [browser_policy_block_set_desktop_background.js]
 [browser_policy_bookmarks.js]
 [browser_policy_default_browser_check.js]
+[browser_policy_disable_feedback_commands.js]
 [browser_policy_disable_formhistory.js]
 [browser_policy_disable_fxaccounts.js]
 [browser_policy_disable_fxscreenshots.js]
 [browser_policy_disable_masterpassword.js]
 [browser_policy_disable_pocket.js]
 [browser_policy_disable_privatebrowsing.js]
 [browser_policy_disable_shield.js]
 [browser_policy_display_bookmarks.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_feedback_commands.js
@@ -0,0 +1,61 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function setup() {
+  await setupPolicyEngineWithJson({
+    "policies": {
+      "DisableFeedbackCommands": true
+    }
+  });
+});
+
+const NORMAL_PAGE = "http://example.com";
+const PHISH_PAGE = "http://www.itisatrap.org/firefox/its-a-trap.html";
+
+function check_all_feedback_commands_hidden(url) {
+  return BrowserTestUtils.withNewTab({
+    gBrowser,
+    url: "about:blank",
+  }, async function(browser) {
+    // We don't get load events when the DocShell redirects to error
+    // pages, but we do get DOMContentLoaded, so we'll wait for that.
+    let dclPromise = ContentTask.spawn(browser, null, async function() {
+      await ContentTaskUtils.waitForEvent(this, "DOMContentLoaded", false);
+    });
+    browser.loadURI(url);
+    await dclPromise;
+
+    let menu = document.getElementById("menu_HelpPopup");
+    let menuOpen = BrowserTestUtils.waitForEvent(menu, "popupshown");
+    menu.openPopup(null, "", 0, 0, false, null);
+    await menuOpen;
+
+    let feedbackPageMenu = document.getElementById("feedbackPage");
+    is(feedbackPageMenu.getAttribute("disabled"), "true",
+       "The `Submit Feedback...` item should be disabled");
+
+    let reportMenu =
+      document.getElementById("menu_HelpPopup_reportPhishingtoolmenu");
+    is(reportMenu.getAttribute("disabled"), "true",
+       "The `Report Deceptive Site` item should be disabled");
+
+    let errorMenu =
+      document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu");
+    is(errorMenu.getAttribute("disabled"), "true",
+       "The `This isn’t a deceptive site` item should be disabled");
+
+    let menuClose = BrowserTestUtils.waitForEvent(menu, "popuphidden");
+    menu.hidePopup();
+    await menuClose;
+  });
+}
+
+add_task(async function test_normal_page() {
+  return check_all_feedback_commands_hidden(NORMAL_PAGE)
+});
+
+add_task(async function test_phishing_page() {
+  return check_all_feedback_commands_hidden(PHISH_PAGE)
+});