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