gecko-dev/dom/media/tests/mochitest/test_getUserMedia_constraints.html
Jan-Ivar Bruaroey d4bc9fa237 Bug 1173255 - Cleanup MediaManager e10s code in prep for deviceId constraint. r=jesup
--HG--
extra : amend_source : 057f17d55cd44a700abab5595c9f4fc95cfd2419
extra : transplant_source : %B7%5C%7D%FA%E9%3F%29%F9%EBM%9E%B5%1A%A6G%29%25%01%0E-
extra : histedit_source : a10d0d5106f5fffb3881604728c1933c90772622%2Cdf022706033cb19f87a8dd58376ab7800d9d2526
2015-06-18 11:46:36 -04:00

89 lines
3.4 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<script src="mediaStreamPlayback.js"></script>
<script src="constraints.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({ title: "Test getUserMedia constraints", bug: "882145" });
/**
Tests covering gUM constraints API for audio, video and fake video. Exercise
successful parsing code and ensure that unknown required constraints and
overconstraining cases produce appropriate errors.
*/
var tests = [
// Each test here tests a different constraint or codepath.
{ message: "unknown required constraint on video ignored",
constraints: { video: { somethingUnknown: { exact: 0 } },
fake: true },
error: null },
{ message: "unknown required constraint on audio ignored",
constraints: { audio: { somethingUnknown: { exact: 0 } },
fake: true },
error: null },
{ message: "audio overconstrained by facingMode ignored",
constraints: { audio: { facingMode: { exact: 'left' } },
fake: true },
error: null },
{ message: "full screensharing requires permission",
constraints: { video: { mediaSource: 'screen' } },
error: "PermissionDeniedError" },
{ message: "application screensharing requires permission",
constraints: { video: { mediaSource: 'application' } },
error: "PermissionDeniedError" },
{ message: "window screensharing requires permission",
constraints: { video: { mediaSource: 'window' } },
error: "PermissionDeniedError" },
{ message: "browser screensharing requires permission",
constraints: { video: { mediaSource: 'browser' } },
error: "PermissionDeniedError" },
{ message: "unknown mediaSource fails",
constraints: { video: { mediaSource: 'uncle' } },
error: "NotFoundError" },
{ message: "emtpy constraint fails",
constraints: { },
error: "NotSupportedError" },
{ message: "Success-path: optional video facingMode + audio ignoring facingMode",
constraints: { fake: true,
audio: { mediaSource: 'microphone',
facingMode: 'left',
foo: 0,
advanced: [{ facingMode: 'environment' },
{ facingMode: 'user' },
{ bar: 0 }] },
video: { mediaSource: 'camera',
foo: 0,
advanced: [{ facingMode: 'environment' },
{ facingMode: ['user'] },
{ facingMode: ['left', 'right', 'user'] },
{ bar: 0 }] } },
error: null },
{ message: "legacy facingMode ignored",
constraints: { video: { mandatory: { facingMode: 'left' } }, fake: true },
error: null },
];
/**
* Starts the test run by running through each constraint
* test by verifying that the right resolution and rejection is fired.
*/
runTest(function() {
var p = new Promise(resolve => SpecialPowers.pushPrefEnv({
set : [ ['media.getusermedia.browser.enabled', false],
['media.getusermedia.screensharing.enabled', false] ]
}, resolve));
return tests.reduce((p, test) =>
p.then(() => navigator.mediaDevices.getUserMedia(test.constraints))
.then(() => is(null, test.error, test.message),
e => is(e.name, test.error, test.message + ": " + e.message)), p);
});
</script>
</pre>
</body>
</html>