--- a/browser/modules/test/unit/test_SitePermissions.js
+++ b/browser/modules/test/unit/test_SitePermissions.js
@@ -1,20 +1,28 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
"use strict";
Components.utils.import("resource:///modules/SitePermissions.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
+const STORAGE_MANAGER_ENABLED = Services.prefs.getBoolPref("browser.storageManager.enabled");
+
add_task(function* testPermissionsListing() {
- Assert.deepEqual(SitePermissions.listPermissions().sort(),
- ["camera", "cookie", "desktop-notification", "focus-tab-by-prompt", "geo", "image",
- "indexedDB", "install", "microphone", "persistent-storage", "popup", "screen"],
+ let expectedPermissions = ["camera", "cookie", "desktop-notification", "focus-tab-by-prompt",
+ "geo", "image", "indexedDB", "install", "microphone", "popup", "screen"];
+ if (STORAGE_MANAGER_ENABLED) {
+ // The persistent-storage permission is still only pref-on on Nightly
+ // so we add it only when it's pref-on.
+ // Should remove this checking and add it as default after it is fully pref-on.
+ expectedPermissions.push("persistent-storage");
+ }
+ Assert.deepEqual(SitePermissions.listPermissions().sort(), expectedPermissions.sort(),
"Correct list of all permissions");
});
add_task(function* testGetAllByURI() {
// check that it returns an empty array on an invalid URI
// like a file URI, which doesn't support site permissions
let wrongURI = Services.io.newURI("file:///example.js")
Assert.deepEqual(SitePermissions.getAllByURI(wrongURI), []);
@@ -68,17 +76,23 @@ add_task(function* testGetAvailableState
SitePermissions.BLOCK ]);
});
add_task(function* testExactHostMatch() {
let uri = Services.io.newURI("https://example.com");
let subUri = Services.io.newURI("https://test1.example.com");
let exactHostMatched = ["desktop-notification", "focus-tab-by-prompt", "camera",
- "microphone", "screen", "geo", "persistent-storage"];
+ "microphone", "screen", "geo"];
+ if (STORAGE_MANAGER_ENABLED) {
+ // The persistent-storage permission is still only pref-on on Nightly
+ // so we add it only when it's pref-on.
+ // Should remove this checking and add it as default after it is fully pref-on.
+ exactHostMatched.push("persistent-storage");
+ }
let nonExactHostMatched = ["image", "cookie", "popup", "install", "indexedDB"];
let permissions = SitePermissions.listPermissions();
for (let permission of permissions) {
SitePermissions.set(uri, permission, SitePermissions.ALLOW);
if (exactHostMatched.includes(permission)) {
// Check that the sub-origin does not inherit the permission from its parent.