diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /dom/media/webaudio/test/test_mediaElementAudioSourceNodeVideo.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream/115.8.0esr.tar.xz firefox-esr-upstream/115.8.0esr.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webaudio/test/test_mediaElementAudioSourceNodeVideo.html')
-rw-r--r-- | dom/media/webaudio/test/test_mediaElementAudioSourceNodeVideo.html | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/dom/media/webaudio/test/test_mediaElementAudioSourceNodeVideo.html b/dom/media/webaudio/test/test_mediaElementAudioSourceNodeVideo.html new file mode 100644 index 0000000000..dcb85f12cb --- /dev/null +++ b/dom/media/webaudio/test/test_mediaElementAudioSourceNodeVideo.html @@ -0,0 +1,70 @@ +<!DOCTYPE HTML> +<html> +<meta charset="utf-8"> +<head> + <title>Test MediaElementAudioSourceNode before "loadedmetadata"</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<pre id="test"> +<script class="testbody" type="text/javascript"> +SimpleTest.waitForExplicitFinish(); + +var video = document.createElement("video"); +function test() { + video.src = "audiovideo.mp4"; + + var context = new AudioContext(); + var complete = false; + + video.onended = () => { + if (complete) { + return; + } + + complete = true; + ok(false, "Video ended without any samples seen"); + SimpleTest.finish(); + }; + + video.ontimeupdate = () => { + info("Timeupdate: " + video.currentTime); + }; + + var node = context.createMediaElementSource(video); + var sp = context.createScriptProcessor(2048, 1); + node.connect(sp); + + // This test ensures we receive some nonzero samples when we capture to + // WebAudio before "loadedmetadata". + sp.onaudioprocess = e => { + if (complete) { + return; + } + + var buf = e.inputBuffer.getChannelData(0); + for (var i = 0; i < buf.length; ++i) { + if (buf[i] != 0) { + complete = true; + ok(true, "Got non-zero samples"); + SimpleTest.finish(); + return; + } + } + }; + + video.play(); +} + +if (video.canPlayType("video/mp4")) { + test(); +} else { + ok(true, "MP4 not supported. Skipping."); + SimpleTest.finish(); +} + +</script> +</pre> +</body> +</html> |