OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML> | |
2 <html> | |
3 <head> | |
4 <script src="../resources/js-test.js"></script> | |
5 <script src="resources/compatibility.js"></script> | |
6 <script src="resources/audit-util.js"></script> | |
7 <script src="resources/audio-testing.js"></script> | |
8 </head> | |
9 <body> | |
10 <script> | |
11 description("Tests document-detached use of OfflineAudioContext, pass if no cras
h."); | |
12 | |
13 window.jsTestIsAsync = true; | |
14 | |
15 function errorCallback(error) | |
16 { | |
17 testPassed("OfflineAudioContext.startRendering() on a closed context threw a
n exception."); | |
18 finishJSTest(); | |
19 } | |
20 | |
21 function successCallback() | |
22 { | |
23 testFailed("OfflineAudioContext.startRendering() on a closed context did not
throw an exception."); | |
24 finishJSTest(); | |
25 } | |
26 | |
27 var context; | |
28 function runTest() | |
29 { | |
30 context.startRendering().then(successCallback, errorCallback); | |
31 } | |
32 | |
33 function createOfflineContext() | |
34 { | |
35 var sampleRate = 44100.0; | |
36 var renderLengthInFrames = 512; | |
37 var bufferSize = 512; | |
38 | |
39 context = new w.OfflineAudioContext(1, renderLengthInFrames, sampleRate); | |
40 var node = context.createScriptProcessor(bufferSize, 0, 1); | |
41 var source = context.createBufferSource(); | |
42 source.buffer = createImpulseBuffer(context, bufferSize); | |
43 node.onaudioprocess = function(e) { }; | |
44 source.connect(node); | |
45 node.connect(context.destination); | |
46 source.start(0); | |
47 } | |
48 | |
49 var w; | |
50 function processMessage(event) { | |
51 if (event.data == "opened") { | |
52 createOfflineContext(); | |
53 w.close(); | |
54 } else if (event.data == "closed") { | |
55 setTimeout(runTest, 100); | |
56 } | |
57 } | |
58 | |
59 if (window.testRunner) { | |
60 testRunner.dumpAsText(); | |
61 testRunner.waitUntilDone(); | |
62 testRunner.setCanOpenWindows(); | |
63 } | |
64 | |
65 w = window.open('../resources/window-postmessage-open-close.html'); | |
66 window.addEventListener("message", processMessage, false); | |
67 </script> | |
68 </body> | |
69 </html> | |
OLD | NEW |