WebProcessCache should keep track of processes being added
[WebKit-https.git] / LayoutTests / webaudio / audiocontext-promise-throwing.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5 <script src="../resources/js-test.js"></script>
6 <script src="resources/audio-testing.js"></script>
7 <script src="resources/delay-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 AudioContext resume/suspend/close methods reject promises when called on an OfflineAudioContext.");
17
18 function runTest() {
19     window.jsTestIsAsync = true;
20         
21     var context = new webkitOfflineAudioContext(1, sampleRate * renderLengthSeconds, sampleRate);
22
23     context.resume().then(function() {
24         testFailed('context.resume() promise resolved (should have rejected)');
25         finishJSTest();
26     }, function(e) {
27        if (e.name == 'InvalidStateError') 
28            testPassed('context.resume() promise rejected with InvalidStateError value');
29        else
30            testFailed('context.resume() promise rejected, but without InvalidStateError value');
31     });
32
33     context.suspend().then(function() {
34         testFailed('context.suspend() promise resolved (should have rejected)');
35         finishJSTest();
36     }, function(e) {
37        if (e.name == 'InvalidStateError') 
38            testPassed('context.suspend() promise rejected with InvalidStateError value');
39        else
40            testFailed('context.suspend() promise rejected, but without InvalidStateError value');
41     });
42
43     context.close().then(function() {
44         testFailed('context.close() promise resolved (should have rejected)');
45         finishJSTest();
46     }, function(e) {
47        if (e.name == 'InvalidStateError')
48            testPassed('context.close() promise rejected with InvalidStateError value');
49        else
50            testFailed('context.close() promise rejected, but without InvalidStateError value');
51        finishJSTest();
52     });
53 }
54
55 runTest();
56
57 </script>
58 </body>
59 </html>