webapprt/test/chrome/browser_webperm.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:e9810426f159
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", {});
7
8 function test() {
9 waitForExplicitFinish();
10
11 loadWebapp("webperm.webapp", undefined, function onLoad() {
12 let app = WebappRT.config.app;
13
14 // Check that the app is non privileged.
15 is(AppsUtils.getAppManifestStatus(app.manifest), Ci.nsIPrincipal.APP_STATUS_INSTALLED, "The app is not privileged");
16
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");
20
21 let perms = [ "indexedDB-unlimited", "geolocation",
22 "camera", "alarms", "tcp-socket", "network-events",
23 "webapps-manage", "desktop-notification" ];
24
25 for (let permName of perms) {
26 // Get the values for all the permission.
27 let permValue = Services.perms.testExactPermissionFromPrincipal(principal, permName);
28
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 }
33
34 finish();
35 });
36 }

mercurial