blob: a28275047e4f6a4463fa164a39fb81a2fbbc084f [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());
youennf6c623dc2021-09-14 06:59:4115 pc1.addTransceiver('audio', { direction: 'recvonly' });
Byron Campen85108bed2024-02-21 17:26:1716 await initialOfferAnswerWithIceGatheringStateTransitions(pc1, pc2);
Blink WPT Bot76b44c02020-08-03 14:07:0017 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 => {
Byron Campen85108bed2024-02-21 17:26:1725 const pc1 = new RTCPeerConnection();
26 t.add_cleanup(() => pc1.close());
27 const pc2 = new RTCPeerConnection();
28 t.add_cleanup(() => pc2.close());
29 pc1.createDataChannel('test');
30 await initialOfferAnswerWithIceGatheringStateTransitions(pc1, pc2);
31 await pc1.setLocalDescription(await pc1.createOffer({iceRestart: true}));
32 await iceGatheringStateTransitions(pc1, 'gathering', 'complete');
33 expectNoMoreGatheringStateChanges(t, pc1);
34 await pc1.setLocalDescription({type: 'rollback'});
35 await new Promise(r => t.step_timeout(r, 1000));
36}, 'rolling back an ICE restart when gathering is complete should not result in iceGatheringState changes (DataChannel case)');
Blink WPT Bot76b44c02020-08-03 14:07:0037
38promise_test(async t => {
39 const pc = new RTCPeerConnection();
40 t.add_cleanup(() => pc.close());
youennf6c623dc2021-09-14 06:59:4141 pc.addTransceiver('audio', { direction: 'recvonly' });
Byron Campen85108bed2024-02-21 17:26:1742 await pc.setLocalDescription();
43 await iceGatheringStateTransitions(pc, 'gathering', 'complete');
44 const backToNew = iceGatheringStateTransitions(pc, 'new');
45 await pc.setLocalDescription({type: 'rollback'});
46 await backToNew;
47}, 'setLocalDescription(rollback) of original offer should cause iceGatheringState to reach "new" when starting in "complete"');
48
49promise_test(async t => {
50 const pc = new RTCPeerConnection();
51 t.add_cleanup(() => pc.close());
52 pc.createDataChannel('test');
53 await pc.setLocalDescription();
54 await iceGatheringStateTransitions(pc, 'gathering', 'complete');
55 const backToNew = iceGatheringStateTransitions(pc, 'new');
56 await pc.setLocalDescription({type: 'rollback'});
57 await backToNew;
58}, 'setLocalDescription(rollback) of original offer should cause iceGatheringState to reach "new" when starting in "complete" (DataChannel case)');
59
60promise_test(async t => {
61 const pc = new RTCPeerConnection();
62 t.add_cleanup(() => pc.close());
63 pc.addTransceiver('audio', { direction: 'recvonly' });
64 await pc.setLocalDescription();
Blink WPT Bot76b44c02020-08-03 14:07:0065 await iceGatheringStateTransitions(pc, 'gathering');
Byron Campen85108bed2024-02-21 17:26:1766 const backToNew = Promise.allSettled([
67 iceGatheringStateTransitions(pc, 'new'),
68 iceGatheringStateTransitions(pc, 'complete', 'new')]);
Blink WPT Bot76b44c02020-08-03 14:07:0069 await pc.setLocalDescription({type: 'rollback'});
70 // We might go directly to 'new', or we might go to 'complete' first,
71 // depending on timing. Allow either.
Byron Campen85108bed2024-02-21 17:26:1772 const results = await backToNew;
Blink WPT Bot76b44c02020-08-03 14:07:0073 assert_true(results.some(result => result.status == 'fulfilled'),
74 'ICE gathering state should go back to "new", possibly through "complete"');
75}, 'setLocalDescription(rollback) of original offer should cause iceGatheringState to reach "new" when starting in "gathering"');
76
Byron Campen85108bed2024-02-21 17:26:1777promise_test(async t => {
78 const pc = new RTCPeerConnection();
79 t.add_cleanup(() => pc.close());
80 pc.createDataChannel('test');
81 await pc.setLocalDescription();
82 await iceGatheringStateTransitions(pc, 'gathering');
83 const backToNew = Promise.allSettled([
84 iceGatheringStateTransitions(pc, 'new'),
85 iceGatheringStateTransitions(pc, 'complete', 'new')]);
86 await pc.setLocalDescription({type: 'rollback'});
87 // We might go directly to 'new', or we might go to 'complete' first,
88 // depending on timing. Allow either.
89 const results = await backToNew;
90 assert_true(results.some(result => result.status == 'fulfilled'),
91 'ICE gathering state should go back to "new", possibly through "complete"');
92}, 'setLocalDescription(rollback) of original offer should cause iceGatheringState to reach "new" when starting in "gathering" (DataChannel case)');
93
Blink WPT Bot76b44c02020-08-03 14:07:0094</script>