diff options
Diffstat (limited to 'testing/web-platform/tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor.html')
-rw-r--r-- | testing/web-platform/tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor.html | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor.html b/testing/web-platform/tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor.html new file mode 100644 index 0000000000..a711419656 --- /dev/null +++ b/testing/web-platform/tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor.html @@ -0,0 +1,73 @@ +<!DOCTYPE html> + +<html class="a"> + <head> + <title>MediaStreamAudioSourceNode</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body class="a"> + <div id="log"></div> + <script> + setup({explicit_done: true}); + // Wait until the DOM is ready to be able to get a reference to the canvas + // element. + window.addEventListener("load", function() { + const ac = new AudioContext(); + const emptyStream = new MediaStream(); + + test(function() { + assert_throws_dom( + "InvalidStateError", + function() { + ac.createMediaStreamSource(emptyStream); + }, + `A MediaStreamAudioSourceNode can only be constructed via the factory + method with a MediaStream that has at least one track of kind "audio"` + ); + }, "MediaStreamAudioSourceNode created with factory method and MediaStream with no tracks"); + + test(function() { + assert_throws_dom( + "InvalidStateError", + function() { + new MediaStreamAudioSourceNode(ac, { mediaStream: emptyStream }); + }, + `A MediaStreamAudioSourceNode can only be constructed via the constructor + with a MediaStream that has at least one track of kind "audio"` + ); + }, "MediaStreamAudioSourceNode created with constructor and MediaStream with no tracks"); + + const canvas = document.querySelector("canvas"); + const ctx = canvas.getContext("2d"); + const videoOnlyStream = canvas.captureStream(); + + test(function() { + assert_throws_dom( + "InvalidStateError", + function() { + ac.createMediaStreamSource(videoOnlyStream); + }, + `A MediaStreamAudioSourceNode can only be constructed via the factory with a + MediaStream that has at least one track of kind "audio"` + ); + }, `MediaStreamAudioSourceNode created with the factory method and MediaStream with only a video track`); + + test(function() { + assert_throws_dom( + "InvalidStateError", + function() { + new MediaStreamAudioSourceNode(ac, { + mediaStream: videoOnlyStream, + }); + }, + `A MediaStreamAudioSourceNode can only be constructed via the factory with a + MediaStream that has at least one track of kind "audio"` + ); + }, `MediaStreamAudioSourceNode created with constructor and MediaStream with only a video track`); + done(); + }); + </script> + </body> + <canvas></canvas> +</html> |