diff -r 000000000000 -r 6474c204b198 webapprt/test/chrome/browser_noperm.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webapprt/test/chrome/browser_noperm.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,31 @@ +Cu.import("resource://webapprt/modules/WebappRT.jsm"); +let { AllPossiblePermissions } = + Cu.import("resource://gre/modules/PermissionsInstaller.jsm", {}); +let { AppsUtils } = Cu.import("resource://gre/modules/AppsUtils.jsm", {}); +let { DOMApplicationRegistry } = + Cu.import("resource://gre/modules/Webapps.jsm", {}); + +function test() { + waitForExplicitFinish(); + + loadWebapp("noperm.webapp", undefined, function onLoad() { + let app = WebappRT.config.app; + + // Check that the app is non privileged. + is(AppsUtils.getAppManifestStatus(app.manifest), Ci.nsIPrincipal.APP_STATUS_INSTALLED, "The app is not privileged"); + + // Check that the app principal has the correct appId. + let principal = document.getElementById("content").contentDocument.defaultView.document.nodePrincipal; + is(DOMApplicationRegistry.getAppLocalIdByManifestURL(app.manifestURL), principal.appId, "Principal app ID correct"); + + // Check if all the permissions of the app are unknown. + for (let permName of AllPossiblePermissions) { + // Get the value for the permission. + let permValue = Services.perms.testExactPermissionFromPrincipal(principal, permName); + + is(permValue, Ci.nsIPermissionManager.UNKNOWN_ACTION, "Permission " + permName + " unknown."); + } + + finish(); + }); +}