Bug 1457048 - Fix permissions tests to accomodate autoplay-media. r=johannh
MozReview-Commit-ID: E0BPcXPox7p
--- a/browser/locales/en-US/chrome/browser/sitePermissions.properties
+++ b/browser/locales/en-US/chrome/browser/sitePermissions.properties
@@ -23,16 +23,17 @@ state.current.hide = Hide Prompt
# state.multichoice.allowForSession,
# state.multichoice.block):
# Used to label permission state checkboxes in the page info dialog.
state.multichoice.alwaysAsk = Always Ask
state.multichoice.allow = Allow
state.multichoice.allowForSession = Allow for Session
state.multichoice.block = Block
+permission.autoplay-media.label = Automatically Play Media with Sound
permission.cookie.label = Set Cookies
permission.desktop-notification2.label = Receive Notifications
permission.image.label = Load Images
permission.camera.label = Use the Camera
permission.microphone.label = Use the Microphone
permission.screen.label = Share the Screen
permission.install.label = Install Add-ons
permission.popup.label = Open Pop-up Windows
--- a/browser/modules/test/unit/test_SitePermissions.js
+++ b/browser/modules/test/unit/test_SitePermissions.js
@@ -5,17 +5,17 @@
ChromeUtils.import("resource:///modules/SitePermissions.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
const RESIST_FINGERPRINTING_ENABLED = Services.prefs.getBoolPref("privacy.resistFingerprinting");
const MIDI_ENABLED = Services.prefs.getBoolPref("dom.webmidi.enabled");
add_task(async function testPermissionsListing() {
- let expectedPermissions = ["camera", "cookie", "desktop-notification", "focus-tab-by-prompt",
+ let expectedPermissions = ["autoplay-media", "camera", "cookie", "desktop-notification", "focus-tab-by-prompt",
"geo", "image", "install", "microphone", "plugin:flash", "popup", "screen", "shortcuts",
"persistent-storage"];
if (RESIST_FINGERPRINTING_ENABLED) {
// Canvas permission should be hidden unless privacy.resistFingerprinting
// is true.
expectedPermissions.push("canvas");
}
if (MIDI_ENABLED) {
@@ -101,17 +101,17 @@ add_task(async function testGetAvailable
[ SitePermissions.ALLOW,
SitePermissions.BLOCK ]);
});
add_task(async 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",
+ let exactHostMatched = ["autoplay-media", "desktop-notification", "focus-tab-by-prompt", "camera",
"microphone", "screen", "geo", "persistent-storage"];
if (RESIST_FINGERPRINTING_ENABLED) {
// Canvas permission should be hidden unless privacy.resistFingerprinting
// is true.
exactHostMatched.push("canvas");
}
if (MIDI_ENABLED) {
// WebMIDI is only pref'd on in nightly.
@@ -122,17 +122,17 @@ add_task(async function testExactHostMat
let nonExactHostMatched = ["image", "cookie", "plugin:flash", "popup", "install", "shortcuts"];
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.
- Assert.equal(SitePermissions.get(subUri, permission).state, SitePermissions.UNKNOWN,
+ Assert.equal(SitePermissions.get(subUri, permission).state, SitePermissions.getDefault(permission),
`${permission} should exact-host match`);
} else if (nonExactHostMatched.includes(permission)) {
// Check that the sub-origin does inherit the permission from its parent.
Assert.equal(SitePermissions.get(subUri, permission).state, SitePermissions.ALLOW,
`${permission} should not exact-host match`);
} else {
Assert.ok(false, `Found an unknown permission ${permission} in exact host match test.` +
"Please add new permissions from SitePermissions.jsm to this test.");