Firefox – Give Firefox permanent access to microphone on localhost

audiofirefoxlocalhostmicrophoneSecurity

Problem:

I'm developing a webpage that uses the microphone to generate animations. I understand that FireFox needs to ask the user for mic access permission due to privacy concerns. However, hitting "Allow" every time I refresh the page, as a developer, gets really tedious.

First attempt:

I see there's an option to "Remember this decision", but it doesn't let me use this, because my content is being served via localhost, and not through a secure (https) connection:

enter image description here

Your connection to this site is not secure. To protect you, Firefox will only allow access for this session.

Second Attempt:

I tried adding localhost to the list of allowed websites under Settings, and still the problem persists:

enter image description here

Question:

Is there any way to override this security feature? I understand that this is a great feature to protect users from malicious websites, but this is localhost, and only for me to look at.

Best Answer

As far as I know, you can't. The exact reason for the block is called getUserMedia.reasonForNoPermanentAllow.insecure. So unless you can tweak/spoof that somehow the only option would be to re-compile firefox from source.

The code you would need you change resides here.

// Don't offer "always remember" action in PB mode.
if (!PrivateBrowsingUtils.isBrowserPrivate(aBrowser)) {

  // Disable the permanent 'Allow' action if the connection isn't secure, or for
  // screen/audio sharing (because we can't guess which window the user wants to
  // share without prompting).

  let reasonForNoPermanentAllow = "";
  if (sharingScreen) {
    reasonForNoPermanentAllow = "getUserMedia.reasonForNoPermanentAllow.screen3";
  } else if (sharingAudio) {
    reasonForNoPermanentAllow = "getUserMedia.reasonForNoPermanentAllow.audio";
  } else if (!aRequest.secure) {
    reasonForNoPermanentAllow = "getUserMedia.reasonForNoPermanentAllow.insecure";
  }

  options.checkbox = {
    label: stringBundle.getString("getUserMedia.remember"),
    checkedState: reasonForNoPermanentAllow ? {
      disableMainAction: true,
      warningLabel: stringBundle.getFormattedString(reasonForNoPermanentAllow,
                                                    [productName])
    } : undefined,
  };
}
Related Question