Bug 1629565: Test that we do not transition to "gathering" on a simple reoffer. r=jib

Differential Revision: https://phabricator.services.mozilla.com/D72236
This commit is contained in:
Byron Campen [:bwc] 2020-04-27 16:42:49 +00:00
Родитель 606eb34163
Коммит 0e6e49d74d
1 изменённых файлов: 43 добавлений и 0 удалений

Просмотреть файл

@ -84,10 +84,53 @@
assert_unreached(`Unhandled rejection ${err.name}: ${err.message}`)));
}, 'iceGatheringState should eventually become complete after setLocalDescription');
const iceGatheringStateTransitions = async (pc, ...states) => {
for (const state of states) {
await new Promise((resolve, reject) => {
pc.addEventListener('icegatheringstatechange', () => {
if (pc.iceGatheringState == state) {
resolve();
} else {
reject(`Unexpected gathering state: ${pc.iceGatheringState}, was expecting ${state}`);
}
}, {once: true});
});
}
};
const initialOfferAnswer = async (pc1, pc2, offerOptions) => {
await pc1.setLocalDescription(
await pc1.createOffer(offerOptions));
const pc1Transitions = iceGatheringStateTransitions(pc1, 'gathering', 'complete');
await pc2.setRemoteDescription(pc1.localDescription);
await pc2.setLocalDescription(await pc2.createAnswer());
const pc2Transitions = iceGatheringStateTransitions(pc2, 'gathering', 'complete');
await pc1.setRemoteDescription(pc2.localDescription);
await pc1Transitions;
await pc2Transitions;
};
const expectNoMoreGatheringStateChanges = async (t, pc) => {
pc.onicegatheringstatechange = t.step_func(() => assert_unreached('Should not get an icegatheringstatechange right now!'));
};
promise_test(async t => {
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());
await initialOfferAnswer(pc1, pc2, {offerToReceiveAudio:true});
expectNoMoreGatheringStateChanges(t, pc1);
expectNoMoreGatheringStateChanges(t, pc2);
await pc1.setLocalDescription(await pc1.createOffer());
await pc2.setLocalDescription(await pc2.createOffer());
await new Promise(r => t.step_timeout(r, 500));
}, 'setLocalDescription(reoffer) with no new transports should not cause iceGatheringState to change');
promise_test(async t => {
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());