D6029: Bug 1477205 - Remove the exception when a node is created after closing the AudioContext. r?padenot

vmillet (Valentin MILLET) phabricator at mercurial-scm.org
Wed Feb 27 05:48:12 EST 2019


vmillet created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6029

AFFECTED FILES
  dom/media/webaudio/AnalyserNode.cpp
  dom/media/webaudio/AudioBufferSourceNode.cpp
  dom/media/webaudio/AudioContext.cpp
  dom/media/webaudio/AudioContext.h
  dom/media/webaudio/AudioWorkletNode.cpp
  dom/media/webaudio/BiquadFilterNode.cpp
  dom/media/webaudio/ChannelMergerNode.cpp
  dom/media/webaudio/ChannelSplitterNode.cpp
  dom/media/webaudio/ConvolverNode.cpp
  dom/media/webaudio/DelayNode.cpp
  dom/media/webaudio/DynamicsCompressorNode.cpp
  dom/media/webaudio/GainNode.cpp
  dom/media/webaudio/IIRFilterNode.cpp
  dom/media/webaudio/MediaElementAudioSourceNode.cpp
  dom/media/webaudio/MediaStreamAudioDestinationNode.cpp
  dom/media/webaudio/MediaStreamAudioSourceNode.cpp
  dom/media/webaudio/OscillatorNode.cpp
  dom/media/webaudio/PannerNode.cpp
  dom/media/webaudio/StereoPannerNode.cpp
  dom/media/webaudio/WaveShaperNode.cpp
  dom/media/webaudio/test/test_audioContextSuspendResumeClose.html

CHANGE DETAILS

diff --git a/dom/media/webaudio/test/test_audioContextSuspendResumeClose.html b/dom/media/webaudio/test/test_audioContextSuspendResumeClose.html
--- a/dom/media/webaudio/test/test_audioContextSuspendResumeClose.html
+++ b/dom/media/webaudio/test/test_audioContextSuspendResumeClose.html
@@ -41,7 +41,7 @@
         return;
       }
 
-      expectException(function() {
+      expectNoException(function() {
         ctx[e.name].apply(ctx, e.args);
       }, DOMException.INVALID_STATE_ERR);
     });
