OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 | 2 |
3 <html> | 3 <html> |
4 <head> | 4 <head> |
5 <script src="../../resources/js-test.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> |
6 <script src="../resources/audit-util.js"></script> | 7 <script src="../resources/audit-util.js"></script> |
7 <script src="../resources/audio-testing.js"></script> | 8 <script src="../resources/audit.js"></script> |
8 </head> | 9 </head> |
9 | 10 |
10 <body> | 11 <body> |
11 <div id="description"></div> | 12 <script> |
12 <div id="console"></div> | 13 let audit = Audit.createTaskRunner(); |
13 | 14 |
14 <script> | 15 function doTest(fftSize, illegal, should) { |
15 description("Test that re-sizing the FFT arrays does not fail."); | 16 let c = new OfflineAudioContext(1, 1000, 44100); |
| 17 let a = c.createAnalyser(); |
| 18 let message = "Setting fftSize to " + fftSize; |
| 19 let tester = function () { |
| 20 a.fftSize = fftSize; |
| 21 }; |
16 | 22 |
17 if (window.testRunner) { | 23 if (illegal) { |
18 testRunner.dumpAsText(); | 24 should(tester, message) |
19 testRunner.waitUntilDone(); | 25 .throw("IndexSizeError"); |
| 26 } else { |
| 27 should(tester, message) |
| 28 .notThrow(); |
| 29 } |
20 } | 30 } |
21 | 31 |
22 var doTest = function(fftSize, illegal) { | 32 audit.define("FFT size test", function (task, should) { |
23 var c = new OfflineAudioContext(1, 1000, 44100); | 33 task.describe("Test that re-sizing the FFT arrays does not fail."); |
24 var a = c.createAnalyser(); | 34 doTest(-1, true, should); |
25 try { | 35 doTest(0, true, should); |
26 a.fftSize = fftSize; | 36 doTest(1, true, should); |
27 if (illegal) | 37 for (let i = 2; i <= 0x20000; i *= 2) { |
28 testFailed("No exception thrown for illegal fftSize " + fftSize + "."
); | 38 if (i >= 32 && i <= 32768) |
29 else | 39 doTest(i, false, should); |
30 testPassed("Successfully set legal fftSize " + fftSize + "."); | 40 else |
31 } catch(e) { | 41 doTest(i, true, should); |
32 testPassed("Exception thrown for illegal fftSize " + fftSize + "."); | 42 doTest(i + 1, true, should); |
33 } | 43 } |
34 // This arbitrary size does not affect the correctness of the test. | |
35 var arr = new Float32Array(100); | |
36 a.getFloatFrequencyData(arr); | |
37 } | |
38 | 44 |
39 doTest(-1, true); | 45 task.done(); |
40 doTest(0, true); | 46 }); |
41 doTest(1, true); | |
42 for (var i = 2; i <= 0x20000; i *= 2) { | |
43 » if (i >= 32 && i <= 32768) | |
44 doTest(i, false); | |
45 else | |
46 doTest(i, true); | |
47 doTest(i + 1, true); | |
48 } | |
49 | 47 |
50 if (window.testRunner) | 48 audit.run(); |
51 testRunner.notifyDone(); | |
52 testPassed("AudioContext survived multiple invalid FFT array resizings."); | |
53 </script> | 49 </script> |
54 | 50 |
55 </body> | 51 </body> |
56 </html> | 52 </html> |
OLD | NEW |