Bug 859597 - Narrow down the acceptable range for AnalyserNode.fftSize; r=padenot
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 08 Apr 2013 21:26:08 -0400
changeset 128141 28c45607546a5c7a25f5ab56eed433388f793642
parent 128140 5133c67c0473f8af5512c0230cd3ce5028f9b38d
child 128142 51ea6740443031194295c0ef1680f47be760475c
push id26164
push usereakhgari@mozilla.com
push dateTue, 09 Apr 2013 12:22:52 +0000
treeherdermozilla-inbound@28c45607546a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs859597
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 859597 - Narrow down the acceptable range for AnalyserNode.fftSize; r=padenot
content/media/webaudio/AnalyserNode.cpp
content/media/webaudio/test/test_analyserNode.html
--- a/content/media/webaudio/AnalyserNode.cpp
+++ b/content/media/webaudio/AnalyserNode.cpp
@@ -95,18 +95,19 @@ JSObject*
 AnalyserNode::WrapObject(JSContext* aCx, JSObject* aScope)
 {
   return AnalyserNodeBinding::Wrap(aCx, aScope, this);
 }
 
 void
 AnalyserNode::SetFftSize(uint32_t aValue, ErrorResult& aRv)
 {
-  // Disallow values that are either less than 2 or not a power of 2
-  if (aValue < 2 ||
+  // Disallow values that are not a power of 2 and outside the [32,2048] range
+  if (aValue < 32 ||
+      aValue > 2048 ||
       (aValue & (aValue - 1)) != 0) {
     aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
     return;
   }
   if (mFFTSize != aValue) {
     mFFTSize = aValue;
     AllocateBuffer();
   }
--- a/content/media/webaudio/test/test_analyserNode.html
+++ b/content/media/webaudio/test/test_analyserNode.html
@@ -35,18 +35,27 @@ addLoadEvent(function() {
   is(analyser.frequencyBinCount, 1024, "Correct default value for frequencyBinCount");
   expectException(function() {
     analyser.fftSize = 0;
   }, DOMException.INDEX_SIZE_ERR);
   expectException(function() {
     analyser.fftSize = 1;
   }, DOMException.INDEX_SIZE_ERR);
   expectException(function() {
+    analyser.fftSize = 8;
+  }, DOMException.INDEX_SIZE_ERR);
+  expectException(function() {
     analyser.fftSize = 100; // non-power of two
   }, DOMException.INDEX_SIZE_ERR);
+  expectException(function() {
+    analyser.fftSize = 2049;
+  }, DOMException.INDEX_SIZE_ERR);
+  expectException(function() {
+    analyser.fftSize = 4096;
+  }, DOMException.INDEX_SIZE_ERR);
   analyser.fftSize = 1024;
   is(analyser.frequencyBinCount, 512, "Correct new value for frequencyBinCount");
 
   is(analyser.minDecibels, -100, "Correct default value for minDecibels");
   is(analyser.maxDecibels, -30, "Correct default value for maxDecibels");
   expectException(function() {
     analyser.minDecibels = -30;
   }, DOMException.INDEX_SIZE_ERR);