4 <title>Test suspend()resume()
</title>
5 <style type=
"text/css">
11 font-family: monospace
;
17 <h1>Test suspend()/resume()
</h1>
20 The functionality of suspend()/resume() can't currently be tested with an OfflineAudioContext,
21 so they need to be tested manually here.
24 You may want to open up a console window to see the messages, in addition to viewing the
25 messages in the Results area below.
30 Test for
<a href=
"crbug.com/483002">issue
483002</a>
33 Perform the following steps
36 Start Test: you should hear a tone.
39 Run Test: This runs the test. You may press this multiple times. Each press should cause
40 "suspended" and
"running" to be printed out in the Results section below and in the
44 End Test: Press this to end the test and stop the audio.
48 <button onclick=
"test1Start()">Test
1: Start Test
</button>
49 <button onclick=
"test1Run()">Test
1: Run Test
</button>
50 <button onclick=
"test1End()">Test
1: End Test
</button>
55 Test for
<a href=
"crbug.com/483269">issue
483269</a>
58 Perform the following steps
61 Start Test: you should hear a tone. Wait a little bit before proceeding.
64 Run Test: You may press this multiple times. This calls suspend()/resume() multiple times.
65 The tone should stop momentarily, but restart very quickly. You should still hear the
69 End Test: Stops the tone.
74 If you do not hear a tone after running the test (but before ending), the test has failed.
76 <button onclick=
"test2Start()">Test
2: Start Test
</button>
77 <button onclick=
"test2Run()">Test
2: Run Test
</button>
78 <button onclick=
"test2End()">Test
2: End Test
</button>
80 <header>Results
</header>
81 <div id=
"results"></div>
84 var context
= new AudioContext();
88 function test1Start() {
89 oscillator
= context
.createOscillator();
90 oscillator
.connect(context
.destination
);
97 context
.suspend().then(function () {
98 log(context
.state
, testCount
);
99 return context
.resume().then(function () {
100 log(context
.state
, testCount
);
102 log("Failed to resume context: " + e
, testCount
);
105 log("Failed to suspend context: " + e
, testCount
);
106 }).then(function () {;
107 log("Test 1 Run: should should be audible");
111 function test1End() {
116 function test2Start() {
117 if (context
.state
=== "suspended") {
118 context
.resume().then(function () {},
119 function (e
) { log("Failed to resume context: " + e
); })
122 oscillator
= context
.createOscillator();
123 oscillator
.connect(context
.destination
);
128 function test2Run() {
133 context
.resume().then(function () {
134 if (context
.state
=== "running") {
135 log("Test 2 Run: sound should be audible");
137 log("Test 2 Run: FAIL: context not running!");
142 function test2End() {
147 function log(message
, count
) {
148 var prefix
= count
+ ": ";
150 if (count
=== undefined)
153 prefix
= count
+ ": ";
154 console
.log(prefix
+ message
);
155 var results
= document
.querySelector("#results");
156 results
.textContent
+= prefix
+ message
+ "\n";