michael@0: Cu.import("resource://webapprt/modules/WebappRT.jsm"); michael@0: let { AppsUtils } = Cu.import("resource://gre/modules/AppsUtils.jsm", {}); michael@0: let { DOMApplicationRegistry } = michael@0: Cu.import("resource://gre/modules/Webapps.jsm", {}); michael@0: let { PermissionsTable, PermissionsReverseTable } = michael@0: Cu.import("resource://gre/modules/PermissionsTable.jsm", {}); michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: loadWebapp("webperm.webapp", undefined, function onLoad() { michael@0: let app = WebappRT.config.app; michael@0: michael@0: // Check that the app is non privileged. michael@0: is(AppsUtils.getAppManifestStatus(app.manifest), Ci.nsIPrincipal.APP_STATUS_INSTALLED, "The app is not privileged"); michael@0: michael@0: // Check that the app principal has the correct appId. michael@0: let principal = document.getElementById("content").contentDocument.defaultView.document.nodePrincipal; michael@0: is(DOMApplicationRegistry.getAppLocalIdByManifestURL(app.manifestURL), principal.appId, "Principal app ID correct"); michael@0: michael@0: let perms = [ "indexedDB-unlimited", "geolocation", michael@0: "camera", "alarms", "tcp-socket", "network-events", michael@0: "webapps-manage", "desktop-notification" ]; michael@0: michael@0: for (let permName of perms) { michael@0: // Get the values for all the permission. michael@0: let permValue = Services.perms.testExactPermissionFromPrincipal(principal, permName); michael@0: michael@0: // Check if the app has the permission as specified in the PermissionsTable.jsm file. michael@0: let realPerm = PermissionsReverseTable[permName]; michael@0: is(permValue, PermissionsTable[realPerm]["app"], "Permission " + permName + " correctly set."); michael@0: } michael@0: michael@0: finish(); michael@0: }); michael@0: }