mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
132 lines
5.0 KiB
HTML
132 lines
5.0 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: "SecurityError" },
|
|
{ message: "application screensharing requires permission",
|
|
constraints: { video: { mediaSource: 'application' } },
|
|
error: "SecurityError" },
|
|
{ message: "window screensharing requires permission",
|
|
constraints: { video: { mediaSource: 'window' } },
|
|
error: "SecurityError" },
|
|
{ message: "browser screensharing requires permission",
|
|
constraints: { video: { mediaSource: 'browser' } },
|
|
error: "SecurityError" },
|
|
{ message: "unknown mediaSource in video fails",
|
|
constraints: { video: { mediaSource: 'uncle' } },
|
|
error: "OverconstrainedError",
|
|
constraint: "mediaSource" },
|
|
{ message: "unknown mediaSource in audio fails",
|
|
constraints: { audio: { mediaSource: 'uncle' } },
|
|
error: "OverconstrainedError",
|
|
constraint: "mediaSource" },
|
|
{ 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 },
|
|
];
|
|
|
|
var mustSupport = [
|
|
'width', 'height', 'frameRate', 'facingMode', 'deviceId',
|
|
// Yet to add:
|
|
// 'aspectRatio', 'frameRate', 'volume', 'sampleRate', 'sampleSize',
|
|
// 'echoCancellation', 'latency', 'groupId'
|
|
|
|
// http://fluffy.github.io/w3c-screen-share/#screen-based-video-constraints
|
|
// OBE by http://w3c.github.io/mediacapture-screen-share
|
|
'mediaSource',
|
|
|
|
// Experimental https://bugzilla.mozilla.org/show_bug.cgi?id=1131568#c3
|
|
'browserWindow', 'scrollWithPage',
|
|
];
|
|
|
|
/**
|
|
* Starts the test run by running through each constraint
|
|
* test by verifying that the right resolution and rejection is fired.
|
|
*/
|
|
|
|
runTest(function() {
|
|
|
|
// Check supported constraints first.
|
|
var dict = navigator.mediaDevices.getSupportedConstraints();
|
|
var supported = Object.keys(dict);
|
|
|
|
mustSupport.forEach(key => ok(supported.indexOf(key) != -1 && dict[key],
|
|
"Supports " + key));
|
|
|
|
var unexpected = supported.filter(key => mustSupport.indexOf(key) == -1);
|
|
is(unexpected.length, 0,
|
|
"Unanticipated support (please update test): " + unexpected);
|
|
|
|
// Run constraint tests
|
|
|
|
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);
|
|
if (test.constraint) {
|
|
is(e.constraint, test.constraint,
|
|
test.message + " w/correct constraint.");
|
|
}
|
|
}), p)
|
|
.then(() => navigator.mediaDevices.getUserMedia({video: true, audio: true}))
|
|
.then(stream => stream.getVideoTracks()[0].applyConstraints({ width: 320 })
|
|
.then(() => stream.getAudioTracks()[0].applyConstraints({ })))
|
|
.then(() => ok(true, "applyConstraints code exercised"))
|
|
// TODO: Test outcome once fake devices support constraints (Bug 1088621)
|
|
});
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|