summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/xpcshell/test_webextension_paths.js
blob: 564e9086acb2839e24b3c953da097e350b34860f (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
let profileDir;
add_task(async function setup() {
  profileDir = gProfD.clone();
  profileDir.append("extensions");

  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
  await promiseStartupManager();
});

// When installing an unpacked addon we derive the ID from the
// directory name.  Make sure that if the directory name is not a valid
// addon ID that we reject it.
add_task(async function test_bad_unpacked_path() {
  let MANIFEST_ID = "webext_bad_path@tests.mozilla.org";

  let manifest = {
    name: "path test",
    description: "test of a bad directory name",
    manifest_version: 2,
    version: "1.0",

    browser_specific_settings: {
      gecko: {
        id: MANIFEST_ID,
      },
    },
  };

  const directories = ["not a valid ID", '"quotes"@tests.mozilla.org'];

  for (let dir of directories) {
    try {
      await promiseWriteWebManifestForExtension(manifest, profileDir, dir);
    } catch (ex) {
      // This can fail if the underlying filesystem (looking at you windows)
      // doesn't handle some of the characters in the ID.  In that case,
      // just ignore this test on this platform.
      continue;
    }
    await promiseRestartManager();

    let addon = await promiseAddonByID(dir);
    Assert.equal(addon, null);
    addon = await promiseAddonByID(MANIFEST_ID);
    Assert.equal(addon, null);
  }
});