Bug 1519562 throw in AudioWorkletNode constructor if name is not registered r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 19 Feb 2019 12:57:57 +0000
changeset 460212 e65b65bf6a76a2d33be297917d171d8c6ebefb9a
parent 460211 8de3a62c5f7616292ae2432cbd46a2b4497bcb5f
child 460213 57fbc6e58e2b1f3eee24713eb34d2b9b6a746f3a
push id35588
push usernbeleuzu@mozilla.com
push dateThu, 21 Feb 2019 15:59:59 +0000
treeherdermozilla-central@7fba2ab9df84 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1519562
milestone67.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 1519562 throw in AudioWorkletNode constructor if name is not registered r=padenot Depends on D20274 Differential Revision: https://phabricator.services.mozilla.com/D20275
dom/media/webaudio/AudioContext.h
dom/media/webaudio/AudioWorkletNode.cpp
testing/web-platform/meta/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-construction.https.html.ini
--- a/dom/media/webaudio/AudioContext.h
+++ b/dom/media/webaudio/AudioContext.h
@@ -310,16 +310,20 @@ class AudioContext final : public DOMEve
 
   BasicWaveFormCache* GetBasicWaveFormCache();
 
   bool CheckClosed(ErrorResult& aRv);
 
   // Steals from |aParamMap|
   void SetParamMapForWorkletName(const nsAString& aName,
                                  AudioParamDescriptorMap* aParamMap);
+  const AudioParamDescriptorMap* GetParamMapForWorkletName(
+      const nsAString& aName) {
+    return mWorkletParamDescriptors.GetValue(aName);
+  }
 
   void Dispatch(already_AddRefed<nsIRunnable>&& aRunnable);
 
  private:
   void DisconnectFromWindow();
   void RemoveFromDecodeQueue(WebAudioDecodeJob* aDecodeJob);
   void ShutdownDecoder();
 
--- a/dom/media/webaudio/AudioWorkletNode.cpp
+++ b/dom/media/webaudio/AudioWorkletNode.cpp
@@ -43,16 +43,27 @@ AudioWorkletNode::AudioWorkletNode(Audio
 
     for (uint32_t channelCount : aOptions.mOutputChannelCount.Value()) {
       if (channelCount == 0 || channelCount > WebAudioUtils::MaxChannelCount) {
         aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
         return nullptr;
       }
     }
   }
+  /**
+   * 2. If nodeName does not exists as a key in the BaseAudioContext’s node
+   *    name to parameter descriptor map, throw a NotSupportedError exception
+   *    and abort these steps.
+   */
+  const AudioParamDescriptorMap* parameterDescriptors =
+      aAudioContext.GetParamMapForWorkletName(aName);
+  if (!parameterDescriptors) {
+    aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
+    return nullptr;
+  }
 
   RefPtr<AudioWorkletNode> audioWorkletNode =
       new AudioWorkletNode(&aAudioContext, aName);
 
   audioWorkletNode->Initialize(aOptions, aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
--- a/testing/web-platform/meta/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-construction.https.html.ini
+++ b/testing/web-platform/meta/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-construction.https.html.ini
@@ -1,22 +1,10 @@
 [audioworkletnode-construction.https.html]
   expected:
     if release_or_beta: ERROR
-  [X Unregistered name "foobar" must throw an exception. did not throw an exception.]
-    expected: FAIL
-
-  [< [construction-after-module-loading\] 1 out of 2 assertions were failed.]
-    expected: FAIL
-
   [< [construction-before-module-loading\] 1 out of 1 assertions were failed.]
-    expected: FAIL
-
+    expected:
+      if release_or_beta: FAIL
   [X Creating a node before loading a module should throw. threw "ReferenceError" instead of InvalidStateError.]
     expected:
       if release_or_beta: FAIL
 
-  [X Creating a node before loading a module should throw. did not throw an exception.]
-    expected: FAIL
-
-  [# AUDIT TASK RUNNER FINISHED: 2 out of 2 tasks were failed.]
-    expected: FAIL
-