blob: bdcf3e0325a5b75c28999ab9b68aa614eeba9353 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<script>
description("Tests the acceptable types for arguments to navigator.getUserMedia methods.");
window.jsTestIsAsync = true;
// Pending callbacks may cause the leak detector run at the end of the test to
// find leaked blink nodes. Therefore, we must wait for all callbacks to arrive
// before finishing the test run.
var remainingExpectedCallbackCount = 3;
var callbackFunction = function() {
remainingExpectedCallbackCount--;
if (remainingExpectedCallbackCount == 0) {
finishJSTest();
}
};
var emptyFunction = function() {};
// No arguments
shouldThrow('navigator.webkitGetUserMedia()');
// 1/2 arguments (getUserMedia requires at least 3 arguments).
shouldThrow('navigator.webkitGetUserMedia({video: true})');
shouldThrow('navigator.webkitGetUserMedia({video: true}, emptyFunction)');
// 3 arguments (getUserMedia requires at least 3 arguments).
shouldNotThrow('navigator.webkitGetUserMedia({video: true}, callbackFunction, callbackFunction)');
shouldNotThrow('navigator.webkitGetUserMedia({audio: true}, callbackFunction, callbackFunction)');
shouldNotThrow('navigator.webkitGetUserMedia({audio: true, video: true}, callbackFunction, callbackFunction)');
shouldThrow('navigator.webkitGetUserMedia(-Infinity, emptyFunction, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia(42, emptyFunction, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia(Infinity, emptyFunction, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia(emptyFunction, emptyFunction, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia(null, emptyFunction, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia(true, emptyFunction, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia(undefined, emptyFunction, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia({ }, emptyFunction, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia({foo: true }, emptyFunction, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia({audio:true, video:true}, emptyFunction, undefined)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, "foobar", emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, -Infinity, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, 42, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, Infinity, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, emptyFunction, "video")');
shouldThrow('navigator.webkitGetUserMedia({video: true}, emptyFunction, -Infinity)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, emptyFunction, 42)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, emptyFunction, Infinity)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, emptyFunction, null)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, emptyFunction, true)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, emptyFunction, undefined)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, emptyFunction, {})');
shouldThrow('navigator.webkitGetUserMedia({video: true}, null, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, true, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, undefined, emptyFunction)');
shouldThrow('navigator.webkitGetUserMedia({video: true}, {}, emptyFunction)');
</script>
</body>
</html>