Commit 3598941e authored by Karl Tomlinson's avatar Karl Tomlinson
Browse files

Bug 1712892 add Page-Info Permissions-tab item to block speaker selection r=pbz

An all-device "Allow" option is not provided because the permission grant
prompt is primarily a device selection, which will (with subsequent patches)
grant persistent permission for the selected device.

Bug 1800287 covers setting a similar block from the selectAudioOutput() prompt.

Differential Revision: https://phabricator.services.mozilla.com/D162232
parent 41f4ad5f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -255,6 +255,9 @@
                        data-l10n-id="urlbar-midi-blocked"/>
                  <image data-permission-id="install" class="blocked-permission-icon install-icon" role="button"
                        data-l10n-id="urlbar-install-blocked"/>
                  <!-- A speaker icon for blocked speaker selection is not
                       shown because, without text, this may be interpreted as
                       active or blocked audio. -->
                </box>
              </box>
              <box id="notification-popup-box"
+18 −0
Original line number Diff line number Diff line
@@ -134,6 +134,24 @@ var gTests = [
      await escapePrompt();
    },
  },
  {
    desc: "SitePermissions speaker block",
    run: async function checkPermissionsBlock() {
      SitePermissions.setForPrincipal(
        gBrowser.contentPrincipal,
        "speaker",
        SitePermissions.BLOCK
      );
      await Promise.all([
        expectObserverCalled("getUserMedia:request"),
        expectObserverCalled("recording-window-ended"),
        expectObserverCalled("getUserMedia:response:deny"),
        promiseMessage(permissionError),
        promiseRequestAudioOutput(),
      ]);
      SitePermissions.removeFromPrincipal(gBrowser.contentPrincipal, "speaker");
    },
  },
];

add_task(async function test() {
+3 −0
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@ permission.desktop-notification3.label = Send notifications
permission.camera.label = Use the camera
permission.microphone.label = Use the microphone
permission.screen.label = Share the screen
# LOCALIZATION NOTE (permission.speaker.label):
# Short form for (permission to) "Choose and change audio output devices".
permission.speaker.label = Select speakers
permission.install.label = Install add-ons
permission.popup.label = Open pop-up windows
permission.geo.label = Access your location
+15 −0
Original line number Diff line number Diff line
@@ -1209,6 +1209,14 @@ let gPermissions = {
      states: [SitePermissions.UNKNOWN, SitePermissions.BLOCK],
    },

    speaker: {
      exactHostMatch: true,
      states: [SitePermissions.UNKNOWN, SitePermissions.BLOCK],
      get disabled() {
        return !SitePermissions.setSinkIdEnabled;
      },
    },

    popup: {
      getDefault() {
        return Services.prefs.getBoolPref("dom.disable_open_during_load")
@@ -1296,6 +1304,13 @@ XPCOMUtils.defineLazyPreferenceGetter(
  "privacy.temporary_permission_expire_time_ms",
  3600 * 1000
);
XPCOMUtils.defineLazyPreferenceGetter(
  SitePermissions,
  "setSinkIdEnabled",
  "media.setsinkid.enabled",
  false,
  SitePermissions.invalidatePermissionList.bind(SitePermissions)
);
XPCOMUtils.defineLazyPreferenceGetter(
  SitePermissions,
  "resistFingerprinting",
+10 −0
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@ const EXT_PROTOCOL_ENABLED = Services.prefs.getBoolPref(
  "security.external_protocol_requires_permission"
);

const SPEAKER_SELECTION_ENABLED = Services.prefs.getBoolPref(
  "media.setsinkid.enabled"
);

add_task(async function testPermissionsListing() {
  let expectedPermissions = [
    "autoplay-media",
@@ -47,6 +51,9 @@ add_task(async function testPermissionsListing() {
  if (EXT_PROTOCOL_ENABLED) {
    expectedPermissions.push("open-protocol-handler");
  }
  if (SPEAKER_SELECTION_ENABLED) {
    expectedPermissions.push("speaker");
  }
  Assert.deepEqual(
    SitePermissions.listPermissions().sort(),
    expectedPermissions.sort(),
@@ -209,6 +216,9 @@ add_task(async function testExactHostMatch() {
  if (EXT_PROTOCOL_ENABLED) {
    exactHostMatched.push("open-protocol-handler");
  }
  if (SPEAKER_SELECTION_ENABLED) {
    exactHostMatched.push("speaker");
  }
  let nonExactHostMatched = [
    "cookie",
    "popup",