blob: c22f2c17029f152b5730e640187c0f366968789b [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/audio-testing.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Basic tests for MediaElementAudioSourceNode API.");
var context = 0;
function runTest() {
window.jsTestIsAsync = true;
context = new webkitAudioContext();
audioElement = new Audio();
mediaSource = context.createMediaElementSource(audioElement);
window.audioNode = mediaSource;
// Check number of inputs and outputs.
if (audioNode.numberOfInputs == 0)
testPassed("Source AudioNode has no inputs.");
else
testFailed("Source AudioNode should not have inputs.");
if (audioNode.numberOfOutputs == 1)
testPassed("Source AudioNode has one output.");
else
testFailed("Source AudioNode should have one output.");
// Try calling connect() method with illegal values.
try {
audioNode.connect(0, 0, 0);
testFailed("connect() exception should be thrown for illegal destination AudioNode.");
} catch(e) {
testPassed("connect() exception thrown for illegal destination AudioNode.");
}
try {
audioNode.connect(context.destination, 5, 0);
testFailed("connect() exception should be thrown for illegal output index.");
} catch(e) {
testPassed("connect() exception thrown for illegal output index.");
}
try {
audioNode.connect(context.destination, 0, 5);
testFailed("connect() exception should be thrown for illegal input index.");
} catch(e) {
testPassed("connect() exception thrown for illegal input index.");
}
// Try calling connect() with proper values.
try {
audioNode.connect(context.destination, 0, 0);
testPassed("audioNode.connect(context.destination) succeeded.");
} catch(e) {
testFailed("audioNode.connect(context.destination) failed.");
}
// Try creating another MediaElementAudioSourceNode using the same audio element.
try {
mediaSource = context.createMediaElementSource(audioElement);
testFailed("createMediaElementSource() should throw if called twice on same HTMLMediaElement.");
} catch(e) {
testPassed("createMediaElementSource() threw error when called twice on same HTMLMediaElement.");
}
shouldThrow("context.createMediaElementSource(null)", "'TypeError: Argument 1 (\\'mediaElement\\') to webkitAudioContext.createMediaElementSource must be an instance of HTMLMediaElement'");
finishJSTest();
}
runTest();
</script>
</body>
</html>