summaryrefslogtreecommitdiffstats
path: root/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_feedback_commands.js
blob: b89788e1cfe16ff9411c1d4cf289751daff19639 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/* the buidHelpMenu() function comes from browser/base/content/utilityOverlay.js */

const NORMAL_PAGE = "http://example.com";
const PHISH_PAGE = "http://www.itisatrap.org/firefox/its-a-trap.html";

async function checkItemsAreDisabled(url) {
  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
      url,
      // The phishing page doesn't send a load notification
      waitForLoad: false,
      waitForStateStop: true,
    },
    async function checkItems() {
      buildHelpMenu();

      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"
      );
    }
  );
}

add_task(async function test_policy_feedback_commands() {
  await setupPolicyEngineWithJson({
    policies: {
      DisableFeedbackCommands: true,
    },
  });

  /* from browser/base/content/utilityOverlay.js */
  buildHelpMenu();

  let feedbackPageMenu = document.getElementById("feedbackPage");
  is(
    feedbackPageMenu.getAttribute("disabled"),
    "true",
    "The `Submit Feedback...` item should be disabled"
  );

  await checkItemsAreDisabled(NORMAL_PAGE);
  await checkItemsAreDisabled(PHISH_PAGE);
});