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