Bug 1308437 - Part 2: Add test case to verify TypeError is thrown when calling setValueCurve on non-finite elements. r=dminor r=padenot
authorBeekill95 <nnn_bikiu0707@yahoo.com>
Mon, 06 Feb 2017 22:18:04 +0700
changeset 341351 845451c03a199550c060f4b1866d35da58f97093
parent 341350 59f634bb78c4904e9ad0072e47b2aa9355638712
child 341352 9066a2ed849311d798300629edac248e81978af5
push id86694
push usercbook@mozilla.com
push dateWed, 08 Feb 2017 14:56:12 +0000
treeherdermozilla-inbound@250c680482eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdminor, padenot
bugs1308437
milestone54.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 1308437 - Part 2: Add test case to verify TypeError is thrown when calling setValueCurve on non-finite elements. r=dminor r=padenot
dom/media/webaudio/test/mochitest.ini
dom/media/webaudio/test/test_setValueCurveWithNonFiniteElements.html
--- a/dom/media/webaudio/test/mochitest.ini
+++ b/dom/media/webaudio/test/mochitest.ini
@@ -184,16 +184,17 @@ skip-if = (toolkit == 'android') || (os 
 [test_pannerNode.html]
 [test_pannerNode_equalPower.html]
 [test_pannerNodeAbove.html]
 [test_pannerNodeAtZeroDistance.html]
 [test_pannerNodeChannelCount.html]
 [test_pannerNodeHRTFSymmetry.html]
 [test_pannerNodeTail.html]
 [test_pannerNode_maxDistance.html]
+[test_setValueCurveWithNonFiniteElements.html]
 [test_stereoPannerNode.html]
 [test_stereoPannerNodePassThrough.html]
 [test_periodicWave.html]
 [test_periodicWaveDisableNormalization.html]
 [test_periodicWaveBandLimiting.html]
 [test_ScriptProcessorCollected1.html]
 [test_scriptProcessorNode.html]
 [test_scriptProcessorNodeChannelCount.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/test_setValueCurveWithNonFiniteElements.html
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML>
+<html>
+<meta charset=utf-8>
+<head>
+  <title>Bug 1308437 - setValueCurve should throw on non-finite elements</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+SimpleTest.waitForExplicitFinish();
+
+function testInfiniteElement(audioContext, audioParam) {
+  // create value curve with infinite element
+  var arr = new Float32Array(5);
+  arr[0] = 0.5;
+  arr[1] = 1;
+  arr[2] = Infinity;
+  arr[3] = 1;
+  arr[4] = 0.5;
+
+  try {
+    audioParam.setValueCurveAtTime(arr, audioContext.currentTime(), 2);
+    ok(false, "We shouldn't be able to call setValueCurve with Infinity but we can");
+  } catch(e) {
+    ok(e instanceof TypeError, "TypeError is thrown");
+  }
+};
+
+function testNanElement(audioContext, audioParam) {
+  // create value curve with infinite element
+  var arr = new Float32Array(5);
+  arr[0] = 0.5;
+  arr[1] = 1;
+  arr[2] = NaN;
+  arr[3] = 1;
+  arr[4] = 0.5;
+
+  try {
+    audioParam.setValueCurveAtTime(arr, audioContext.currentTime(), 2);
+    ok(false, "We shouldn't be able to call setValueCurve with NaN but we can");
+  } catch(e) {
+    ok(e instanceof TypeError, "TypeError is thrown");
+  }
+};
+
+addLoadEvent(function() {
+  var audioContext = new AudioContext();
+  var gainNode = audioContext.createGain();
+
+  testInfiniteElement(audioContext, gainNode.gain);
+  testNanElement(audioContext, gainNode.gain);
+
+  SimpleTest.finish();
+});
+</script>
+</pre>
+</body>
+</html>
\ No newline at end of file