summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/mediacapture-streams/GUM-non-applicable-constraint.https.html
blob: e9fd6665dcface83218869a0a0fd1284c12f924f (plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!doctype html>
<title>non-applicable constraint in getUserMedia</title>
<link rel="author" title="Intel" href="http://www.intel.com"/>
<link rel="help" href="https://w3c.github.io/mediacapture-main/#methods-5">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
  <script src=/resources/testdriver.js></script>
<script src=/resources/testdriver-vendor.js></script>
<script src=permission-helper.js></script>

<p class="instructions">When prompted, accept to share your audio and video stream.</p>

<script>

let video_only_valid_constraints = {
  width: {min: 0},
  height: {min: 0},
  frameRate: {min: 0},
  aspectRatio: {min: 0},
  facingMode: {ideal: 'environment'},
  resizeMode: {ideal: 'none'}
}

let video_only_invalid_constraints = {
  width: {min: 100000000},
  height: {min: 100000000},
  frameRate: {min: 100000000},
  aspectRatio: {min: 100000000},
  facingMode: {exact: 'invalid'},
  resizeMode: {exact: 'invalid'}
}

let audio_only_valid_constraints = {
  volume: {min: 0},
  sampleRate: {min: 0},
  sampleSize: {min: 0},
  echoCancellation: {ideal: true},
  autoGainControl: {ideal: true},
  noiseSuppression: {ideal: true},
  voiceIsolation: {ideal: true},
  latency: {min: 0},
  channelCount: {min: 0}
}

let audio_only_invalid_constraints = {
  volume: {min: 2},
  sampleRate: {min: 100000000},
  sampleSize: {min: 100000000},
  echoCancellation: {exact: true},
  autoGainControl: {exact: true},
  noiseSuppression: {exact: true},
  voiceIsolation: {exact: true},
  latency: {max: 0},
  channelCount: {max: 0}
}

promise_test(async () => {
  // Both permissions are needed at some point, asking for both at once
  await setMediaPermission();
  let stream = await navigator.mediaDevices.getUserMedia({audio: video_only_valid_constraints})
  assert_equals(stream.getAudioTracks().length, 1, "the media stream has exactly one audio track");
}, 'Test that setting video-only valid constraints inside of "audio" is simply ignored');

promise_test(async () => {
  let stream = await navigator.mediaDevices.getUserMedia({audio: video_only_invalid_constraints})
  assert_equals(stream.getAudioTracks().length, 1, "the media stream has exactly one audio track");
}, 'Test that setting video-only invalid constraints inside of "audio" is simply ignored');

promise_test(async () => {
  let stream = await navigator.mediaDevices.getUserMedia({video: audio_only_valid_constraints})
  assert_equals(stream.getVideoTracks().length, 1, "the media stream has exactly one video track");
}, 'Test that setting audio-only valid constraints inside of "video" is simply ignored');

promise_test(async () => {
  let stream = await navigator.mediaDevices.getUserMedia({video: audio_only_invalid_constraints})
  assert_equals(stream.getVideoTracks().length, 1, "the media stream has exactly one video track");
}, 'Test that setting audio-only invalid constraints inside of "video" is simply ignored');

</script>