summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webaudio/the-audio-api/the-audiocontext-interface/constructor-allowed-to-start.html
blob: f866b5f7a1cb408c1a0c26c21c99bb7a28d53e82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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>