| Blink WPT Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 1 | <!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 | |
| 10 | promise_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()); |
| youennf | 6c623dc | 2021-09-14 06:59:41 | [diff] [blame] | 15 | pc1.addTransceiver('audio', { direction: 'recvonly' }); |
| Byron Campen | 85108bed | 2024-02-21 17:26:17 | [diff] [blame^] | 16 | await initialOfferAnswerWithIceGatheringStateTransitions(pc1, pc2); |
| Blink WPT Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 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 | |
| 24 | promise_test(async t => { |
| Byron Campen | 85108bed | 2024-02-21 17:26:17 | [diff] [blame^] | 25 | 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 Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 37 | |
| 38 | promise_test(async t => { |
| 39 | const pc = new RTCPeerConnection(); |
| 40 | t.add_cleanup(() => pc.close()); |
| youennf | 6c623dc | 2021-09-14 06:59:41 | [diff] [blame] | 41 | pc.addTransceiver('audio', { direction: 'recvonly' }); |
| Byron Campen | 85108bed | 2024-02-21 17:26:17 | [diff] [blame^] | 42 | 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 | |
| 49 | promise_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 | |
| 60 | promise_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 Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 65 | await iceGatheringStateTransitions(pc, 'gathering'); |
| Byron Campen | 85108bed | 2024-02-21 17:26:17 | [diff] [blame^] | 66 | const backToNew = Promise.allSettled([ |
| 67 | iceGatheringStateTransitions(pc, 'new'), |
| 68 | iceGatheringStateTransitions(pc, 'complete', 'new')]); |
| Blink WPT Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 69 | 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 Campen | 85108bed | 2024-02-21 17:26:17 | [diff] [blame^] | 72 | const results = await backToNew; |
| Blink WPT Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 73 | 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 Campen | 85108bed | 2024-02-21 17:26:17 | [diff] [blame^] | 77 | promise_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 Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 94 | </script> |