1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/webapprt/test/chrome/browser_webperm.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,36 @@ 1.4 +Cu.import("resource://webapprt/modules/WebappRT.jsm"); 1.5 +let { AppsUtils } = Cu.import("resource://gre/modules/AppsUtils.jsm", {}); 1.6 +let { DOMApplicationRegistry } = 1.7 + Cu.import("resource://gre/modules/Webapps.jsm", {}); 1.8 +let { PermissionsTable, PermissionsReverseTable } = 1.9 + Cu.import("resource://gre/modules/PermissionsTable.jsm", {}); 1.10 + 1.11 +function test() { 1.12 + waitForExplicitFinish(); 1.13 + 1.14 + loadWebapp("webperm.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 + let perms = [ "indexedDB-unlimited", "geolocation", 1.25 + "camera", "alarms", "tcp-socket", "network-events", 1.26 + "webapps-manage", "desktop-notification" ]; 1.27 + 1.28 + for (let permName of perms) { 1.29 + // Get the values for all the permission. 1.30 + let permValue = Services.perms.testExactPermissionFromPrincipal(principal, permName); 1.31 + 1.32 + // Check if the app has the permission as specified in the PermissionsTable.jsm file. 1.33 + let realPerm = PermissionsReverseTable[permName]; 1.34 + is(permValue, PermissionsTable[realPerm]["app"], "Permission " + permName + " correctly set."); 1.35 + } 1.36 + 1.37 + finish(); 1.38 + }); 1.39 +}