author | Paul Adenot <paul@paul.cx> |
Wed, 22 Oct 2014 11:00:00 +0200 | |
changeset 215809 | ceed59c2891035d48b8a4dda718f475ed404f059 |
parent 215808 | 6ead619835d3dde11247afb2ce4e57143afd9a77 |
child 215810 | 854091113b03518d90d8ec06b35634bdcfd0ec25 |
push id | 27827 |
push user | ryanvm@gmail.com |
push date | Fri, 14 Nov 2014 22:48:07 +0000 |
treeherder | mozilla-central@acbd7b68fa8c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | ehsan |
bugs | 1000264 |
milestone | 36.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
|
dom/media/webaudio/test/mochitest.ini | file | annotate | diff | comparison | revisions | |
dom/media/webaudio/test/test_decodeAudioDataPromise.html | file | annotate | diff | comparison | revisions |
--- a/dom/media/webaudio/test/mochitest.ini +++ b/dom/media/webaudio/test/mochitest.ini @@ -82,16 +82,17 @@ skip-if = toolkit == 'android' # bug 105 [test_channelSplitterNodeWithVolume.html] [test_convolverNode.html] [test_convolverNode_mono_mono.html] [test_convolverNodeChannelCount.html] [test_convolverNodePassThrough.html] [test_convolverNodeWithGain.html] [test_currentTime.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_decodeAudioDataPromise.html @@ -0,0 +1,61 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test the decodeAudioData API with Promise</title> + + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> + <script src="webaudio.js"></script> +</head> +<body> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +SimpleTest.waitForExplicitFinish(); +addLoadEvent(function() { + +var finished = 0; + +function finish() { + if (++finished == 2) { + SimpleTest.finish(); + } +} + +var ac = new AudioContext(); +// Test that a the promise is rejected with an invalid source buffer. +expectNoException(function() { + var p = ac.decodeAudioData(" "); + ok(p instanceof Promise, "AudioContext.decodeAudioData should return a Promise"); + p.then(function(data) { + ok(false, "Promise should not resolve with an invalid source buffer."); + finish(); + }).catch(function() { + ok(true, "Promise should be rejected with an invalid source buffer."); + finish(); + }) +}); + +// Test that a the promise is resolved with a valid source buffer. +var xhr = new XMLHttpRequest(); +xhr.open("GET", "ting-44.1k-1ch.ogg", true); +xhr.responseType = "arraybuffer"; +xhr.onload = function() { + var p = ac.decodeAudioData(xhr.response); + ok(p instanceof Promise, "AudioContext.decodeAudioData should return a Promise"); + p.then(function(data) { + ok(data instanceof AudioBuffer, "Promise should resolve, passing an AudioBuffer"); + ok(true, "Promise should resolve with a valid source buffer."); + finish(); + }).catch(function() { + ok(false, "Promise should not be rejected with a valid source buffer."); + finish(); + }); +}; +xhr.send(); +}); + +</script> +</pre> +</body> +</html>