blob: 1962a10962c6c9228810c85c30934b7f5491f9a1 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Tests getUserMedia.");
function setUserMediaPermission(isGranted) {
if (window.testRunner)
testRunner.setUserMediaPermission(isGranted);
else
debug("This test can not be run without the testRunner");
}
var stream;
var errorArg;
function error() {
testFailed('Error callback called.');
finishJSTest();
}
function expectedError() {
testPassed('Error callback called.');
}
function gotStreamInError(s) {
testFailed('Stream generated.');
finishJSTest();
}
function gotStream5(s) {
stream = s;
testPassed('Stream generated.');
shouldBe('stream.getAudioTracks().length', '1');
shouldBe('stream.getVideoTracks().length', '1');
finishJSTest();
}
function error1(e) {
errorArg = e;
testPassed('Error callback called.');
shouldBeEqualToString('errorArg.name', 'OverconstrainedError');
shouldBeEqualToString('errorArg.message', 'Invalid constraint');
shouldThrow("navigator.getUserMedia({audio:{volume:{exact:1}}, video:true}, gotStream5, 0);");
shouldNotThrow("navigator.getUserMedia({audio:{volume:{exact:1}}, video:true}, gotStream5, error);");
}
function gotStream4(s) {
stream = s;
testPassed('Stream generated.');
shouldBe('stream.getAudioTracks().length', '1');
shouldBe('stream.getVideoTracks().length', '1');
shouldThrow("navigator.getUserMedia({audio:true, video:{width:{exact:11}}}, gotStreamInError, null);");
shouldNotThrow("navigator.getUserMedia({audio:true, video:{width:{exact:11}}}, gotStreamInError, error1);");
}
function gotStream3(s) {
stream = s;
testPassed('Stream generated.');
shouldBe('stream.getAudioTracks().length', '1');
shouldBe('stream.getVideoTracks().length', '1');
shouldThrow("navigator.getUserMedia({audio:{}, video:true}, gotStream4, null);");
shouldNotThrow("navigator.getUserMedia({audio:{}, video:true}, gotStream4, error);");
}
function gotStream2(s) {
stream = s;
testPassed('Stream generated.');
shouldBe('stream.getAudioTracks().length', '0');
shouldBe('stream.getVideoTracks().length', '1');
shouldThrow("navigator.getUserMedia({audio:true, video:true}, gotStream3, null);");
shouldNotThrow("navigator.getUserMedia({audio:true, video:true}, gotStream3, error);");
}
function gotStream1(s) {
stream = s;
testPassed('Stream generated.');
shouldBe('stream.getAudioTracks().length', '1');
shouldBe('stream.getVideoTracks().length', '0');
shouldThrow("navigator.getUserMedia({video:true}, gotStream2, null);")
shouldNotThrow("navigator.getUserMedia({video:true}, gotStream2, error);")
}
shouldNotThrow("navigator.getUserMedia({audio:false, video:false}, error, expectedError);")
shouldThrow("navigator.getUserMedia({audio:false, video:false}, error, null);")
setUserMediaPermission(true);
shouldNotThrow("navigator.getUserMedia({audio:true}, gotStream1, error);");
window.jsTestIsAsync = true;
window.successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>