| <!DOCTYPE html> |
| |
| <html> |
| <head> |
| <script src="../resources/js-test.js"></script> |
| <script src="resources/audio-testing.js"></script> |
| </head> |
| |
| <body> |
| <div id="description"></div> |
| <div id="console"></div> |
| |
| <script> |
| description("Test that re-sizing the FFT arrays does not fail."); |
| |
| jsTestIsAsync = true; |
| |
| var doTest = function(fftSize, illegal) { |
| var c = new webkitOfflineAudioContext(1, 1000, 44100); |
| var a = c.createAnalyser(); |
| try { |
| a.fftSize = fftSize; |
| if (illegal) |
| testFailed("No exception thrown for illegal fftSize " + fftSize + "."); |
| else |
| testPassed("Successfully set legal fftSize " + fftSize + "."); |
| } catch(e) { |
| testPassed("Exception thrown for illegal fftSize " + fftSize + "."); |
| } |
| // This arbitrary size does not affect the correctness of the test. |
| var arr = new Float32Array(100); |
| a.getFloatFrequencyData(arr); |
| } |
| |
| doTest(-1, true); |
| doTest(0, true); |
| doTest(1, true); |
| for (var i = 2; i <= 0x20000; i *= 2) { |
| if (i >= 32 && i <= 32768) |
| doTest(i, false); |
| else |
| doTest(i, true); |
| doTest(i + 1, true); |
| } |
| |
| testPassed("webkitAudioContext survived multiple invalid FFT array resizings."); |
| finishJSTest(); |
| </script> |
| </body> |
| </html> |