diff --git a/dom/media/webaudio/WaveShaperNode.cpp b/dom/media/webaudio/WaveShaperNode.cpp
--- a/dom/media/webaudio/WaveShaperNode.cpp
+++ b/dom/media/webaudio/WaveShaperNode.cpp
@@ -295,9 +295,6 @@
 /* static */ already_AddRefed<WaveShaperNode> WaveShaperNode::Create(
     AudioContext& aAudioContext, const WaveShaperOptions& aOptions,
     ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   RefPtr<WaveShaperNode> audioNode = new WaveShaperNode(&aAudioContext);
 
diff --git a/dom/media/webaudio/StereoPannerNode.cpp b/dom/media/webaudio/StereoPannerNode.cpp
--- a/dom/media/webaudio/StereoPannerNode.cpp
+++ b/dom/media/webaudio/StereoPannerNode.cpp
@@ -167,9 +167,6 @@
 /* static */ already_AddRefed<StereoPannerNode> StereoPannerNode::Create(
     AudioContext& aAudioContext, const StereoPannerOptions& aOptions,
     ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   RefPtr<StereoPannerNode> audioNode = new StereoPannerNode(&aAudioContext);
 
diff --git a/dom/media/webaudio/PannerNode.cpp b/dom/media/webaudio/PannerNode.cpp
--- a/dom/media/webaudio/PannerNode.cpp
+++ b/dom/media/webaudio/PannerNode.cpp
@@ -324,9 +324,6 @@
 /* static */ already_AddRefed<PannerNode> PannerNode::Create(
     AudioContext& aAudioContext, const PannerOptions& aOptions,
     ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   RefPtr<PannerNode> audioNode = new PannerNode(&aAudioContext);
 
diff --git a/dom/media/webaudio/OscillatorNode.cpp b/dom/media/webaudio/OscillatorNode.cpp
--- a/dom/media/webaudio/OscillatorNode.cpp
+++ b/dom/media/webaudio/OscillatorNode.cpp
@@ -389,9 +389,6 @@
 /* static */ already_AddRefed<OscillatorNode> OscillatorNode::Create(
     AudioContext& aAudioContext, const OscillatorOptions& aOptions,
     ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   RefPtr<OscillatorNode> audioNode = new OscillatorNode(&aAudioContext);
 
diff --git a/dom/media/webaudio/MediaStreamAudioSourceNode.cpp b/dom/media/webaudio/MediaStreamAudioSourceNode.cpp
--- a/dom/media/webaudio/MediaStreamAudioSourceNode.cpp
+++ b/dom/media/webaudio/MediaStreamAudioSourceNode.cpp
@@ -50,10 +50,6 @@
     return nullptr;
   }
 
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
-
   if (aAudioContext.Graph() !=
       aOptions.mMediaStream->GetPlaybackStream()->Graph()) {
     nsCOMPtr<nsPIDOMWindowInner> pWindow = aAudioContext.GetParentObject();
diff --git a/dom/media/webaudio/MediaStreamAudioDestinationNode.cpp b/dom/media/webaudio/MediaStreamAudioDestinationNode.cpp
--- a/dom/media/webaudio/MediaStreamAudioDestinationNode.cpp
+++ b/dom/media/webaudio/MediaStreamAudioDestinationNode.cpp
@@ -99,10 +99,6 @@
     return nullptr;
   }
 
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
-
   RefPtr<MediaStreamAudioDestinationNode> audioNode =
       new MediaStreamAudioDestinationNode(&aAudioContext);
 
diff --git a/dom/media/webaudio/MediaElementAudioSourceNode.cpp b/dom/media/webaudio/MediaElementAudioSourceNode.cpp
--- a/dom/media/webaudio/MediaElementAudioSourceNode.cpp
+++ b/dom/media/webaudio/MediaElementAudioSourceNode.cpp
@@ -25,10 +25,6 @@
     return nullptr;
   }
 
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
-
   RefPtr<MediaElementAudioSourceNode> node =
       new MediaElementAudioSourceNode(&aAudioContext);
 
diff --git a/dom/media/webaudio/IIRFilterNode.cpp b/dom/media/webaudio/IIRFilterNode.cpp
--- a/dom/media/webaudio/IIRFilterNode.cpp
+++ b/dom/media/webaudio/IIRFilterNode.cpp
@@ -158,9 +158,6 @@
 /* static */ already_AddRefed<IIRFilterNode> IIRFilterNode::Create(
     AudioContext& aAudioContext, const IIRFilterOptions& aOptions,
     ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   if (aOptions.mFeedforward.Length() == 0 ||
       aOptions.mFeedforward.Length() > 20) {
diff --git a/dom/media/webaudio/GainNode.cpp b/dom/media/webaudio/GainNode.cpp
--- a/dom/media/webaudio/GainNode.cpp
+++ b/dom/media/webaudio/GainNode.cpp
@@ -118,9 +118,6 @@
 /* static */ already_AddRefed<GainNode> GainNode::Create(
     AudioContext& aAudioContext, const GainOptions& aOptions,
     ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   RefPtr<GainNode> audioNode = new GainNode(&aAudioContext);
 
diff --git a/dom/media/webaudio/DynamicsCompressorNode.cpp b/dom/media/webaudio/DynamicsCompressorNode.cpp
--- a/dom/media/webaudio/DynamicsCompressorNode.cpp
+++ b/dom/media/webaudio/DynamicsCompressorNode.cpp
@@ -184,9 +184,6 @@
 DynamicsCompressorNode::Create(AudioContext& aAudioContext,
                                const DynamicsCompressorOptions& aOptions,
                                ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   RefPtr<DynamicsCompressorNode> audioNode =
       new DynamicsCompressorNode(&aAudioContext);
diff --git a/dom/media/webaudio/DelayNode.cpp b/dom/media/webaudio/DelayNode.cpp
--- a/dom/media/webaudio/DelayNode.cpp
+++ b/dom/media/webaudio/DelayNode.cpp
@@ -184,9 +184,6 @@
 /* static */ already_AddRefed<DelayNode> DelayNode::Create(
     AudioContext& aAudioContext, const DelayOptions& aOptions,
     ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   if (aOptions.mMaxDelayTime <= 0. || aOptions.mMaxDelayTime >= 180.) {
     aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
diff --git a/dom/media/webaudio/ConvolverNode.cpp b/dom/media/webaudio/ConvolverNode.cpp
--- a/dom/media/webaudio/ConvolverNode.cpp
+++ b/dom/media/webaudio/ConvolverNode.cpp
@@ -395,9 +395,6 @@
 /* static */ already_AddRefed<ConvolverNode> ConvolverNode::Create(
     JSContext* aCx, AudioContext& aAudioContext,
     const ConvolverOptions& aOptions, ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   RefPtr<ConvolverNode> audioNode = new ConvolverNode(&aAudioContext);
 
diff --git a/dom/media/webaudio/ChannelSplitterNode.cpp b/dom/media/webaudio/ChannelSplitterNode.cpp
--- a/dom/media/webaudio/ChannelSplitterNode.cpp
+++ b/dom/media/webaudio/ChannelSplitterNode.cpp
@@ -57,9 +57,6 @@
 /* static */ already_AddRefed<ChannelSplitterNode> ChannelSplitterNode::Create(
     AudioContext& aAudioContext, const ChannelSplitterOptions& aOptions,
     ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   if (aOptions.mNumberOfOutputs == 0 ||
       aOptions.mNumberOfOutputs > WebAudioUtils::MaxChannelCount) {
diff --git a/dom/media/webaudio/ChannelMergerNode.cpp b/dom/media/webaudio/ChannelMergerNode.cpp
--- a/dom/media/webaudio/ChannelMergerNode.cpp
+++ b/dom/media/webaudio/ChannelMergerNode.cpp
@@ -67,9 +67,6 @@
 /* static */ already_AddRefed<ChannelMergerNode> ChannelMergerNode::Create(
     AudioContext& aAudioContext, const ChannelMergerOptions& aOptions,
     ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   if (aOptions.mNumberOfInputs == 0 ||
       aOptions.mNumberOfInputs > WebAudioUtils::MaxChannelCount) {
diff --git a/dom/media/webaudio/BiquadFilterNode.cpp b/dom/media/webaudio/BiquadFilterNode.cpp
--- a/dom/media/webaudio/BiquadFilterNode.cpp
+++ b/dom/media/webaudio/BiquadFilterNode.cpp
@@ -242,9 +242,6 @@
 /* static */ already_AddRefed<BiquadFilterNode> BiquadFilterNode::Create(
     AudioContext& aAudioContext, const BiquadFilterOptions& aOptions,
     ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   RefPtr<BiquadFilterNode> audioNode = new BiquadFilterNode(&aAudioContext);
 
diff --git a/dom/media/webaudio/AudioWorkletNode.cpp b/dom/media/webaudio/AudioWorkletNode.cpp
--- a/dom/media/webaudio/AudioWorkletNode.cpp
+++ b/dom/media/webaudio/AudioWorkletNode.cpp
@@ -25,9 +25,6 @@
     const GlobalObject& aGlobal, AudioContext& aAudioContext,
     const nsAString& aName, const AudioWorkletNodeOptions& aOptions,
     ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   if (aOptions.mNumberOfInputs == 0 && aOptions.mNumberOfOutputs == 0) {
     aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
diff --git a/dom/media/webaudio/AudioContext.h b/dom/media/webaudio/AudioContext.h
--- a/dom/media/webaudio/AudioContext.h
+++ b/dom/media/webaudio/AudioContext.h
@@ -309,8 +309,6 @@
 
   BasicWaveFormCache* GetBasicWaveFormCache();
 
-  bool CheckClosed(ErrorResult& aRv);
-
   void Dispatch(already_AddRefed<nsIRunnable>&& aRunnable);
 
  private:
diff --git a/dom/media/webaudio/AudioContext.cpp b/dom/media/webaudio/AudioContext.cpp
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -323,26 +323,14 @@
   return object.forget();
 }
 
-bool AudioContext::CheckClosed(ErrorResult& aRv) {
-  if (mAudioContextState == AudioContextState::Closed || mIsShutDown ||
-      mIsDisconnecting) {
-    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return true;
-  }
-  return false;
-}
-
 already_AddRefed<AudioBufferSourceNode> AudioContext::CreateBufferSource(
     ErrorResult& aRv) {
   return AudioBufferSourceNode::Create(nullptr, *this,
                                        AudioBufferSourceOptions(), aRv);
 }
 
 already_AddRefed<ConstantSourceNode> AudioContext::CreateConstantSource(
     ErrorResult& aRv) {
-  if (CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   RefPtr<ConstantSourceNode> constantSourceNode = new ConstantSourceNode(this);
   return constantSourceNode.forget();
@@ -397,10 +385,6 @@
     return nullptr;
   }
 
-  if (CheckClosed(aRv)) {
-    return nullptr;
-  }
-
   RefPtr<ScriptProcessorNode> scriptProcessor = new ScriptProcessorNode(
       this, aBufferSize, aNumberOfInputChannels, aNumberOfOutputChannels);
   return scriptProcessor.forget();
diff --git a/dom/media/webaudio/AudioBufferSourceNode.cpp b/dom/media/webaudio/AudioBufferSourceNode.cpp
--- a/dom/media/webaudio/AudioBufferSourceNode.cpp
+++ b/dom/media/webaudio/AudioBufferSourceNode.cpp
@@ -608,9 +608,6 @@
 AudioBufferSourceNode::Create(JSContext* aCx, AudioContext& aAudioContext,
                               const AudioBufferSourceOptions& aOptions,
                               ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   RefPtr<AudioBufferSourceNode> audioNode =
       new AudioBufferSourceNode(&aAudioContext);
diff --git a/dom/media/webaudio/AnalyserNode.cpp b/dom/media/webaudio/AnalyserNode.cpp
--- a/dom/media/webaudio/AnalyserNode.cpp
+++ b/dom/media/webaudio/AnalyserNode.cpp
@@ -89,9 +89,6 @@
 /* static */ already_AddRefed<AnalyserNode> AnalyserNode::Create(
     AudioContext& aAudioContext, const AnalyserOptions& aOptions,
     ErrorResult& aRv) {
-  if (aAudioContext.CheckClosed(aRv)) {
-    return nullptr;
-  }
 
   RefPtr<AnalyserNode> analyserNode = new AnalyserNode(&aAudioContext);
 



To: vmillet, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list