From cbdefabbd2c714e903ceda6502a2e41ea9b586d3 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Sun, 23 Jun 2013 19:22:10 -0400 Subject: [PATCH] Bug 886165 - Hide the alternate names in the spec behind prefs which are turned off by default; r=roc This patch uses one pref per interface, to allow us finer grain control over which ones we might need to turn on in the future. --- content/media/test/crashtests/875144.html | 4 +-- content/media/test/crashtests/876024-2.html | 4 +-- content/media/test/crashtests/876215.html | 4 +-- content/media/test/crashtests/880202.html | 2 +- content/media/webaudio/BiquadFilterNode.cpp | 21 +++++++++++++ content/media/webaudio/PannerNode.h | 30 +++++++++++++++++++ .../webaudio/test/blink/audio-testing.js | 2 +- .../test/blink/panner-model-testing.js | 2 +- .../media/webaudio/test/test_bug867174.html | 2 +- .../media/webaudio/test/test_bug875221.html | 2 +- .../media/webaudio/test/test_bug875402.html | 2 +- .../test/test_convolverNode_mono_mono.html | 2 +- dom/webidl/AudioBufferSourceNode.webidl | 6 ++-- dom/webidl/AudioContext.webidl | 6 ++-- dom/webidl/AudioParam.webidl | 2 +- dom/webidl/BiquadFilterNode.webidl | 8 +++++ dom/webidl/PannerNode.webidl | 5 ++++ testing/profiles/prefs_general.js | 8 +++++ 18 files changed, 92 insertions(+), 20 deletions(-) diff --git a/content/media/test/crashtests/875144.html b/content/media/test/crashtests/875144.html index 88ba7880fe9d..3a1543df3e28 100644 --- a/content/media/test/crashtests/875144.html +++ b/content/media/test/crashtests/875144.html @@ -36,7 +36,7 @@ o11[i] = Math.sin(i * 127); } return o10; }(); } catch(e) { Logger.error(Logger.comment(e)); } -try { o3.noteOff(-1) } catch(e) { Logger.error(Logger.comment(e)); } +try { o3.stop(-1) } catch(e) { Logger.error(Logger.comment(e)); } /* [Exception... "An attempt was made to use an object that is not, or is no longer, usable" code: "11" nsresult: "0x8053000b (InvalidStateError)" location: "file:///Users/cdiehl/dev/projects/peach/Peach/Utilities/JS/undefined.js Line: 602"] */ try { o3.channelCountMode = 'explicit'; } catch(e) { Logger.error(Logger.comment(e)); } try { o12 = o1.createBiquadFilter(); } catch(e) { Logger.error(Logger.comment(e)); } @@ -78,4 +78,4 @@ o22[i] = Math.sin(i * 63); } return o21; }(); } catch(e) { Logger.error(Logger.comment(e)); } - \ No newline at end of file + diff --git a/content/media/test/crashtests/876024-2.html b/content/media/test/crashtests/876024-2.html index d299ec4d2d67..616ed7e97af0 100644 --- a/content/media/test/crashtests/876024-2.html +++ b/content/media/test/crashtests/876024-2.html @@ -7,8 +7,8 @@ function boom() { var bufferSource = AudioContext().createScriptProcessor().context.createBufferSource(); - bufferSource.noteGrainOn(0, 0, 0); - bufferSource.noteOff(562949953421313); + bufferSource.start(0, 0, 0); + bufferSource.stop(562949953421313); } diff --git a/content/media/test/crashtests/876215.html b/content/media/test/crashtests/876215.html index 3ead4ae72873..07135e362831 100644 --- a/content/media/test/crashtests/876215.html +++ b/content/media/test/crashtests/876215.html @@ -1,6 +1,6 @@ \ No newline at end of file + diff --git a/content/media/test/crashtests/880202.html b/content/media/test/crashtests/880202.html index ca364045ba2d..dc0fade9db49 100644 --- a/content/media/test/crashtests/880202.html +++ b/content/media/test/crashtests/880202.html @@ -23,7 +23,7 @@ BufferSource1.buffer=function(){ }(); Gain0.connect(Panner0); -Panner0.panningModel=0; +Panner0.panningModel="equalpower"; setTimeout(function(){ diff --git a/content/media/webaudio/BiquadFilterNode.cpp b/content/media/webaudio/BiquadFilterNode.cpp index c241c2d8576c..fe45106ce3a4 100644 --- a/content/media/webaudio/BiquadFilterNode.cpp +++ b/content/media/webaudio/BiquadFilterNode.cpp @@ -10,6 +10,7 @@ #include "AudioDestinationNode.h" #include "WebAudioUtils.h" #include "blink/Biquad.h" +#include "mozilla/Preferences.h" namespace mozilla { namespace dom { @@ -201,6 +202,26 @@ BiquadFilterNode::WrapObject(JSContext* aCx, JS::Handle aScope) void BiquadFilterNode::SetType(BiquadFilterType aType) { + if (!Preferences::GetBool("media.webaudio.legacy.BiquadFilterNode")) { + // Do not accept the alternate enum values unless the legacy pref + // has been turned on. + switch (aType) { + case BiquadFilterType::_0: + case BiquadFilterType::_1: + case BiquadFilterType::_2: + case BiquadFilterType::_3: + case BiquadFilterType::_4: + case BiquadFilterType::_5: + case BiquadFilterType::_6: + case BiquadFilterType::_7: + // Do nothing in order to emulate setting an invalid enum value. + return; + default: + // Shut up the compiler warning + break; + } + } + // Handle the alternate enum values switch (aType) { case BiquadFilterType::_0: aType = BiquadFilterType::Lowpass; break; diff --git a/content/media/webaudio/PannerNode.h b/content/media/webaudio/PannerNode.h index cb177abe80ba..d0b0839a319b 100644 --- a/content/media/webaudio/PannerNode.h +++ b/content/media/webaudio/PannerNode.h @@ -14,6 +14,7 @@ #include "mozilla/dom/PannerNodeBinding.h" #include "ThreeDPoint.h" #include "mozilla/WeakPtr.h" +#include "mozilla/Preferences.h" #include "WebAudioUtils.h" #include @@ -42,6 +43,20 @@ public: } void SetPanningModel(PanningModelType aPanningModel) { + if (!Preferences::GetBool("media.webaudio.legacy.PannerNode")) { + // Do not accept the alternate enum values unless the legacy pref + // has been turned on. + switch (aPanningModel) { + case PanningModelType::_0: + case PanningModelType::_1: + // Do nothing in order to emulate setting an invalid enum value. + return; + default: + // Shut up the compiler warning + break; + } + } + // Handle the alternate enum values switch (aPanningModel) { case PanningModelType::_0: aPanningModel = PanningModelType::Equalpower; break; @@ -61,6 +76,21 @@ public: } void SetDistanceModel(DistanceModelType aDistanceModel) { + if (!Preferences::GetBool("media.webaudio.legacy.PannerNode")) { + // Do not accept the alternate enum values unless the legacy pref + // has been turned on. + switch (aDistanceModel) { + case DistanceModelType::_0: + case DistanceModelType::_1: + case DistanceModelType::_2: + // Do nothing in order to emulate setting an invalid enum value. + return; + default: + // Shut up the compiler warning + break; + } + } + // Handle the alternate enum values switch (aDistanceModel) { case DistanceModelType::_0: aDistanceModel = DistanceModelType::Linear; break; diff --git a/content/media/webaudio/test/blink/audio-testing.js b/content/media/webaudio/test/blink/audio-testing.js index d46723559fd2..c66d32c7f222 100644 --- a/content/media/webaudio/test/blink/audio-testing.js +++ b/content/media/webaudio/test/blink/audio-testing.js @@ -161,7 +161,7 @@ function timeToSampleFrame(time, sampleRate) { return Math.floor(0.5 + time * sampleRate); } -// Compute the number of sample frames consumed by noteGrainOn with +// Compute the number of sample frames consumed by start with // the specified |grainOffset|, |duration|, and |sampleRate|. function grainLengthInSampleFrames(grainOffset, duration, sampleRate) { var startFrame = timeToSampleFrame(grainOffset, sampleRate); diff --git a/content/media/webaudio/test/blink/panner-model-testing.js b/content/media/webaudio/test/blink/panner-model-testing.js index c021ee52de2a..e4679958a3a6 100644 --- a/content/media/webaudio/test/blink/panner-model-testing.js +++ b/content/media/webaudio/test/blink/panner-model-testing.js @@ -58,7 +58,7 @@ function createGraph(context, nodeCount) { // Start the source time[k] = k * timeStep; - bufferSource[k].noteOn(time[k]); + bufferSource[k].start(time[k]); } } diff --git a/content/media/webaudio/test/test_bug867174.html b/content/media/webaudio/test/test_bug867174.html index 55880777c288..c95b02534b46 100644 --- a/content/media/webaudio/test/test_bug867174.html +++ b/content/media/webaudio/test/test_bug867174.html @@ -16,7 +16,7 @@ addLoadEvent(function() { var source = ctx.createBufferSource(); var buffer = ctx.createBuffer(2, 2048, 8000); - source.playbackRate.setTargetValueAtTime(0, 2, 3); + source.playbackRate.setTargetAtTime(0, 2, 3); var sp = ctx.createScriptProcessor(); source.connect(sp); sp.connect(ctx.destination); diff --git a/content/media/webaudio/test/test_bug875221.html b/content/media/webaudio/test/test_bug875221.html index 3f5d8557ad58..875144b4c696 100644 --- a/content/media/webaudio/test/test_bug875221.html +++ b/content/media/webaudio/test/test_bug875221.html @@ -17,7 +17,7 @@ try { (document.body || document.documentElement).appendChild(o0); } catch(e) { try { o1 = new OfflineAudioContext(1, 10, (new AudioContext()).sampleRate); } catch(e) { } try { o1.startRendering(); } catch(e) { } try { o1.listener.dopplerFactor = 1; } catch(e) { } -try { o2 = o1.createJavaScriptNode(); } catch(e) { } +try { o2 = o1.createScriptProcessor(); } catch(e) { } try { o3 = o1.createChannelMerger(4); } catch(e) { } try { o1.listener.dopplerFactor = 3; } catch(e) { } try { o1.listener.setPosition(0, 134217728, 64) } catch(e) { } diff --git a/content/media/webaudio/test/test_bug875402.html b/content/media/webaudio/test/test_bug875402.html index da1fe091ec80..0b13c6e17246 100644 --- a/content/media/webaudio/test/test_bug875402.html +++ b/content/media/webaudio/test/test_bug875402.html @@ -12,7 +12,7 @@ SpecialPowers.setBoolPref("media.webaudio.enabled", true); SimpleTest.waitForExplicitFinish(); try { o1 = new OfflineAudioContext(1, 10, (new AudioContext()).sampleRate); } catch(e) { } -try { o2 = o1.createJavaScriptNode(); } catch(e) { } +try { o2 = o1.createScriptProcessor(); } catch(e) { } try { o4 = new OfflineAudioContext(1, 10, (new AudioContext()).sampleRate); } catch(e) { } try { o5 = o1.createChannelSplitter(4); } catch(e) { } try { o7 = o4.createScriptProcessor(1024, 4, 1); } catch(e) { } diff --git a/content/media/webaudio/test/test_convolverNode_mono_mono.html b/content/media/webaudio/test/test_convolverNode_mono_mono.html index f11fe7077819..725c072413f9 100644 --- a/content/media/webaudio/test/test_convolverNode_mono_mono.html +++ b/content/media/webaudio/test/test_convolverNode_mono_mono.html @@ -55,7 +55,7 @@ function runTest() { bufferSource.connect(convolver); convolver.connect(context.destination); - bufferSource.noteOn(0); + bufferSource.start(0); context.oncomplete = checkConvolvedResult(trianglePulse); context.startRendering(); diff --git a/dom/webidl/AudioBufferSourceNode.webidl b/dom/webidl/AudioBufferSourceNode.webidl index 936c57f8063f..06f3d33f84bc 100644 --- a/dom/webidl/AudioBufferSourceNode.webidl +++ b/dom/webidl/AudioBufferSourceNode.webidl @@ -38,12 +38,12 @@ interface AudioBufferSourceNode : AudioNode { [PrefControlled] partial interface AudioBufferSourceNode { // Same as start() - [Throws] + [Throws,Pref="media.webaudio.legacy.AudioBufferSourceNode"] void noteOn(double when); - [Throws] + [Throws,Pref="media.webaudio.legacy.AudioBufferSourceNode"] void noteGrainOn(double when, double grainOffset, double grainDuration); - [Throws] + [Throws,Pref="media.webaudio.legacy.AudioBufferSourceNode"] // Same as stop() void noteOff(double when); }; diff --git a/dom/webidl/AudioContext.webidl b/dom/webidl/AudioContext.webidl index ffe1a392d867..1204993d2f2c 100644 --- a/dom/webidl/AudioContext.webidl +++ b/dom/webidl/AudioContext.webidl @@ -78,15 +78,15 @@ interface AudioContext : EventTarget { [PrefControlled] partial interface AudioContext { // Same as createGain() - [Creator] + [Creator,Pref="media.webaudio.legacy.AudioContext"] GainNode createGainNode(); // Same as createDelay() - [Creator, Throws] + [Creator, Throws, Pref="media.webaudio.legacy.AudioContext"] DelayNode createDelayNode(optional double maxDelayTime = 1); // Same as createScriptProcessor() - [Creator, Throws] + [Creator, Throws, Pref="media.webaudio.legacy.AudioContext"] ScriptProcessorNode createJavaScriptNode(optional unsigned long bufferSize = 0, optional unsigned long numberOfInputChannels = 2, optional unsigned long numberOfOutputChannels = 2); diff --git a/dom/webidl/AudioParam.webidl b/dom/webidl/AudioParam.webidl index 7981d377e995..a4789193fd2b 100644 --- a/dom/webidl/AudioParam.webidl +++ b/dom/webidl/AudioParam.webidl @@ -46,7 +46,7 @@ interface AudioParam { [PrefControlled] partial interface AudioParam { // Same as setTargetAtTime() - [Throws] + [Throws,Pref="media.webaudio.legacy.AudioParam"] void setTargetValueAtTime(float target, double startTime, double timeConstant); }; diff --git a/dom/webidl/BiquadFilterNode.webidl b/dom/webidl/BiquadFilterNode.webidl index 02101c151ea4..5a290b176b69 100644 --- a/dom/webidl/BiquadFilterNode.webidl +++ b/dom/webidl/BiquadFilterNode.webidl @@ -45,13 +45,21 @@ interface BiquadFilterNode : AudioNode { */ [PrefControlled] partial interface BiquadFilterNode { + [Pref="media.webaudio.legacy.BiquadFilterNode"] const unsigned short LOWPASS = 0; + [Pref="media.webaudio.legacy.BiquadFilterNode"] const unsigned short HIGHPASS = 1; + [Pref="media.webaudio.legacy.BiquadFilterNode"] const unsigned short BANDPASS = 2; + [Pref="media.webaudio.legacy.BiquadFilterNode"] const unsigned short LOWSHELF = 3; + [Pref="media.webaudio.legacy.BiquadFilterNode"] const unsigned short HIGHSHELF = 4; + [Pref="media.webaudio.legacy.BiquadFilterNode"] const unsigned short PEAKING = 5; + [Pref="media.webaudio.legacy.BiquadFilterNode"] const unsigned short NOTCH = 6; + [Pref="media.webaudio.legacy.BiquadFilterNode"] const unsigned short ALLPASS = 7; }; diff --git a/dom/webidl/PannerNode.webidl b/dom/webidl/PannerNode.webidl index c7f7eb1a0589..4209d3600eff 100644 --- a/dom/webidl/PannerNode.webidl +++ b/dom/webidl/PannerNode.webidl @@ -57,11 +57,16 @@ interface PannerNode : AudioNode { */ [PrefControlled] partial interface PannerNode { + [Pref="media.webaudio.legacy.PannerNode"] const unsigned short EQUALPOWER = 0; + [Pref="media.webaudio.legacy.PannerNode"] const unsigned short HRTF = 1; + [Pref="media.webaudio.legacy.PannerNode"] const unsigned short LINEAR_DISTANCE = 0; + [Pref="media.webaudio.legacy.PannerNode"] const unsigned short INVERSE_DISTANCE = 1; + [Pref="media.webaudio.legacy.PannerNode"] const unsigned short EXPONENTIAL_DISTANCE = 2; }; diff --git a/testing/profiles/prefs_general.js b/testing/profiles/prefs_general.js index ae88cd47476f..630aeb4286c0 100644 --- a/testing/profiles/prefs_general.js +++ b/testing/profiles/prefs_general.js @@ -130,3 +130,11 @@ user_pref("network.http.bypass-cachelock-threshold", 200000); // Enable Gamepad user_pref("dom.gamepad.enabled", true); user_pref("dom.gamepad.non_standard_events.enabled", true); + +// Enable Web Audio legacy APIs +user_pref("media.webaudio.legacy.AudioBufferSourceNode", true); +user_pref("media.webaudio.legacy.AudioContext", true); +user_pref("media.webaudio.legacy.AudioParam", true); +user_pref("media.webaudio.legacy.BiquadFilterNode", true); +user_pref("media.webaudio.legacy.PannerNode", true); +user_pref("media.webaudio.legacy.OscillatorNode", true);