| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="resources/compatibility.js"></script> | 4 <script src="resources/compatibility.js"></script> |
| 5 <script src="resources/audio-testing.js"></script> | 5 <script src="resources/audio-testing.js"></script> |
| 6 <script src="../resources/js-test.js"></script> | 6 <script src="../resources/js-test.js"></script> |
| 7 </head> | 7 </head> |
| 8 <body> | 8 <body> |
| 9 <script> | 9 <script> |
| 10 description("Tests that ScriptProcessorNode event dispatch doesn't fail when det
ached from document."); | 10 description("Tests document-detached use of AudioContext, pass if no crash."); |
| 11 | 11 |
| 12 window.jsTestIsAsync = true; | 12 window.jsTestIsAsync = true; |
| 13 | 13 |
| 14 var sampleRate = 44100.0; | 14 var sampleRate = 44100.0; |
| 15 var renderLengthInFrames = 512; | 15 var renderLengthInFrames = 512; |
| 16 var bufferSize = 512; | 16 var bufferSize = 512; |
| 17 var context; | 17 var context; |
| 18 var node; |
| 18 function runTest() | 19 function runTest() |
| 19 { | 20 { |
| 20 var node; | |
| 21 | |
| 22 try { | 21 try { |
| 23 node = context.createScriptProcessor(bufferSize, 0, 1); | 22 node = context.createScriptProcessor(bufferSize, 0, 1); |
| 24 testPassed("Successfully created ScriptProcessorNode."); | 23 var source = context.createBufferSource(); |
| 24 source.buffer = createImpulseBuffer(context, bufferSize); |
| 25 node.onaudioprocess = function(e) { }; |
| 26 source.connect(node); |
| 27 node.connect(context.destination); |
| 28 source.start(0); |
| 29 |
| 30 context.startRendering(); |
| 25 } catch (e) { | 31 } catch (e) { |
| 26 testFailed("Failed to create ScriptProcessorNode."); | 32 // The context has been stopped and detached; nothing to test. |
| 33 return; |
| 27 } | 34 } |
| 28 | |
| 29 var source = context.createBufferSource(); | |
| 30 source.buffer = createImpulseBuffer(context, bufferSize); | |
| 31 | |
| 32 node.onaudioprocess = function(e) { }; | |
| 33 source.connect(node); | |
| 34 node.connect(context.destination); | |
| 35 source.start(0); | |
| 36 | |
| 37 context.startRendering(); | |
| 38 } | 35 } |
| 39 | 36 |
| 40 var w; | 37 var w; |
| 41 function processMessage(event) { | 38 function processMessage(event) { |
| 42 if (event.data == "opened") { | 39 if (event.data == "opened") { |
| 43 context = new w.OfflineAudioContext(1, renderLengthInFrames, sampleRate)
; | 40 context = new w.OfflineAudioContext(1, renderLengthInFrames, sampleRate)
; |
| 44 w.close(); | 41 w.close(); |
| 45 } else if (event.data == "closed") { | 42 } else if (event.data == "closed") { |
| 46 runTest(); | 43 runTest(); |
| 47 finishJSTest(); | 44 finishJSTest(); |
| 48 } | 45 } |
| 49 } | 46 } |
| 50 | 47 |
| 51 if (window.testRunner) { | 48 if (window.testRunner) { |
| 52 testRunner.dumpAsText(); | 49 testRunner.dumpAsText(); |
| 53 testRunner.waitUntilDone(); | 50 testRunner.waitUntilDone(); |
| 54 testRunner.setCanOpenWindows(); | 51 testRunner.setCanOpenWindows(); |
| 55 } | 52 } |
| 56 | 53 |
| 57 w = window.open('../resources/window-postmessage-open-close.html'); | 54 w = window.open('../resources/window-postmessage-open-close.html'); |
| 58 window.addEventListener("message", processMessage, false); | 55 window.addEventListener("message", processMessage, false); |
| 59 </script> | 56 </script> |
| 60 </body> | 57 </body> |
| 61 </html> | 58 </html> |
| OLD | NEW |