cdumez@apple.com | 6987018 | 2020-09-26 22:13:56 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <body> |
| 4 | <script src="../resources/js-test.js"></script> |
| 5 | <script> |
| 6 | description("Makes sure that we don't throw an exception when constructing an AudioNode with a closed context."); |
| 7 | |
| 8 | async function runTest() { |
| 9 | iframe = document.createElement("iframe"); |
| 10 | document.body.appendChild(iframe); |
| 11 | context = new iframe.contentWindow.AudioContext(); |
| 12 | document.body.removeChild(iframe); |
| 13 | |
| 14 | shouldNotThrow("new AnalyserNode(context)"); |
| 15 | shouldNotThrow("new AudioBufferSourceNode(context)"); |
| 16 | shouldNotThrow("new BiquadFilterNode(context)"); |
| 17 | shouldNotThrow("new ChannelMergerNode(context)"); |
| 18 | shouldNotThrow("new ChannelSplitterNode(context)"); |
| 19 | shouldNotThrow("new ConstantSourceNode(context)"); |
| 20 | shouldNotThrow("new ConvolverNode(context)"); |
| 21 | shouldNotThrow("new DelayNode(context)"); |
| 22 | shouldNotThrow("new DynamicsCompressorNode(context)"); |
| 23 | shouldNotThrow("new GainNode(context)"); |
| 24 | shouldNotThrow("new IIRFilterNode(context, { feedforward: [1], feedback: [1, -0.9] })"); |
| 25 | shouldNotThrow("new MediaElementAudioSourceNode(context, { mediaElement: new Audio })"); |
| 26 | shouldThrowErrorName("new MediaStreamAudioDestinationNode(context)", "NotAllowedError"); // Not per specification but this is Blink's behavior. |
| 27 | shouldNotThrow("new OscillatorNode(context)"); |
| 28 | shouldNotThrow("new PannerNode(context)"); |
| 29 | shouldNotThrow("new PeriodicWave(context)"); |
| 30 | shouldNotThrow("new StereoPannerNode(context)"); |
| 31 | shouldNotThrow("new WaveShaperNode(context)"); |
| 32 | |
| 33 | shouldNotThrow("context.createAnalyser()"); |
| 34 | shouldNotThrow("context.createBufferSource()"); |
| 35 | shouldNotThrow("context.createBiquadFilter()"); |
| 36 | shouldNotThrow("context.createChannelMerger()"); |
| 37 | shouldNotThrow("context.createChannelSplitter()"); |
| 38 | shouldNotThrow("context.createConstantSource()"); |
| 39 | shouldNotThrow("context.createConvolver()"); |
| 40 | shouldNotThrow("context.createDelay()"); |
| 41 | shouldNotThrow("context.createDynamicsCompressor()"); |
| 42 | shouldNotThrow("context.createGain()"); |
| 43 | shouldNotThrow("context.createIIRFilter([1], [1, -0.9])"); |
| 44 | shouldNotThrow("context.createMediaElementSource(new Audio)"); |
| 45 | shouldThrowErrorName("context.createMediaStreamDestination()", "NotAllowedError"); // Not per specification but this is Blink's behavior. |
| 46 | shouldNotThrow("context.createOscillator()"); |
| 47 | shouldNotThrow("context.createPanner()"); |
| 48 | shouldNotThrow("context.createPeriodicWave([1, 2], [1, 2])"); |
| 49 | shouldNotThrow("context.createStereoPanner()"); |
| 50 | shouldNotThrow("context.createWaveShaper()"); |
| 51 | shouldNotThrow("context.createScriptProcessor()"); |
| 52 | |
| 53 | await shouldRejectWithErrorName("context.suspend()", "InvalidStateError"); |
| 54 | await shouldRejectWithErrorName("context.resume()", "InvalidStateError"); |
| 55 | await shouldRejectWithErrorName("context.close()", "InvalidStateError"); |
| 56 | } |
| 57 | |
| 58 | onload = runTest; |
| 59 | </script> |
| 60 | </body> |
| 61 | </html> |