WebProcessCache should keep track of processes being added
[WebKit-https.git] / LayoutTests / webaudio / audiocontext-promise.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5 <script src="../resources/js-test.js"></script>
6 </head>
7
8 <body>
9
10 <div id="description"></div>
11 <div id="console"></div>
12
13 <script>
14 description("Tests that AudioContext suspend method resolve promises immediately when already suspended.");
15
16 function runTest() {
17     window.jsTestIsAsync = true;
18
19     context = new webkitAudioContext();
20
21     var isSuspended = false;
22     context.suspend().then(function() {
23         testPassed('context resolve callback called');
24         isSuspended = true;
25     }, function() {
26         testFailed('context reject callback called');
27     });
28
29     if (isSuspended)
30         testFailed('context resolve callback called synchronously');
31  
32     var resolvePromise;
33     var promise = new Promise(function(resolve, reject) {
34         resolvePromise = resolve;
35     });
36     promise.then(function() {
37         if (isSuspended)
38             testPassed('JS promise callback called after context callback');
39         else
40             testFailed('JS promise callback called before context callback');
41         finishJSTest();
42     });
43     resolvePromise();
44 }
45
46 runTest();
47
48 </script>
49 </body>
50 </html>