blob: 348033b1b42029584acf46085dcc8171ee623167 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script type="text/javascript" src="resources/audio-testing.js"></script>
</head>
<body>
<script>
description("Basic tests for decodeAudioData function.");
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
window.jsTestIsAsync = true;
var context = new webkitAudioContext();
try {
context.decodeAudioData(null, function(){}, function(){});
testFailed("decodeAudioData should raise exception when arraybuffer parameter is null.");
} catch(e) {
testPassed("decodeAudioData raises exception correctly when arraybuffer parameter is null.");
}
var decodeCaseArray = [{url: "resources/media/24bit-44khz.wav", result: true},
{url: "resources/media/invalid-audio-file.txt", result: false}];
function runDecodeTest(index) {
if (index >= decodeCaseArray.length) {
finishJSTest();
return;
}
var request = new XMLHttpRequest();
request.open("GET", decodeCaseArray[index].url, true);
request.responseType = "arraybuffer";
request.onload = function() {
context.decodeAudioData(request.response, successCallback, errorCallback);
function successCallback() {
if (decodeCaseArray[index].result)
testPassed("The " + decodeCaseArray[index].url + " test: successCallback has been called correctly.");
else
testFailed("The " + decodeCaseArray[index].url + " test: successCallback was not called.");
runDecodeTest(++index);
}
function errorCallback() {
if (decodeCaseArray[index].result)
testFailed("The " + decodeCaseArray[index].url + " test: errorCallback was called incorrectly.");
else
testPassed("The " + decodeCaseArray[index].url + " test: errorCallback has been called correctly.");
runDecodeTest(++index);
}
}
request.send();
}
runDecodeTest(0);
</script>
</body>
</html>
|