summaryrefslogtreecommitdiffstats
path: root/dom/apps/tests/unit/test_manifestSanitizer.js
blob: 4b0c999a73f8766b28eb0e34859047f4bd30245e (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

function testEntryPoint(aRoot) {
  do_check_true(aRoot.name == "hello world");
  do_check_true(aRoot.description == "A bold name");
  do_check_true(aRoot.developer.name == "Blink Inc.");

  let permissions = aRoot.permissions;
  do_check_true(permissions.contacts.description == "Required for autocompletion in the share screen");
  do_check_true(permissions.alarms.description == "Required to schedule notifications");
}

function run_test() {
  Components.utils.import("resource:///modules/AppsUtils.jsm");

  do_check_true(!!AppsUtils);

  // Test manifest, with one entry point.
  let manifest = {
    name: "hello <b>world</b>",
    description: "A bold name",
    developer: {
      name: "<blink>Blink</blink> Inc.",
      url: "http://blink.org"
    },
    permissions : {
      "contacts": {
        "description": "Required for autocompletion in the <a href='http://shareme.com'>share</a> screen",
        "access": "readcreate"
        },
      "alarms": {
        "description": "Required to schedule notifications"
      }
    },

    entry_points: {
      "subapp": {
        name: "hello <b>world</b>",
        description: "A bold name",
        developer: {
          name: "<blink>Blink</blink> Inc.",
          url: "http://blink.org"
        },
        permissions : {
          "contacts": {
            "description": "Required for autocompletion in the <a href='http://shareme.com'>share</a> screen",
            "access": "readcreate"
            },
          "alarms": {
            "description": "Required to schedule notifications"
          }
        }
      }
    }
  }

  AppsUtils.sanitizeManifest(manifest);

  // Check the main section and the subapp entry point.
  testEntryPoint(manifest);
  testEntryPoint(manifest.entry_points.subapp);
}