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