Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!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>