2013-08-16 23:17:52 +04:00
|
|
|
Cu.import("resource://webapprt/modules/WebappRT.jsm");
|
|
|
|
let { AppsUtils } = Cu.import("resource://gre/modules/AppsUtils.jsm", {});
|
|
|
|
let { DOMApplicationRegistry } =
|
|
|
|
Cu.import("resource://gre/modules/Webapps.jsm", {});
|
2015-01-06 13:19:00 +03:00
|
|
|
let { PermissionsTable } =
|
2013-08-16 23:17:52 +04:00
|
|
|
Cu.import("resource://gre/modules/PermissionsTable.jsm", {});
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
loadWebapp("webperm.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");
|
|
|
|
|
2015-01-06 13:19:00 +03:00
|
|
|
let perms = [
|
|
|
|
{
|
|
|
|
manifestName: "storage",
|
|
|
|
permName: "indexedDB",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
manifestName: "geolocation",
|
|
|
|
permName: "geolocation",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
manifestName: "camera",
|
|
|
|
permName: "camera",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
manifestName: "alarms",
|
|
|
|
permName: "alarms",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
manifestName: "tcp-socket",
|
|
|
|
permName: "tcp-socket",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
manifestName: "network-events",
|
|
|
|
permName: "network-events",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
manifestName: "webapps-manage",
|
|
|
|
permName: "webapps-manage",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
manifestName: "desktop-notification",
|
|
|
|
permName: "desktop-notification",
|
|
|
|
},
|
|
|
|
];
|
2013-08-16 23:17:52 +04:00
|
|
|
|
2015-01-06 13:19:00 +03:00
|
|
|
for (let perm of perms) {
|
2013-08-16 23:17:52 +04:00
|
|
|
// Get the values for all the permission.
|
2015-01-06 13:19:00 +03:00
|
|
|
let permValue = Services.perms.testExactPermissionFromPrincipal(principal, perm.permName);
|
2013-08-16 23:17:52 +04:00
|
|
|
|
|
|
|
// Check if the app has the permission as specified in the PermissionsTable.jsm file.
|
2015-01-06 13:19:00 +03:00
|
|
|
is(permValue, PermissionsTable[perm.manifestName]["app"], "Permission " + perm.permName + " correctly set.");
|
2013-08-16 23:17:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
finish();
|
|
|
|
});
|
|
|
|
}
|