| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title> |
| 5 OfflineAudioContext - Thread Smoke Test |
| 6 </title> |
| 7 <script src="../../resources/testharness.js"></script> |
| 8 <script src="../../resources/testharnessreport.js"></script> |
| 9 <script src="../resources/audit.js"></script> |
| 10 </head> |
| 11 <body> |
| 12 <script id="layout-test-code"> |
| 13 const audit = Audit.createTaskRunner(); |
| 14 |
| 15 // The common sample rate. |
| 16 const sampleRate = 48000; |
| 17 |
| 18 // To make channel count and buffer length irrelevant to this test. |
| 19 const numberOfChannels = 1; |
| 20 const renderLength = 1; |
| 21 |
| 22 // Create 2500 contexts in total. 58.0.3029 on OSX crashes around 2030. |
| 23 const maxNumberOfContexts = 2500; |
| 24 |
| 25 let contexts = []; |
| 26 |
| 27 // For recursive and sequential rendering of multiple context. |
| 28 function recurseContextRendering(index, oncomplete) { |
| 29 if (index < maxNumberOfContexts) { |
| 30 contexts[index].startRendering().then(() => { |
| 31 recurseContextRendering(index + 1, oncomplete); |
| 32 }); |
| 33 } else { |
| 34 oncomplete(index); |
| 35 } |
| 36 } |
| 37 |
| 38 // Create contexts up front, but do not start rendering. Based on |
| 39 // crbug.com/716800, this caused a crash with out-of-threads error. |
| 40 audit.define( |
| 41 { |
| 42 label: 'context-creation-smoketest', |
| 43 description: |
| 44 'Creating ' + maxNumberOfContexts + ' contexts up front.' |
| 45 }, |
| 46 (task, should) => { |
| 47 let i; |
| 48 for (i = 0; i < maxNumberOfContexts; ++i) { |
| 49 contexts.push(new OfflineAudioContext( |
| 50 numberOfChannels, renderLength, sampleRate)); |
| 51 } |
| 52 should(i, 'The number of created contexts without a crash') |
| 53 .beEqualTo(maxNumberOfContexts); |
| 54 task.done(); |
| 55 }); |
| 56 |
| 57 // Create contexts, render and drop them sequentially. This should not |
| 58 // crash the browser with out-of-threads error. |
| 59 audit.define( |
| 60 { |
| 61 label: 'rendering-thread-smoketest', |
| 62 description: |
| 63 'Rendering ' + maxNumberOfContexts + ' contexts sequentially.' |
| 64 }, |
| 65 (task, should) => { |
| 66 recurseContextRendering(0, (counter) => { |
| 67 should(counter, 'The number of contexts rendered without a crash') |
| 68 .beEqualTo(maxNumberOfContexts); |
| 69 task.done(); |
| 70 }); |
| 71 }); |
| 72 |
| 73 audit.run(); |
| 74 </script> |
| 75 </body> |
| 76 </html> |
| OLD | NEW |