--- a/dom/media/webaudio/test/mochitest.ini
+++ b/dom/media/webaudio/test/mochitest.ini
@@ -45,16 +45,17 @@ support-files =
skip-if = (toolkit == 'android' && debug) || os == 'win' # bug 1127845, bug 1138468
[test_audioBufferSourceNodeNoStart.html]
[test_audioBufferSourceNodeNullBuffer.html]
[test_audioBufferSourceNodeOffset.html]
skip-if = (toolkit == 'gonk') || (toolkit == 'android') || debug #bug 906752
[test_audioBufferSourceNodePassThrough.html]
[test_audioBufferSourceNodeRate.html]
[test_AudioContext.html]
+[test_AudioContext_disabled.html]
[test_audioContextSuspendResumeClose.html]
skip-if = buildapp == 'mulet'
tags=capturestream
[test_audioDestinationNode.html]
[test_AudioListener.html]
[test_AudioNodeDevtoolsAPI.html]
[test_audioParamChaining.html]
[test_AudioParamDevtoolsAPI.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/test_AudioContext_disabled.html
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test whether we can disable the AudioContext interface</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="webaudio.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+const webaudio_interfaces = [
+ "AudioContext",
+ "OfflineAudioContext",
+ "AudioContext",
+ "OfflineAudioCompletionEvent",
+ "AudioNode",
+ "AudioDestinationNode",
+ "AudioParam",
+ "GainNode",
+ "DelayNode",
+ "AudioBuffer",
+ "AudioBufferSourceNode",
+ "MediaElementAudioSourceNode",
+ "ScriptProcessorNode",
+ "AudioProcessingEvent",
+ "PannerNode",
+ "AudioListener",
+ "StereoPannerNode",
+ "ConvolverNode",
+ "AnalyserNode",
+ "ChannelSplitterNode",
+ "ChannelMergerNode",
+ "DynamicsCompressorNode",
+ "BiquadFilterNode",
+ "IIRFilterNode",
+ "WaveShaperNode",
+ "OscillatorNode",
+ "PeriodicWave",
+ "MediaStreamAudioSourceNode",
+ "MediaStreamAudioDestinationNode"
+];
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+ SpecialPowers.pushPrefEnv({"set": [["dom.webaudio.enabled", false]]}, function() {
+ webaudio_interfaces.forEach((e) => ok(!window[e], e + " must be disabled when the Web Audio API is disabled"));
+ SimpleTest.finish();
+ });
+});
+
+</script>
+</pre>
+</body>
+</html>
--- a/dom/webidl/AnalyserNode.webidl
+++ b/dom/webidl/AnalyserNode.webidl
@@ -5,16 +5,17 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface AnalyserNode : AudioNode {
// Real-time frequency-domain data
void getFloatFrequencyData(Float32Array array);
void getByteFrequencyData(Uint8Array array);
// Real-time waveform data
void getFloatTimeDomainData(Float32Array array);
--- a/dom/webidl/AudioBuffer.webidl
+++ b/dom/webidl/AudioBuffer.webidl
@@ -5,16 +5,17 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface AudioBuffer {
readonly attribute float sampleRate;
readonly attribute unsigned long length;
// in seconds
readonly attribute double duration;
--- a/dom/webidl/AudioBufferSourceNode.webidl
+++ b/dom/webidl/AudioBufferSourceNode.webidl
@@ -5,16 +5,17 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface AudioBufferSourceNode : AudioNode {
attribute AudioBuffer? buffer;
readonly attribute AudioParam playbackRate;
readonly attribute AudioParam detune;
attribute boolean loop;
--- a/dom/webidl/AudioContext.webidl
+++ b/dom/webidl/AudioContext.webidl
@@ -19,17 +19,18 @@ enum AudioContextState {
"closed"
};
dictionary PeriodicWaveConstraints {
boolean disableNormalization = false;
};
[Constructor,
- Constructor(AudioChannel audioChannelType)]
+ Constructor(AudioChannel audioChannelType),
+ Pref="dom.webaudio.enabled"]
interface AudioContext : EventTarget {
readonly attribute AudioDestinationNode destination;
readonly attribute float sampleRate;
readonly attribute double currentTime;
readonly attribute AudioListener listener;
readonly attribute AudioContextState state;
[Throws]
--- a/dom/webidl/AudioDestinationNode.webidl
+++ b/dom/webidl/AudioDestinationNode.webidl
@@ -5,14 +5,15 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface AudioDestinationNode : AudioNode {
readonly attribute unsigned long maxChannelCount;
};
--- a/dom/webidl/AudioListener.webidl
+++ b/dom/webidl/AudioListener.webidl
@@ -5,16 +5,17 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface AudioListener {
// same as OpenAL (default 1)
[Deprecated="PannerNodeDoppler"]
attribute double dopplerFactor;
// in meters / second (default 343.3)
[Deprecated="PannerNodeDoppler"]
--- a/dom/webidl/AudioNode.webidl
+++ b/dom/webidl/AudioNode.webidl
@@ -16,16 +16,17 @@ enum ChannelCountMode {
"explicit"
};
enum ChannelInterpretation {
"speakers",
"discrete"
};
+[Pref="dom.webaudio.enabled"]
interface AudioNode : EventTarget {
[Throws]
AudioNode connect(AudioNode destination, optional unsigned long output = 0, optional unsigned long input = 0);
[Throws]
void connect(AudioParam destination, optional unsigned long output = 0);
[Throws]
void disconnect(optional unsigned long output = 0);
--- a/dom/webidl/AudioParam.webidl
+++ b/dom/webidl/AudioParam.webidl
@@ -5,16 +5,17 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface AudioParam {
attribute float value;
readonly attribute float defaultValue;
// Parameter automation.
[Throws]
AudioParam setValueAtTime(float value, double startTime);
--- a/dom/webidl/AudioProcessingEvent.webidl
+++ b/dom/webidl/AudioProcessingEvent.webidl
@@ -5,16 +5,17 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface AudioProcessingEvent : Event {
readonly attribute double playbackTime;
[Throws]
readonly attribute AudioBuffer inputBuffer;
[Throws]
readonly attribute AudioBuffer outputBuffer;
--- a/dom/webidl/BiquadFilterNode.webidl
+++ b/dom/webidl/BiquadFilterNode.webidl
@@ -16,16 +16,17 @@ enum BiquadFilterType {
"bandpass",
"lowshelf",
"highshelf",
"peaking",
"notch",
"allpass"
};
+[Pref="dom.webaudio.enabled"]
interface BiquadFilterNode : AudioNode {
attribute BiquadFilterType type;
readonly attribute AudioParam frequency; // in Hertz
readonly attribute AudioParam detune; // in Cents
readonly attribute AudioParam Q; // Quality factor
readonly attribute AudioParam gain; // in Decibels
--- a/dom/webidl/ChannelMergerNode.webidl
+++ b/dom/webidl/ChannelMergerNode.webidl
@@ -5,12 +5,13 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface ChannelMergerNode : AudioNode {
};
--- a/dom/webidl/ChannelSplitterNode.webidl
+++ b/dom/webidl/ChannelSplitterNode.webidl
@@ -5,12 +5,13 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface ChannelSplitterNode : AudioNode {
};
--- a/dom/webidl/ConvolverNode.webidl
+++ b/dom/webidl/ConvolverNode.webidl
@@ -5,16 +5,17 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface ConvolverNode : AudioNode {
[SetterThrows]
attribute AudioBuffer? buffer;
attribute boolean normalize;
};
--- a/dom/webidl/DelayNode.webidl
+++ b/dom/webidl/DelayNode.webidl
@@ -5,16 +5,17 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface DelayNode : AudioNode {
readonly attribute AudioParam delayTime;
};
// Mozilla extension
DelayNode implements AudioNodePassThrough;
--- a/dom/webidl/DynamicsCompressorNode.webidl
+++ b/dom/webidl/DynamicsCompressorNode.webidl
@@ -5,16 +5,17 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface DynamicsCompressorNode : AudioNode {
readonly attribute AudioParam threshold; // in Decibels
readonly attribute AudioParam knee; // in Decibels
readonly attribute AudioParam ratio; // unit-less
readonly attribute float reduction; // in Decibels
readonly attribute AudioParam attack; // in Seconds
readonly attribute AudioParam release; // in Seconds
--- a/dom/webidl/GainNode.webidl
+++ b/dom/webidl/GainNode.webidl
@@ -5,16 +5,17 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface GainNode : AudioNode {
readonly attribute AudioParam gain;
};
// Mozilla extension
GainNode implements AudioNodePassThrough;
--- a/dom/webidl/IIRFilterNode.webidl
+++ b/dom/webidl/IIRFilterNode.webidl
@@ -4,14 +4,15 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is https://www.w3.org/TR/webaudio
*
* Copyright © 2016 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface IIRFilterNode : AudioNode {
void getFrequencyResponse(Float32Array frequencyHz, Float32Array magResponse, Float32Array phaseResponse);
};
// Mozilla extension
IIRFilterNode implements AudioNodePassThrough;
--- a/dom/webidl/MediaElementAudioSourceNode.webidl
+++ b/dom/webidl/MediaElementAudioSourceNode.webidl
@@ -5,15 +5,16 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface MediaElementAudioSourceNode : AudioNode {
};
// Mozilla extensions
MediaElementAudioSourceNode implements AudioNodePassThrough;
--- a/dom/webidl/MediaStreamAudioDestinationNode.webidl
+++ b/dom/webidl/MediaStreamAudioDestinationNode.webidl
@@ -5,13 +5,14 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface MediaStreamAudioDestinationNode : AudioNode {
readonly attribute MediaStream stream;
};
--- a/dom/webidl/MediaStreamAudioSourceNode.webidl
+++ b/dom/webidl/MediaStreamAudioSourceNode.webidl
@@ -5,15 +5,16 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface MediaStreamAudioSourceNode : AudioNode {
};
// Mozilla extensions
MediaStreamAudioSourceNode implements AudioNodePassThrough;
--- a/dom/webidl/OfflineAudioCompletionEvent.webidl
+++ b/dom/webidl/OfflineAudioCompletionEvent.webidl
@@ -5,14 +5,15 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface OfflineAudioCompletionEvent : Event {
readonly attribute AudioBuffer renderedBuffer;
};
--- a/dom/webidl/OfflineAudioContext.webidl
+++ b/dom/webidl/OfflineAudioContext.webidl
@@ -5,17 +5,18 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
-[Constructor(unsigned long numberOfChannels, unsigned long length, float sampleRate)]
+[Constructor(unsigned long numberOfChannels, unsigned long length, float sampleRate),
+Pref="dom.webaudio.enabled"]
interface OfflineAudioContext : AudioContext {
[Throws]
Promise<AudioBuffer> startRendering();
attribute EventHandler oncomplete;
readonly attribute unsigned long length;
--- a/dom/webidl/OscillatorNode.webidl
+++ b/dom/webidl/OscillatorNode.webidl
@@ -13,16 +13,17 @@
enum OscillatorType {
"sine",
"square",
"sawtooth",
"triangle",
"custom"
};
+[Pref="dom.webaudio.enabled"]
interface OscillatorNode : AudioNode {
[SetterThrows]
attribute OscillatorType type;
readonly attribute AudioParam frequency; // in Hertz
readonly attribute AudioParam detune; // in Cents
--- a/dom/webidl/PannerNode.webidl
+++ b/dom/webidl/PannerNode.webidl
@@ -16,16 +16,17 @@ enum PanningModelType {
};
enum DistanceModelType {
"linear",
"inverse",
"exponential"
};
+[Pref="dom.webaudio.enabled"]
interface PannerNode : AudioNode {
// Default for stereo is equalpower
attribute PanningModelType panningModel;
// Uses a 3D cartesian coordinate system
void setPosition(double x, double y, double z);
void setOrientation(double x, double y, double z);
--- a/dom/webidl/PeriodicWave.webidl
+++ b/dom/webidl/PeriodicWave.webidl
@@ -5,12 +5,13 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface PeriodicWave {
};
--- a/dom/webidl/ScriptProcessorNode.webidl
+++ b/dom/webidl/ScriptProcessorNode.webidl
@@ -5,16 +5,17 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface ScriptProcessorNode : AudioNode {
attribute EventHandler onaudioprocess;
readonly attribute long bufferSize;
};
--- a/dom/webidl/StereoPannerNode.webidl
+++ b/dom/webidl/StereoPannerNode.webidl
@@ -5,15 +5,16 @@
*
* The origin of this IDL file is
* https://webaudio.github.io/web-audio-api/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
+[Pref="dom.webaudio.enabled"]
interface StereoPannerNode : AudioNode {
readonly attribute AudioParam pan;
};
// Mozilla extension
StereoPannerNode implements AudioNodePassThrough;
--- a/dom/webidl/WaveShaperNode.webidl
+++ b/dom/webidl/WaveShaperNode.webidl
@@ -11,16 +11,17 @@
*/
enum OverSampleType {
"none",
"2x",
"4x"
};
+[Pref="dom.webaudio.enabled"]
interface WaveShaperNode : AudioNode {
[SetterThrows]
attribute Float32Array? curve;
attribute OverSampleType oversample;
};
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -514,16 +514,18 @@ pref("media.navigator.audio.full_duplex"
#else
// *BSD, others - merely a guess for now
pref("media.peerconnection.capture_delay", 50);
pref("media.getusermedia.playout_delay", 50);
pref("media.navigator.audio.full_duplex", false);
#endif
#endif
+pref("dom.webaudio.enabled", true);
+
#if !defined(ANDROID)
pref("media.getusermedia.screensharing.enabled", true);
#endif
#ifdef RELEASE_BUILD
pref("media.getusermedia.screensharing.allowed_domains", "webex.com,*.webex.com,ciscospark.com,*.ciscospark.com,projectsquared.com,*.projectsquared.com,*.room.co,room.co,beta.talky.io,talky.io,*.clearslide.com,appear.in,*.appear.in,tokbox.com,*.tokbox.com,*.sso.francetelecom.fr,*.si.francetelecom.fr,*.sso.infra.ftgroup,*.multimedia-conference.orange-business.com,*.espacecollaboration.orange-business.com,free.gotomeeting.com,g2m.me,*.g2m.me,*.mypurecloud.com,*.mypurecloud.com.au,spreed.me,*.spreed.me,*.spreed.com,air.mozilla.org,*.circuit.com,*.yourcircuit.com,circuit.siemens.com,yourcircuit.siemens.com,circuitsandbox.net,*.unify.com,tandi.circuitsandbox.net,*.ericsson.net,*.cct.ericsson.net,*.opentok.com,*.conf.meetecho.com,meet.jit.si,*.meet.jit.si,web.stage.speakeasyapp.net,web.speakeasyapp.net,*.hipchat.me,*.beta-wspbx.com,*.wspbx.com,*.unifiedcloudit.com,*.smartboxuc.com,*.smartbox-uc.com,*.panterranetworks.com,pexipdemo.com,*.pexipdemo.com,pex.me,*.pex.me,*.rd.pexip.com,1click.io,*.1click.io,*.fuze.com,*.fuzemeeting.com,*.thinkingphones.com,gotomeeting.com,*.gotomeeting.com,gotowebinar.com,*.gotowebinar.com,gototraining.com,*.gototraining.com,citrix.com,*.citrix.com,expertcity.com,*.expertcity.com,citrixonline.com,*.citrixonline.com,g2m.me,*.g2m.me,gotomeet.me,*.gotomeet.me,gotomeet.at,*.gotomeet.at,miriadaxdes.miriadax.net,certificacion.miriadax.net,miriadax.net,*.wire.com,sylaps.com,*.sylaps.com");
#else
// includes Mozilla's test domain: mozilla.github.io (not intended for release)