audiopannernode-basic.html should cover default value of attribute.
[WebKit-https.git] / LayoutTests / webaudio / decode-audio-data-basic.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../fast/js/resources/js-test-pre.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 if (window.testRunner) {
12     testRunner.dumpAsText();
13     testRunner.waitUntilDone();
14 }
15     
16 window.jsTestIsAsync = true;
17
18 var context = new webkitAudioContext();
19
20 try {
21     context.decodeAudioData(null, function(){}, function(){});
22     testFailed("decodeAudioData should raise exception when arraybuffer parameter is null.");
23 } catch(e) {
24     testPassed("decodeAudioData raises exception correctly when arraybuffer parameter is null.");
25 }
26
27 var decodeCaseArray = [{url: "resources/media/24bit-44khz.wav", result: true},
28                        {url: "resources/media/invalid-audio-file.txt", result: false}];
29
30 function runDecodeTest(index) {
31     if (index >= decodeCaseArray.length) {
32         finishJSTest();
33         return;
34     }
35
36     var request = new XMLHttpRequest();
37     request.open("GET", decodeCaseArray[index].url, true);
38     request.responseType = "arraybuffer";
39     
40     request.onload = function() {
41         context.decodeAudioData(request.response, successCallback, errorCallback);
42         
43         function successCallback() {
44             if (decodeCaseArray[index].result)
45                 testPassed("The " + decodeCaseArray[index].url +  " test: successCallback has been called correctly.");
46             else
47                 testFailed("The " + decodeCaseArray[index].url + " test: successCallback was not called.");
48             
49             runDecodeTest(++index);
50         }
51         
52         function errorCallback() {
53             if (decodeCaseArray[index].result)
54                 testFailed("The " + decodeCaseArray[index].url + " test: errorCallback was called incorrectly.");
55             else
56                 testPassed("The " + decodeCaseArray[index].url + " test: errorCallback has been called correctly.");
57
58             runDecodeTest(++index);
59         }
60     }
61     request.send();
62 }
63
64 runDecodeTest(0);
65
66 </script>
67 <script src="../fast/js/resources/js-test-post.js"></script>
68 </body>
69 </html>