content/media/webaudio/test/test_decodeMultichannel.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <meta charset=utf-8>
     4 <head>
     5   <title>Test that we can decode 4 channel wave file in webaudio, but not in &lt;audio&gt;</title>
     6   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     7   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     8 </head>
     9 <body>
    10 <pre id="test">
    11 <script class="testbody" type="text/javascript">
    12 var filename = "audio-quad.wav";
    14 SimpleTest.waitForExplicitFinish();
    16 function finishTest(a) {
    17   if (a) {
    18     a = null;
    19     SimpleTest.finish();
    20   }
    21 }
    23 function decodeUsingAudioElement() {
    24   var a = new Audio();
    25   a.addEventListener("error", function() {
    26     ok(true, "We should not be able to decode this file using an HTMLAudioElement");
    27     finishTest(a);
    28   });
    29   a.addEventListener("loadedmetadata", function() {
    30     ok(false, "We should not be able to decode this file using an HTMLMediaElement.");
    31     finishTest(a);
    32   });
    34   a.src = filename;
    35   a.load();
    36 }
    38 addLoadEvent(function() {
    39   var xhr = new XMLHttpRequest();
    40   xhr.open("GET", filename);
    41   xhr.responseType = "arraybuffer";
    42   xhr.onload = function() {
    43     var context = new AudioContext();
    44     context.decodeAudioData(xhr.response, function(b) {
    45       ok(true, "Decoding of a wave file with four channels succeded.");
    46       is(b.numberOfChannels, 4, "The AudioBuffer should have 4 channels.");
    47       decodeUsingAudioElement();
    48     }, function() {
    49       ok(false, "Decoding of a wave file with four channels failed.");
    50       decodeUsingAudioElement();
    51     });
    52   };
    53   xhr.send(null);
    54 });
    55 </script>
    56 </pre>
    57 </body>
    58 </html>

mercurial