Bug 1212237 - Use MediaRecorder to test peerIdentity track isolation. r=jib

Differential Revision: https://phabricator.services.mozilla.com/D48945

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Pehrson 2019-11-06 05:11:08 +00:00
parent 8efadc1da8
commit 8fc4484f5a
2 changed files with 30 additions and 10 deletions

View File

@ -62,6 +62,13 @@ function identityPcTest(remoteOptions) {
function REMOTE_STREAMS_ARE_RESTRICTED(test) {
var remoteStream = test.pcLocal._pc.getRemoteStreams()[0];
for (const track of remoteStream.getTracks()) {
mustThrowWith(
`Freshly received ${track.kind} track with peerIdentity`,
"SecurityError",
() => new MediaRecorder(new MediaStream([track])).start()
);
}
return Promise.all([
audioIsSilence(true, remoteStream),
videoIsBlack(true, remoteStream),

View File

@ -11,23 +11,36 @@ createHTML({
title: "Test getUserMedia peerIdentity Constraint",
bug: "942367"
});
function theTest() {
function testPeerIdentityConstraint(withConstraint) {
var config = { audio: true, video: true };
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));
return getUserMedia(config)
.then(stream => Promise.all([
audioIsSilence(withConstraint, stream),
videoIsBlack(withConstraint, stream)
]).then(() => stream.getTracks().forEach(t => t.stop())));
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
return testPeerIdentityConstraint(false)
.then(() => testPeerIdentityConstraint(true));
await testPeerIdentityConstraint(false);
await testPeerIdentityConstraint(true);
}
runTest(theTest);