4 <script src=
"resources/compatibility.js"></script>
5 <script src=
"resources/audio-testing.js"></script>
6 <script src=
"../resources/js-test.js"></script>
10 description("Tests document-detached use of OfflineAudioContext, pass if no crash.");
12 window
.jsTestIsAsync
= true;
14 function errorCallback(error
)
16 testPassed("OfflineAudioContext.startRendering() on a closed context threw an exception.");
20 function successCallback()
22 testFailed("OfflineAudioContext.startRendering() on a closed context did not throw an exception.");
29 context
.startRendering().then(successCallback
, errorCallback
);
32 function createOfflineContext()
34 var sampleRate
= 44100.0;
35 var renderLengthInFrames
= 512;
38 context
= new w
.OfflineAudioContext(1, renderLengthInFrames
, sampleRate
);
39 var node
= context
.createScriptProcessor(bufferSize
, 0, 1);
40 var source
= context
.createBufferSource();
41 source
.buffer
= createImpulseBuffer(context
, bufferSize
);
42 node
.onaudioprocess = function(e
) { };
44 node
.connect(context
.destination
);
49 function processMessage(event
) {
50 if (event
.data
== "opened") {
51 createOfflineContext();
53 } else if (event
.data
== "closed") {
54 setTimeout(runTest
, 100);
58 if (window
.testRunner
) {
59 testRunner
.dumpAsText();
60 testRunner
.waitUntilDone();
61 testRunner
.setCanOpenWindows();
64 w
= window
.open('../resources/window-postmessage-open-close.html');
65 window
.addEventListener("message", processMessage
, false);