Bug 1582190: Add test-case that reproduces this bug. r=jib

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Byron Campen [:bwc] 2019-10-01 22:38:12 +00:00
parent 232603d16a
commit e348913a3a

View File

@ -6,6 +6,11 @@
<script src="RTCPeerConnection-helper.js"></script>
<script>
'use strict';
const stopTracks = (...streams) => {
streams.forEach(stream => stream.getTracks().forEach(track => track.stop()));
};
// Test is based on the following revision:
// https://rawgit.com/w3c/webrtc-pc/1cc5bfc3ff18741033d804c4a71f7891242fb5b3/webrtc.html
/*
@ -621,6 +626,54 @@ promise_test(async t => {
assert_equals(dc.readyState, 'connecting', 'Channel should be in the connecting state');
}, 'New data channel should be in the connecting state after creation (after connection ' +
'establishment)');
promise_test(async t => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
const stream = await getNoiseStream({audio: true, video: true});
t.add_cleanup(() => stopTracks(stream));
const audio = stream.getAudioTracks()[0];
const video = stream.getVideoTracks()[0];
pc1.addTrack(audio, stream);
pc1.addTrack(video, stream);
await createDataChannelPair(pc1, pc2);
}, 'addTrack, then createDataChannel, should negotiate properly');
promise_test(async t => {
const pc1 = new RTCPeerConnection({bundlePolicy: "max-bundle"});
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
const stream = await getNoiseStream({audio: true, video: true});
t.add_cleanup(() => stopTracks(stream));
const audio = stream.getAudioTracks()[0];
const video = stream.getVideoTracks()[0];
pc1.addTrack(audio, stream);
pc1.addTrack(video, stream);
await createDataChannelPair(pc1, pc2);
}, 'addTrack, then createDataChannel, should negotiate properly when max-bundle is used');
promise_test(async t => {
const pc1 = new RTCPeerConnection({bundlePolicy: "max-bundle"});
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
const stream = await getNoiseStream({audio: true, video: true});
t.add_cleanup(() => stopTracks(stream));
const audio = stream.getAudioTracks()[0];
const video = stream.getVideoTracks()[0];
pc1.addTrack(audio, stream);
pc1.addTrack(video, stream);
const [dc1, dc2] = await createDataChannelPair(pc1, pc2);
pc2.getTransceivers()[0].stop();
const dc1Closed = new Promise(r => dc1.onclose = r);
await doSignalingHandshake(pc1, pc2);
await dc1Closed;
}, 'Stopping the bundle-tag when there is a DataChannel in the bundle should kill the DataChannel');
/*
Untestable
6.1. createDataChannel