Skip to content

Commit

Permalink
Test that AudioContext's state is updated if "allowed to start" (#24611)
Browse files Browse the repository at this point in the history
  • Loading branch information
foolip committed Jul 16, 2020
1 parent 8c155e4 commit 36cff35
Showing 1 changed file with 25 additions and 0 deletions.
@@ -0,0 +1,25 @@
<!doctype html>
<title>AudioContext state around "allowed to start" in constructor</title>
<link rel=help href=https://webaudio.github.io/web-audio-api/#dom-audiocontext-audiocontext>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/resources/testdriver.js></script>
<script src=/resources/testdriver-vendor.js></script>
<script>
setup({ single_test: true });
test_driver.bless("audio playback", () => {
const ctx = new AudioContext();
// Immediately after the constructor the state is "suspended" because the
// control message to start processing has just been sent, but the state
// should change soon.
assert_equals(ctx.state, "suspended", "initial state");
ctx.onstatechange = () => {
assert_equals(ctx.state, "running", "state after statechange event");
// Now create another context and ensure it starts out in the "suspended"
// state too, ensuring it's not synchronously "running".
const ctx2 = new AudioContext();
assert_equals(ctx2.state, "suspended", "initial state of 2nd context");
done();
};
});
</script>

0 comments on commit 36cff35

Please sign in to comment.