-
Notifications
You must be signed in to change notification settings - Fork 3k
/
MediaStreamTrack-applyConstraints.https.html
57 lines (53 loc) · 2.24 KB
/
MediaStreamTrack-applyConstraints.https.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!doctype html>
<title>MediaStreamTrack applyConstraints</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/#dom-mediastreamtrack-applyconstraints
promise_test(t => {
return navigator.mediaDevices.getUserMedia({ video: true })
.then(t.step_func(stream => {
return stream.getVideoTracks()[0].applyConstraints(
{ groupId: { exact: "INVALID" } }).then(
t.unreached_func('Accepted invalid groupID'),
t.step_func(e => {
assert_equals(e.name, 'OverconstrainedError');
assert_equals(e.constraint, 'groupId');
}));
}));
}, 'applyConstraints rejects invalid groupID');
promise_test(t => {
return navigator.mediaDevices.getUserMedia({ video: true })
.then(t.step_func(stream => {
var track = stream.getVideoTracks()[0];
var groupId = track.getSettings().groupId;
return track.applyConstraints({ groupId: "INVALID" }).then(
t.step_func(() => {
assert_equals(track.getSettings().groupId, groupId);
}));
}));
}, 'applyConstraints accepts invalid ideal groupID, does not change setting');
promise_test(t => {
return navigator.mediaDevices.getUserMedia({ video: true })
.then(t.step_func(stream => {
var track = stream.getVideoTracks()[0];
var groupId = track.getSettings().groupId;
return navigator.mediaDevices.enumerateDevices().then(devices => {
var anotherDevice = devices.find(device => {
return device.kind == "videoinput" && device.groupId != groupId;
});
if (anotherDevice !== undefined) {
return track.applyConstraints(
{ groupId: { exact: anotherDevice.groupId } }).then(
t.unreached_func(),
t.step_func(e => {
assert_equals(e.name, 'OverconstrainedError');
assert_equals(e.constraint, 'groupId');
}));
}
});
}));
}, 'applyConstraints rejects attempt to switch device using groupId');
</script>