summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/xpcshell/test_addonStartup.js
blob: 715b74a06805018a1c6ffe9815474f97abdf9a45 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"use strict";

add_task(async function test_XPIStates_invalid_paths() {
  let { path } = gAddonStartup;

  let startupDatasets = [
    {
      "app-profile": {
        addons: {
          "xpcshell-something-or-other@mozilla.org": {
            bootstrapped: true,
            dependencies: [],
            enabled: true,
            hasEmbeddedWebExtension: false,
            lastModifiedTime: 1,
            path: "xpcshell-something-or-other@mozilla.org",
            version: "0.0.0",
          },
        },
        checkStartupModifications: true,
        path: "/home/xpcshell/.mozilla/firefox/default/extensions",
      },
    },
    {
      "app-profile": {
        addons: {
          "xpcshell-something-or-other@mozilla.org": {
            bootstrapped: true,
            dependencies: [],
            enabled: true,
            hasEmbeddedWebExtension: false,
            lastModifiedTime: 1,
            path: "xpcshell-something-or-other@mozilla.org",
            version: "0.0.0",
          },
        },
        checkStartupModifications: true,
        path: "c:\\Users\\XpcShell\\Application Data\\Mozilla Firefox\\Profiles\\meh",
      },
    },
    {
      "app-profile": {
        addons: {
          "xpcshell-something-or-other@mozilla.org": {
            bootstrapped: true,
            dependencies: [],
            enabled: true,
            hasEmbeddedWebExtension: false,
            lastModifiedTime: 1,
            path: "/home/xpcshell/my-extensions/something-or-other",
            version: "0.0.0",
          },
        },
        checkStartupModifications: true,
        path: "/home/xpcshell/.mozilla/firefox/default/extensions",
      },
    },
    {
      "app-profile": {
        addons: {
          "xpcshell-something-or-other@mozilla.org": {
            bootstrapped: true,
            dependencies: [],
            enabled: true,
            hasEmbeddedWebExtension: false,
            lastModifiedTime: 1,
            path: "c:\\Users\\XpcShell\\my-extensions\\something-or-other",
            version: "0.0.0",
          },
        },
        checkStartupModifications: true,
        path: "c:\\Users\\XpcShell\\Application Data\\Mozilla Firefox\\Profiles\\meh",
      },
    },
  ];

  for (let startupData of startupDatasets) {
    await IOUtils.writeJSON(path, startupData, { compress: true });

    try {
      let result = aomStartup.readStartupData();
      info(`readStartupData() returned ${JSON.stringify(result)}`);
    } catch (e) {
      // We don't care if this throws, only that it doesn't crash.
      info(`readStartupData() threw: ${e}`);
      equal(
        e.result,
        Cr.NS_ERROR_FILE_UNRECOGNIZED_PATH,
        "Got expected error code"
      );
    }
  }
});