summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_softblocked.js
blob: edf53183d0e433c0075a5e60d3b697caf64b5f3b (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

// useMLBF=true only supports hard blocks, not soft blocks.
enable_blocklist_v2_instead_of_useMLBF();

// Tests that an appDisabled add-on that becomes softBlocked remains disabled
// when becoming appEnabled
add_task(async function test_softblock() {
  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
  await promiseStartupManager();

  await promiseInstallWebExtension({
    manifest: {
      name: "Softblocked add-on",
      version: "1.0",
      browser_specific_settings: {
        gecko: {
          id: "softblock1@tests.mozilla.org",
          strict_min_version: "2",
          strict_max_version: "3",
        },
      },
    },
  });
  let s1 = await promiseAddonByID("softblock1@tests.mozilla.org");

  // Make sure to mark it as previously enabled.
  await s1.enable();

  Assert.ok(!s1.softDisabled);
  Assert.ok(s1.appDisabled);
  Assert.ok(!s1.isActive);

  await AddonTestUtils.loadBlocklistRawData({
    extensions: [
      {
        guid: "softblock1@tests.mozilla.org",
        versionRange: [
          {
            severity: "1",
          },
        ],
      },
    ],
  });

  Assert.ok(s1.softDisabled);
  Assert.ok(s1.appDisabled);
  Assert.ok(!s1.isActive);

  AddonTestUtils.appInfo.platformVersion = "2";
  await promiseRestartManager("2");

  s1 = await promiseAddonByID("softblock1@tests.mozilla.org");

  Assert.ok(s1.softDisabled);
  Assert.ok(!s1.appDisabled);
  Assert.ok(!s1.isActive);
});