summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/tests/mochitests/test_getUserMedia_peerIdentity.html
blob: c4dfb9acb8e39993f12b1f792c3f3df2cedd9385 (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
<!DOCTYPE HTML>
<html>
<head>
  <script type="application/javascript" src="mediaStreamPlayback.js"></script>
  <script type="application/javascript" src="blacksilence.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
  title: "Test getUserMedia peerIdentity Constraint",
  bug: "942367"
});
async function theTest() {
  async function testPeerIdentityConstraint(withConstraint) {
    const config = { audio: true, video: true };
    if (withConstraint) {
      config.peerIdentity = 'user@example.com';
    }
    info('getting media with constraints: ' + JSON.stringify(config));
    const stream = await getUserMedia(config);
    for (const track of stream.getTracks()) {
      const recorder = new MediaRecorder(new MediaStream([track]));
      try {
        recorder.start();
        ok(!withConstraint,
          `gUM ${track.kind} track without peerIdentity must not throw`);
        recorder.stop();
      } catch(e) {
        ok(withConstraint,
          `gUM ${track.kind} track with peerIdentity must throw`);
      }
    }
    await Promise.all([
      audioIsSilence(withConstraint, stream),
      videoIsBlack(withConstraint, stream),
    ]);
    stream.getTracks().forEach(t => t.stop());
  };

  // both without and with the constraint
  await testPeerIdentityConstraint(false);
  await testPeerIdentityConstraint(true);
}

runTest(theTest);

</script>
</pre>
</body>
</html>