RTCPeerConnection-explicit-rollback-iceGatheringState.html (4462B)
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()); 15 pc1.addTransceiver('audio', { direction: 'recvonly' }); 16 await initialOfferAnswerWithIceGatheringStateTransitions(pc1, pc2); 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 => { 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)'); 37 38 promise_test(async t => { 39 const pc = new RTCPeerConnection(); 40 t.add_cleanup(() => pc.close()); 41 pc.addTransceiver('audio', { direction: 'recvonly' }); 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(); 65 await iceGatheringStateTransitions(pc, 'gathering'); 66 const backToNew = Promise.allSettled([ 67 iceGatheringStateTransitions(pc, 'new'), 68 iceGatheringStateTransitions(pc, 'complete', 'new')]); 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. 72 const results = await backToNew; 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 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 94 </script>