webapprt/test/chrome/browser_webperm.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 { AppsUtils } = Cu.import("resource://gre/modules/AppsUtils.jsm", {});
     3 let { DOMApplicationRegistry } =
     4   Cu.import("resource://gre/modules/Webapps.jsm", {});
     5 let { PermissionsTable, PermissionsReverseTable } =
     6   Cu.import("resource://gre/modules/PermissionsTable.jsm", {});
     8 function test() {
     9   waitForExplicitFinish();
    11   loadWebapp("webperm.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     let perms = [ "indexedDB-unlimited", "geolocation",
    22                   "camera", "alarms", "tcp-socket", "network-events",
    23                   "webapps-manage", "desktop-notification" ];
    25     for (let permName of perms) {
    26       // Get the values for all the permission.
    27       let permValue = Services.perms.testExactPermissionFromPrincipal(principal, permName);
    29       // Check if the app has the permission as specified in the PermissionsTable.jsm file.
    30       let realPerm = PermissionsReverseTable[permName];
    31       is(permValue, PermissionsTable[realPerm]["app"], "Permission " + permName + " correctly set.");
    32     }
    34     finish();
    35   });
    36 }

mercurial