blob: 9c1fe014bd9ee18bb6a9ab65ea7aa3eebbce1200 [file] [log] [blame]
Blink WPT Bot76b44c02020-08-03 14:07:001<!doctype html>
2<meta charset=utf-8>
3<title>RTCPeerConnection.prototype.iceGatheringState</title>
4<script src="/resources/testharness.js"></script>
5<script src="/resources/testharnessreport.js"></script>
6<script src="RTCPeerConnection-helper.js"></script>
7<script>
8'use strict';
9
10promise_test(async t => {
11 const pc1 = new RTCPeerConnection();
12 t.add_cleanup(() => pc1.close());
13 const pc2 = new RTCPeerConnection();
14 t.add_cleanup(() => pc2.close());
15 await initialOfferAnswerWithIceGatheringStateTransitions(
16 pc1, pc2, {offerToReceiveAudio: true});
17 await pc1.setLocalDescription(await pc1.createOffer({iceRestart: true}));
18 await iceGatheringStateTransitions(pc1, 'gathering', 'complete');
19 expectNoMoreGatheringStateChanges(t, pc1);
20 await pc1.setLocalDescription({type: 'rollback'});
21 await new Promise(r => t.step_timeout(r, 1000));
22}, 'rolling back an ICE restart when gathering is complete should not result in iceGatheringState changes');
23
24promise_test(async t => {
25 const pc = new RTCPeerConnection();
26 t.add_cleanup(() => pc.close());
27 await pc.setLocalDescription(
28 await pc.createOffer({offerToReceiveAudio: true}));
29 await iceGatheringStateTransitions(pc, 'gathering', 'complete');
30 await pc.setLocalDescription({type: 'rollback'});
31 await iceGatheringStateTransitions(pc, 'new');
32}, 'setLocalDescription(rollback) of original offer should cause iceGatheringState to reach "new" when starting in "complete"');
33
34promise_test(async t => {
35 const pc = new RTCPeerConnection();
36 t.add_cleanup(() => pc.close());
37 await pc.setLocalDescription(
38 await pc.createOffer({offerToReceiveAudio: true}));
39 await iceGatheringStateTransitions(pc, 'gathering');
40 await pc.setLocalDescription({type: 'rollback'});
41 // We might go directly to 'new', or we might go to 'complete' first,
42 // depending on timing. Allow either.
43 const results = await Promise.allSettled([
44 iceGatheringStateTransitions(pc, 'new'),
45 iceGatheringStateTransitions(pc, 'complete', 'new')]);
46 assert_true(results.some(result => result.status == 'fulfilled'),
47 'ICE gathering state should go back to "new", possibly through "complete"');
48}, 'setLocalDescription(rollback) of original offer should cause iceGatheringState to reach "new" when starting in "gathering"');
49
50</script>