test_peerConnection_closeDuringIce.html (2891B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script type="application/javascript" src="pc.js"></script> 5 </head> 6 <body> 7 <pre id="test"> 8 <script type="application/javascript"> 9 createHTML({ 10 bug: "1087629", 11 title: "Close PCs during ICE connectivity check" 12 }); 13 14 // Test closeDuringIce to simulate problems during peer connections 15 16 17 function PC_LOCAL_SETUP_NULL_ICE_HANDLER(test) { 18 test.pcLocal.setupIceCandidateHandler(test, function() {}, function () {}); 19 } 20 function PC_REMOTE_SETUP_NULL_ICE_HANDLER(test) { 21 test.pcRemote.setupIceCandidateHandler(test, function() {}, function () {}); 22 } 23 function PC_REMOTE_ADD_FAKE_ICE_CANDIDATE(test) { 24 var cand = {"candidate":"candidate:0 1 UDP 2130379007 192.0.2.1 12345 typ host","sdpMid":"","sdpMLineIndex":0}; 25 test.pcRemote.storeOrAddIceCandidate(cand); 26 info(test.pcRemote + " Stored fake candidate: " + JSON.stringify(cand)); 27 } 28 function PC_LOCAL_ADD_FAKE_ICE_CANDIDATE(test) { 29 var cand = {"candidate":"candidate:0 1 UDP 2130379007 192.0.2.2 56789 typ host","sdpMid":"","sdpMLineIndex":0}; 30 test.pcLocal.storeOrAddIceCandidate(cand); 31 info(test.pcLocal + " Stored fake candidate: " + JSON.stringify(cand)); 32 } 33 function PC_LOCAL_CLOSE_DURING_ICE(test) { 34 return test.pcLocal.iceChecking.then(() => { 35 test.pcLocal.onsignalingstatechange = function () {}; 36 test.pcLocal.close(); 37 }); 38 } 39 function PC_REMOTE_CLOSE_DURING_ICE(test) { 40 return test.pcRemote.iceChecking.then(() => { 41 test.pcRemote.onsignalingstatechange = function () {}; 42 test.pcRemote.close(); 43 }); 44 } 45 function PC_LOCAL_WAIT_FOR_ICE_CHECKING(test) { 46 var resolveIceChecking; 47 test.pcLocal.iceChecking = new Promise(r => resolveIceChecking = r); 48 test.pcLocal.ice_connection_callbacks.checkIceStatus = () => { 49 if (test.pcLocal._pc.iceConnectionState === "checking") { 50 resolveIceChecking(); 51 } 52 } 53 } 54 function PC_REMOTE_WAIT_FOR_ICE_CHECKING(test) { 55 var resolveIceChecking; 56 test.pcRemote.iceChecking = new Promise(r => resolveIceChecking = r); 57 test.pcRemote.ice_connection_callbacks.checkIceStatus = () => { 58 if (test.pcRemote._pc.iceConnectionState === "checking") { 59 resolveIceChecking(); 60 } 61 } 62 } 63 64 runNetworkTest(() => { 65 var test = new PeerConnectionTest(); 66 test.setMediaConstraints([{audio: true}], [{audio: true}]); 67 test.chain.replace("PC_LOCAL_SETUP_ICE_HANDLER", PC_LOCAL_SETUP_NULL_ICE_HANDLER); 68 test.chain.replace("PC_REMOTE_SETUP_ICE_HANDLER", PC_REMOTE_SETUP_NULL_ICE_HANDLER); 69 test.chain.insertAfter("PC_REMOTE_SETUP_NULL_ICE_HANDLER", PC_LOCAL_WAIT_FOR_ICE_CHECKING); 70 test.chain.insertAfter("PC_LOCAL_WAIT_FOR_ICE_CHECKING", PC_REMOTE_WAIT_FOR_ICE_CHECKING); 71 test.chain.removeAfter("PC_LOCAL_SET_REMOTE_DESCRIPTION"); 72 test.chain.append([PC_REMOTE_ADD_FAKE_ICE_CANDIDATE, PC_LOCAL_ADD_FAKE_ICE_CANDIDATE, 73 PC_LOCAL_CLOSE_DURING_ICE, PC_REMOTE_CLOSE_DURING_ICE]); 74 return test.run(); 75 }); 76 </script> 77 </pre> 78 </body> 79 </html>