Bug 1047268 - Call SpecialPowers.pushPermissions() to ensure permission change is completed before continuing the rest of the tests. r=dhylands

This commit is contained in:
JW Wang 2014-08-01 01:48:00 -04:00
parent 5590faba5b
commit 1d4bc3f2ca

View File

@ -49,18 +49,28 @@ SpecialPowers.pushPrefEnv({
// Need special permission to access "apps". We always have the permission in B2G
// mochitests, but on other platforms, we need to manually add the permission.
var needAppsPermission = false;;
if (!SpecialPowers.testPermission(
"webapps-manage", SpecialPowers.Ci.nsIPermissionManager.ALLOW_ACTION, document)) {
ok(!navigator.getDeviceStorage("apps"), "Should not have apps storage without permission");
SpecialPowers.addPermission("webapps-manage", true, document);
needAppsPermission = true;
}
ok(navigator.getDeviceStorage("apps"), "Should have apps storage with permission");
ok(navigator.getDeviceStorage("sdcard"), "Should have sdcard storage");
ok(navigator.getDeviceStorage("crashes"), "Should have crashes storage");
var testFunction = function() {
ok(navigator.getDeviceStorage("apps"), "Should have apps storage with permission");
ok(navigator.getDeviceStorage("sdcard"), "Should have sdcard storage");
ok(navigator.getDeviceStorage("crashes"), "Should have crashes storage");
// The test harness reverts our pref changes automatically.
SimpleTest.finish();
}
// The test harness reverts our pref changes automatically.
SimpleTest.finish();
if (needAppsPermission) {
SpecialPowers.pushPermissions(
[{ "type":"webapps-manage", "allow": true, "context": document }],
testFunction);
} else {
testFunction();
}
});
</script>