summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_hidden_addons.js
blob: 5d28752c9325aa133797e995225d5983f82cfc32 (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
64
65
66
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Test that system and hidden addons are only displayed when the showSystemAddons
// preferences is true.

const SYSTEM_ADDON = createAddonData({
  id: "system",
  name: "System Addon",
  isSystem: true,
  hidden: true,
});
const HIDDEN_ADDON = createAddonData({
  id: "hidden",
  name: "Hidden Addon",
  isSystem: false,
  hidden: true,
});
const NORMAL_ADDON = createAddonData({
  id: "normal",
  name: "Normal Addon",
  isSystem: false,
  hidden: false,
});

add_task(async function testShowSystemAddonsTrue() {
  info("Test with showHiddenAddons set to true");
  await testAddonsDisplay(true);

  info("Test with showHiddenAddons set to false");
  await testAddonsDisplay(false);
});

async function testAddonsDisplay(showHidden) {
  const thisFirefoxClient = setupThisFirefoxMock();
  thisFirefoxClient.listAddons = () => [
    SYSTEM_ADDON,
    HIDDEN_ADDON,
    NORMAL_ADDON,
  ];

  info("Set showHiddenAddons to " + showHidden);
  await pushPref("devtools.aboutdebugging.showHiddenAddons", showHidden);

  const { document, tab, window } = await openAboutDebugging();
  await selectThisFirefoxPage(document, window.AboutDebugging.store);

  const hasSystemAddon = !!findDebugTargetByText("System Addon", document);
  const hasHiddenAddon = !!findDebugTargetByText("Hidden Addon", document);
  const hasInstalledAddon = !!findDebugTargetByText("Normal Addon", document);
  is(
    hasSystemAddon,
    showHidden,
    "System addon display is correct when showHiddenAddons is " + showHidden
  );
  is(
    hasHiddenAddon,
    showHidden,
    "Hidden addon display is correct when showHiddenAddons is " + showHidden
  );
  ok(hasInstalledAddon, "Installed addon is always displayed");

  await removeTab(tab);
}