dom/apps/tests/unit/test_manifestSanitizer.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/apps/tests/unit/test_manifestSanitizer.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +function testEntryPoint(aRoot) {
     1.8 +  do_check_true(aRoot.name == "hello world");
     1.9 +  do_check_true(aRoot.description == "A bold name");
    1.10 +  do_check_true(aRoot.developer.name == "Blink Inc.");
    1.11 +
    1.12 +  let permissions = aRoot.permissions;
    1.13 +  do_check_true(permissions.contacts.description == "Required for autocompletion in the share screen");
    1.14 +  do_check_true(permissions.alarms.description == "Required to schedule notifications");
    1.15 +}
    1.16 +
    1.17 +function run_test() {
    1.18 +  Components.utils.import("resource:///modules/AppsUtils.jsm");
    1.19 +
    1.20 +  do_check_true(!!AppsUtils);
    1.21 +
    1.22 +  // Test manifest, with one entry point.
    1.23 +  let manifest = {
    1.24 +    name: "hello <b>world</b>",
    1.25 +    description: "A bold name",
    1.26 +    developer: {
    1.27 +      name: "<blink>Blink</blink> Inc.",
    1.28 +      url: "http://blink.org"
    1.29 +    },
    1.30 +    permissions : {
    1.31 +      "contacts": {
    1.32 +        "description": "Required for autocompletion in the <a href='http://shareme.com'>share</a> screen",
    1.33 +        "access": "readcreate"
    1.34 +        },
    1.35 +      "alarms": {
    1.36 +        "description": "Required to schedule notifications"
    1.37 +      }
    1.38 +    },
    1.39 +
    1.40 +    entry_points: {
    1.41 +      "subapp": {
    1.42 +        name: "hello <b>world</b>",
    1.43 +        description: "A bold name",
    1.44 +        developer: {
    1.45 +          name: "<blink>Blink</blink> Inc.",
    1.46 +          url: "http://blink.org"
    1.47 +        },
    1.48 +        permissions : {
    1.49 +          "contacts": {
    1.50 +            "description": "Required for autocompletion in the <a href='http://shareme.com'>share</a> screen",
    1.51 +            "access": "readcreate"
    1.52 +            },
    1.53 +          "alarms": {
    1.54 +            "description": "Required to schedule notifications"
    1.55 +          }
    1.56 +        }
    1.57 +      }
    1.58 +    }
    1.59 +  }
    1.60 +
    1.61 +  AppsUtils.sanitizeManifest(manifest);
    1.62 +
    1.63 +  // Check the main section and the subapp entry point.
    1.64 +  testEntryPoint(manifest);
    1.65 +  testEntryPoint(manifest.entry_points.subapp);
    1.66 +}

mercurial