summaryrefslogtreecommitdiffstats
path: root/dom/media/webaudio/test/test_slowStart.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /dom/media/webaudio/test/test_slowStart.html
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webaudio/test/test_slowStart.html')
-rw-r--r--dom/media/webaudio/test/test_slowStart.html48
1 files changed, 48 insertions, 0 deletions
diff --git a/dom/media/webaudio/test/test_slowStart.html b/dom/media/webaudio/test/test_slowStart.html
new file mode 100644
index 0000000000..17de7351c1
--- /dev/null
+++ b/dom/media/webaudio/test/test_slowStart.html
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test AudioContext.currentTime</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();
+SimpleTest.requestFlakyTimeout("This test needs to periodically query the AudioContext's position.");
+const CUBEB_INIT_DELAY = 5000;
+// Delay audio stream start by a good 5 seconds
+SpecialPowers.pushPrefEnv({"set": [["media.cubeb.slow_stream_init_ms",
+ CUBEB_INIT_DELAY]]}, runTest);
+
+
+function runTest() {
+ let ac = new AudioContext();
+ let notStartedYetCount = 0;
+ let startWallClockTime = performance.now();
+ is(ac.currentTime, 0, "AudioContext.currentTime should be 0 initially");
+ is(ac.state, "suspended", "AudioContext.currentTime is initially suspended");
+ let intervalHandle = setInterval(function() {
+ if (ac.state == "running" || ac.currentTime > 0) {
+ clearInterval(intervalHandle);
+ return;
+ }
+ is(ac.currentTime, 0, "AudioContext.currentTime is still 0");
+ is(ac.state, "suspended", "AudioContext.currentTime is still suspended");
+ notStartedYetCount++;
+ });
+ ac.onstatechange = function() {
+ is(ac.state, "running", "The AudioContext eventually started.");
+ var startDuration = performance.now() - startWallClockTime;
+ info(`AudioContext start time with a delay of ${CUBEB_INIT_DELAY}): ${startDuration}`);
+ ok(notStartedYetCount > 0, "We should have observed the AudioContext in \"suspended\" state");
+ ok(startDuration >= CUBEB_INIT_DELAY, "The AudioContext state transition was correct.");
+ SimpleTest.finish();
+ }
+}
+
+</script>
+</pre>
+</body>
+</html>