821716aae11f4a6aff922c37e01a5c31dd0e85ce
[WebKit-https.git] / LayoutTests / webaudio / audiobuffersource-exception.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5 <script src="../fast/js/resources/js-test-pre.js"></script>
6 <script src="resources/audio-testing.js"></script>
7 <script src="resources/audiobuffersource-testing.js"></script>
8 </head>
9
10 <body>
11
12 <div id="description"></div>
13 <div id="console"></div>
14
15 <script>
16 description("Tests that AudioBufferSourceNode validates start and stop calls.");
17
18 var bufferSource;
19
20 function runTest() {
21     if (window.testRunner) {
22         testRunner.dumpAsText();
23         testRunner.waitUntilDone();
24     }
25
26     window.jsTestIsAsync = true;
27
28     var sampleRate = 44100.0;
29     var numberOfFrames = 32;
30     var context = new webkitOfflineAudioContext(1, numberOfFrames, sampleRate);
31     bufferSource = context.createBufferSource();
32     bufferSource.buffer = createTestBuffer(context, numberOfFrames);
33     bufferSource.connect(context.destination);
34
35     // 'stop' should be called only after 'start'.
36     shouldThrow("bufferSource.stop(0)", "'Error: InvalidStateError: DOM Exception 11'");
37     bufferSource.start(0);
38
39     // 'start' should be called only once.
40     shouldThrow("bufferSource.start(0)", "'Error: InvalidStateError: DOM Exception 11'");
41     bufferSource.stop(0);
42
43     context.oncomplete = finishJSTest;
44     context.startRendering();
45 }
46
47 runTest();
48
49 </script>
50
51 <script src="../fast/js/resources/js-test-post.js"></script>
52 </body>
53 </html>