Bug 1308434 - Add testcase for calling DecodeAudioData on detached buffer. r=padenot,dminor
authorBeekill95 <nnn_bikiu0707@yahoo.com>
Thu, 26 Jan 2017 13:45:51 +0700
changeset 360460 75ec51fdcd4e5a6a87f50476e69ed6aeaf30b432
parent 360459 1176bc6973a950abb17e5cd8cfaa3236390f050f
child 360461 f6379ae84275e13b70789c0fc9da853c50751aca
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot, dminor
bugs1308434
milestone54.0a1
Bug 1308434 - Add testcase for calling DecodeAudioData on detached buffer. r=padenot,dminor MozReview-Commit-ID: 25zz7RfVHxO
dom/media/webaudio/test/mochitest.ini
dom/media/webaudio/test/test_decodeAudioDataOnDetachedBuffer.html
--- a/dom/media/webaudio/test/mochitest.ini
+++ b/dom/media/webaudio/test/mochitest.ini
@@ -105,18 +105,19 @@ skip-if = (android_version == '18' && de
 [test_convolverNode.html]
 [test_convolverNode_mono_mono.html]
 [test_convolverNodeChannelCount.html]
 [test_convolverNodeDelay.html]
 [test_convolverNodeFiniteInfluence.html]
 [test_convolverNodePassThrough.html]
 [test_convolverNodeWithGain.html]
 [test_currentTime.html]
+[test_decodeAudioDataOnDetachedBuffer.html]
+[test_decodeAudioDataPromise.html]
 [test_decodeMultichannel.html]
-[test_decodeAudioDataPromise.html]
 [test_delayNode.html]
 [test_delayNodeAtMax.html]
 [test_delayNodeChannelChanges.html]
 skip-if = toolkit == 'android' # bug 1056706
 [test_delayNodeCycles.html]
 [test_delayNodePassThrough.html]
 [test_delayNodeSmallMaxDelay.html]
 [test_delayNodeTailIncrease.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/test_decodeAudioDataOnDetachedBuffer.html
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML>
+<html>
+  <meta charset=utf-8>
+<head>
+  <title>Bug 1308434 - Test DecodeAudioData on detached buffer</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 type="text/javascript">
+var testDecodeAudioDataOnDetachedBuffer = function(buffer) {
+  var context = new AudioContext();
+
+  // make the buffer detached
+  context.decodeAudioData(buffer);
+
+  // check that the buffer is detached
+  is(buffer.byteLength, 0, "Buffer should be detached");
+
+  // call decodeAudioData on detached buffer
+  context.decodeAudioData(buffer).then(function(b) {
+    ok(false, "We should not be able to decode the detached buffer but we do");
+    SimpleTest.finish();
+  }, function(r) {
+    SimpleTest.isa(r, TypeError);
+    is(r.message, "Argument of AudioContext.decodeAudioData can't be a detached buffer", "Incorrect message");
+    SimpleTest.finish();
+  });
+};
+
+var filename = "small-shot.mp3";
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+  var xhr = new XMLHttpRequest();
+  xhr.open("GET", filename);
+  xhr.responseType = "arraybuffer";
+
+  xhr.onload = function() {
+    testDecodeAudioDataOnDetachedBuffer(xhr.response);
+  };
+
+  xhr.send();
+});
+</script>
+</pre>
+</body>
+</html>
\ No newline at end of file