diff options
Diffstat (limited to 'dom/media/webrtc/tests/mochitests/test_getUserMedia_peerIdentity.html')
-rw-r--r-- | dom/media/webrtc/tests/mochitests/test_getUserMedia_peerIdentity.html | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_getUserMedia_peerIdentity.html b/dom/media/webrtc/tests/mochitests/test_getUserMedia_peerIdentity.html new file mode 100644 index 0000000000..2c964e2f89 --- /dev/null +++ b/dom/media/webrtc/tests/mochitests/test_getUserMedia_peerIdentity.html @@ -0,0 +1,61 @@ +<!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()); + }; + + // Start a tone so that the gUM call will record something even + // with --use-test-media-devices. + const audioContext = new AudioContext(); + const tone = new LoopbackTone(audioContext, TEST_AUDIO_FREQ); + tone.start(); + + try { + // both without and with the constraint + await testPeerIdentityConstraint(false); + await testPeerIdentityConstraint(true); + } finally { + tone.stop(); + } +} + +runTest(theTest); + +</script> +</pre> +</body> +</html> |