Bug 1517526 - Let user allow blocked autoplay. r=johannh

Differential Revision: https://phabricator.services.mozilla.com/D17130

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dale Harvey 2019-01-22 21:48:24 +00:00
parent fb4355013b
commit d13fedb2c6
3 changed files with 22 additions and 1 deletions

View File

@ -1055,7 +1055,8 @@ var gIdentityHandler = {
SitePermissions.SCOPE_POLICY, SitePermissions.SCOPE_GLOBAL,
].includes(aPermission.scope);
if (aPermission.id == "popup" && !isPolicyPermission) {
if ((aPermission.id == "popup" && !isPolicyPermission) ||
aPermission.id == "autoplay-media") {
let menulist = document.createXULElement("menulist");
let menupopup = document.createXULElement("menupopup");
let block = document.createXULElement("vbox");

View File

@ -54,8 +54,27 @@ add_task(async function testMainViewVisible() {
let labels = permissionsList.querySelectorAll(".identity-popup-permission-label");
is(labels.length, 1, "One permission visible in main view");
is(labels[0].textContent, labelText, "Correct value");
let menulist = document.getElementById("identity-popup-popup-menulist");
Assert.equal(menulist.label, "Block");
await EventUtils.synthesizeMouseAtCenter(menulist, { type: "mousedown" });
await BrowserTestUtils.waitForCondition(() => {
return menulist.getElementsByTagName("menuitem")[0].label === "Allow";
});
let menuitem = menulist.getElementsByTagName("menuitem")[0];
Assert.equal(menuitem.getAttribute("label"), "Allow");
menuitem.click();
menulist.menupopup.hidePopup();
await closeIdentityPopup();
let uri = Services.io.newURI(AUTOPLAY_PAGE);
let state = SitePermissions.get(uri, "autoplay-media").state;
Assert.equal(state, SitePermissions.ALLOW);
});
Services.perms.removeAll();
Services.prefs.clearUserPref("media.autoplay.default");
});

View File

@ -706,6 +706,7 @@ var gPermissionObject = {
return SitePermissions.UNKNOWN;
},
labelID: "autoplay-media",
states: [ SitePermissions.ALLOW, SitePermissions.BLOCK ],
},
"image": {