mirror of
https://github.com/servo/servo.git
synced 2025-06-30 12:03:38 +01:00
78 lines
2.5 KiB
HTML
78 lines
2.5 KiB
HTML
<!doctype html>
|
|
<title>MediaStreamTrack GetSettings</title>
|
|
<p class="instructions">When prompted, accept to share your video stream.</p>
|
|
<script src=/resources/testharness.js></script>
|
|
<script src=/resources/testharnessreport.js></script>
|
|
<script>
|
|
'use strict'
|
|
|
|
// https://w3c.github.io/mediacapture-main/archives/20170605/getusermedia.html
|
|
|
|
promise_test(t => {
|
|
const constraints = {
|
|
video: true,
|
|
audio: false
|
|
};
|
|
|
|
return navigator.mediaDevices.getUserMedia(constraints)
|
|
.then(mediaStream => {
|
|
const settings1 = mediaStream.getVideoTracks()[0].getSettings();
|
|
const videoConstraints = {
|
|
deviceId: settings1.deviceId
|
|
};
|
|
|
|
return navigator.mediaDevices.getUserMedia({
|
|
video: videoConstraints,
|
|
audio: false
|
|
}).then(mediaStream => {
|
|
const settings2 = mediaStream.getVideoTracks()[0].getSettings();
|
|
assert_equals(settings1.deviceId, settings2.deviceId);
|
|
});
|
|
});
|
|
}, 'A device can be opened twice and have the same device ID');
|
|
|
|
promise_test(t => {
|
|
const constraints = {
|
|
video: true,
|
|
audio: false
|
|
};
|
|
|
|
return navigator.mediaDevices.getUserMedia(constraints)
|
|
.then(mediaStream => {
|
|
const settings1 = mediaStream.getVideoTracks()[0].getSettings();
|
|
const videoConstraints = {
|
|
deviceId: settings1.deviceId,
|
|
width: {
|
|
exact: settings1.width / 2
|
|
}
|
|
};
|
|
|
|
return navigator.mediaDevices.getUserMedia({
|
|
video: videoConstraints,
|
|
audio: false
|
|
}).then(mediaStream => {
|
|
const settings2 = mediaStream.getVideoTracks()[0].getSettings();
|
|
assert_equals(settings1.deviceId, settings2.deviceId);
|
|
assert_equals(settings1.width / 2, settings2.width);
|
|
});
|
|
});
|
|
}, 'A device can be opened twice with different resolutions');
|
|
|
|
promise_test(t => {
|
|
return navigator.mediaDevices.enumerateDevices().then(async devices => {
|
|
for (var device of devices) {
|
|
if (device.kind == "audiooutput")
|
|
continue;
|
|
var device_id_constraint = {deviceId: {exact: device.deviceId}};
|
|
var constraints = device.kind == "audioinput"
|
|
? {audio: device_id_constraint}
|
|
: {video: device_id_constraint};
|
|
|
|
var stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
assert_equals(stream.getTracks()[0].getSettings().groupId,
|
|
device.groupId);
|
|
assert_true(device.groupId.length > 0);
|
|
}
|
|
});
|
|
}, 'groupId is correctly reported by getSettings() for all devices');
|
|
</script>
|