webapprt/test/chrome/browser_noperm.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 Cu.import("resource://webapprt/modules/WebappRT.jsm");
     2 let { AllPossiblePermissions } =
     3   Cu.import("resource://gre/modules/PermissionsInstaller.jsm", {});
     4 let { AppsUtils } = Cu.import("resource://gre/modules/AppsUtils.jsm", {});
     5 let { DOMApplicationRegistry } =
     6   Cu.import("resource://gre/modules/Webapps.jsm", {});
     8 function test() {
     9   waitForExplicitFinish();
    11   loadWebapp("noperm.webapp", undefined, function onLoad() {
    12     let app = WebappRT.config.app;
    14     // Check that the app is non privileged.
    15     is(AppsUtils.getAppManifestStatus(app.manifest), Ci.nsIPrincipal.APP_STATUS_INSTALLED, "The app is not privileged");
    17     // Check that the app principal has the correct appId.
    18     let principal = document.getElementById("content").contentDocument.defaultView.document.nodePrincipal;
    19     is(DOMApplicationRegistry.getAppLocalIdByManifestURL(app.manifestURL), principal.appId, "Principal app ID correct");
    21     // Check if all the permissions of the app are unknown.
    22     for (let permName of AllPossiblePermissions) {
    23       // Get the value for the permission.
    24       let permValue = Services.perms.testExactPermissionFromPrincipal(principal, permName);
    26       is(permValue, Ci.nsIPermissionManager.UNKNOWN_ACTION, "Permission " + permName + " unknown.");
    27     }
    29     finish();
    30   });
    31 }

mercurial