Bug 883591 - Don't allow creating a MediaStreamDestinationNode on an OfflineAudioContext. r=ehsan
authorPaul Adenot <paul@paul.cx>
Thu, 18 Jul 2013 11:57:38 +0200
changeset 139001 4a86241a8aae236f1e667781bac4629ff43d9392
parent 139000 65fd27c976769554377663f904b3b21dbc4ef938
child 139002 843d948e138bd7382bdd661870f1c0e5bdc6e058
push id31200
push userpaul@paul.cx
push dateThu, 18 Jul 2013 09:58:08 +0000
treeherdermozilla-inbound@4a86241a8aae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs883591
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 883591 - Don't allow creating a MediaStreamDestinationNode on an OfflineAudioContext. r=ehsan
content/media/webaudio/AudioContext.cpp
content/media/webaudio/AudioContext.h
content/media/webaudio/test/test_OfflineAudioContext.html
dom/webidl/AudioContext.webidl
--- a/content/media/webaudio/AudioContext.cpp
+++ b/content/media/webaudio/AudioContext.cpp
@@ -208,18 +208,23 @@ bool IsValidBufferSize(uint32_t aBufferS
   default:
     return false;
   }
 }
 
 }
 
 already_AddRefed<MediaStreamAudioDestinationNode>
-AudioContext::CreateMediaStreamDestination()
+AudioContext::CreateMediaStreamDestination(ErrorResult& aRv)
 {
+  if (mIsOffline) {
+    aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
+    return nullptr;
+  }
+
   nsRefPtr<MediaStreamAudioDestinationNode> node =
       new MediaStreamAudioDestinationNode(this);
   return node.forget();
 }
 
 already_AddRefed<ScriptProcessorNode>
 AudioContext::CreateScriptProcessor(uint32_t aBufferSize,
                                     uint32_t aNumberOfInputChannels,
--- a/content/media/webaudio/AudioContext.h
+++ b/content/media/webaudio/AudioContext.h
@@ -122,17 +122,17 @@ public:
                uint32_t aLength, float aSampleRate,
                ErrorResult& aRv);
 
   already_AddRefed<AudioBuffer>
   CreateBuffer(JSContext* aJSContext, ArrayBuffer& aBuffer,
                bool aMixToMono, ErrorResult& aRv);
 
   already_AddRefed<MediaStreamAudioDestinationNode>
-  CreateMediaStreamDestination();
+  CreateMediaStreamDestination(ErrorResult& aRv);
 
   already_AddRefed<ScriptProcessorNode>
   CreateScriptProcessor(uint32_t aBufferSize,
                         uint32_t aNumberOfInputChannels,
                         uint32_t aNumberOfOutputChannels,
                         ErrorResult& aRv);
 
   already_AddRefed<ScriptProcessorNode>
--- a/content/media/webaudio/test/test_OfflineAudioContext.html
+++ b/content/media/webaudio/test/test_OfflineAudioContext.html
@@ -18,16 +18,20 @@ addLoadEvent(function() {
   var buf = ctx.createBuffer(2, 100, ctx.sampleRate);
   for (var i = 0; i < 2; ++i) {
     for (var j = 0; j < 100; ++j) {
       buf.getChannelData(i)[j] = Math.sin(2 * Math.PI * 200 * j / ctx.sampleRate);
     }
   }
 
   expectException(function() {
+    ctx.createMediaStreamDestination();
+  }, DOMException.NOT_SUPPORTED_ERR);
+
+  expectException(function() {
     new OfflineAudioContext(2, 100, 0);
   }, DOMException.NOT_SUPPORTED_ERR);
   expectException(function() {
     new OfflineAudioContext(2, 100, -1);
   }, DOMException.NOT_SUPPORTED_ERR);
   expectException(function() {
     new OfflineAudioContext(0, 100, 44100);
   }, DOMException.NOT_SUPPORTED_ERR);
--- a/dom/webidl/AudioContext.webidl
+++ b/dom/webidl/AudioContext.webidl
@@ -27,17 +27,17 @@ interface AudioContext : EventTarget {
     void decodeAudioData(ArrayBuffer audioData,
                          DecodeSuccessCallback successCallback,
                          optional DecodeErrorCallback errorCallback);
 
     // AudioNode creation 
     [Creator]
     AudioBufferSourceNode createBufferSource();
 
-    [Creator]
+    [Creator, Throws]
     MediaStreamAudioDestinationNode createMediaStreamDestination();
 
     [Creator, Throws]
     ScriptProcessorNode createScriptProcessor(optional unsigned long bufferSize = 0,
                                               optional unsigned long numberOfInputChannels = 2,
                                               optional unsigned long numberOfOutputChannels = 2);
 
     [Creator]