webapprt/test/chrome/browser_noperm.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/webapprt/test/chrome/browser_noperm.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,31 @@
     1.4 +Cu.import("resource://webapprt/modules/WebappRT.jsm");
     1.5 +let { AllPossiblePermissions } =
     1.6 +  Cu.import("resource://gre/modules/PermissionsInstaller.jsm", {});
     1.7 +let { AppsUtils } = Cu.import("resource://gre/modules/AppsUtils.jsm", {});
     1.8 +let { DOMApplicationRegistry } =
     1.9 +  Cu.import("resource://gre/modules/Webapps.jsm", {});
    1.10 +
    1.11 +function test() {
    1.12 +  waitForExplicitFinish();
    1.13 +
    1.14 +  loadWebapp("noperm.webapp", undefined, function onLoad() {
    1.15 +    let app = WebappRT.config.app;
    1.16 +
    1.17 +    // Check that the app is non privileged.
    1.18 +    is(AppsUtils.getAppManifestStatus(app.manifest), Ci.nsIPrincipal.APP_STATUS_INSTALLED, "The app is not privileged");
    1.19 +
    1.20 +    // Check that the app principal has the correct appId.
    1.21 +    let principal = document.getElementById("content").contentDocument.defaultView.document.nodePrincipal;
    1.22 +    is(DOMApplicationRegistry.getAppLocalIdByManifestURL(app.manifestURL), principal.appId, "Principal app ID correct");
    1.23 +
    1.24 +    // Check if all the permissions of the app are unknown.
    1.25 +    for (let permName of AllPossiblePermissions) {
    1.26 +      // Get the value for the permission.
    1.27 +      let permValue = Services.perms.testExactPermissionFromPrincipal(principal, permName);
    1.28 +
    1.29 +      is(permValue, Ci.nsIPermissionManager.UNKNOWN_ACTION, "Permission " + permName + " unknown.");
    1.30 +    }
    1.31 +
    1.32 +    finish();
    1.33 +  });
    1.34 +}

mercurial