Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / webaudio / decode-audio-data-basic.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 <script type="text/javascript" src="resources/audio-testing.js"></script>
6 </head>
7 <body>
8 <script>
9 description("Basic tests for decodeAudioData function.");
10     
11 window.jsTestIsAsync = true;
12
13 var context = new webkitAudioContext();
14
15 // decodeAudioData should raise exception when arraybuffer parameter is null.
16 shouldThrow("context.decodeAudioData(null, function(){}, function(){});", "'TypeError: Argument 1 (\\'audioData\\') to webkitAudioContext.decodeAudioData must be an instance of ArrayBuffer'");
17
18 var decodeCaseArray = [{url: "resources/media/24bit-44khz.wav", result: true},
19                        {url: "resources/media/invalid-audio-file.txt", result: false}];
20
21 function runDecodeTest(index) {
22     if (index >= decodeCaseArray.length) {
23         finishJSTest();
24         return;
25     }
26
27     var request = new XMLHttpRequest();
28     request.open("GET", decodeCaseArray[index].url, true);
29     request.responseType = "arraybuffer";
30     
31     request.onload = function() {
32         context.decodeAudioData(request.response, successCallback, errorCallback);
33         
34         function successCallback() {
35             if (decodeCaseArray[index].result)
36                 testPassed("The " + decodeCaseArray[index].url +  " test: successCallback has been called correctly.");
37             else
38                 testFailed("The " + decodeCaseArray[index].url + " test: successCallback was not called.");
39             
40             runDecodeTest(++index);
41         }
42         
43         function errorCallback() {
44             if (decodeCaseArray[index].result)
45                 testFailed("The " + decodeCaseArray[index].url + " test: errorCallback was called incorrectly.");
46             else
47                 testPassed("The " + decodeCaseArray[index].url + " test: errorCallback has been called correctly.");
48
49             runDecodeTest(++index);
50         }
51     }
52     request.send();
53 }
54
55 runDecodeTest(0);
56
57 </script>
58 </body>
59 </html>