summaryrefslogtreecommitdiffstats
path: root/browser/extensions/report-site-issue/test/browser/browser_button_state.js
blob: 6111a26975cc5b5f16426ad993cc2878845cda76 (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
"use strict";

const REPORTABLE_PAGE = "http://example.com/";
const REPORTABLE_PAGE2 = "https://example.com/";
const NONREPORTABLE_PAGE = "about:mozilla";

/* Test that the Report Site Issue help menu item is enabled for http and https tabs,
   on page load, or TabSelect, and disabled for everything else. */
add_task(async function test_button_state_disabled() {
  await SpecialPowers.pushPrefEnv({ set: [[PREF_WC_REPORTER_ENABLED, true]] });

  let tab1 = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    REPORTABLE_PAGE
  );
  const menu = new HelpMenuHelper();
  await menu.open();
  is(
    menu.isItemEnabled(),
    true,
    "Check that panel item is enabled for reportable schemes on tab load"
  );
  await menu.close();

  let tab2 = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    NONREPORTABLE_PAGE
  );
  await menu.open();
  is(
    menu.isItemEnabled(),
    false,
    "Check that panel item is disabled for non-reportable schemes on tab load"
  );
  await menu.close();

  let tab3 = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    REPORTABLE_PAGE2
  );
  await menu.open();
  is(
    menu.isItemEnabled(),
    true,
    "Check that panel item is enabled for reportable schemes on tab load"
  );
  await menu.close();

  await BrowserTestUtils.removeTab(tab1);
  await BrowserTestUtils.removeTab(tab2);
  await BrowserTestUtils.removeTab(tab3);
});