realtimeanalyser-fft-sizing.html (1530B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title> 5 realtimeanalyser-fft-sizing.html 6 </title> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/webaudio/resources/audit-util.js"></script> 10 <script src="/webaudio/resources/audit.js"></script> 11 </head> 12 <body> 13 <script id="layout-test-code"> 14 let audit = Audit.createTaskRunner(); 15 16 function doTest(fftSize, illegal, should) { 17 let c = new OfflineAudioContext(1, 1000, 44100); 18 let a = c.createAnalyser(); 19 let message = 'Setting fftSize to ' + fftSize; 20 let tester = function() { 21 a.fftSize = fftSize; 22 }; 23 24 if (illegal) { 25 should(tester, message).throw(DOMException, 'IndexSizeError'); 26 } else { 27 should(tester, message).notThrow(); 28 } 29 } 30 31 audit.define( 32 { 33 label: 'FFT size test', 34 description: 'Test that re-sizing the FFT arrays does not fail.' 35 }, 36 function(task, should) { 37 doTest(-1, true, should); 38 doTest(0, true, should); 39 doTest(1, true, should); 40 for (let i = 2; i <= 0x20000; i *= 2) { 41 if (i >= 32 && i <= 32768) 42 doTest(i, false, should); 43 else 44 doTest(i, true, should); 45 doTest(i + 1, true, should); 46 } 47 48 task.done(); 49 }); 50 51 audit.run(); 52 </script> 53 </body> 54 </html>