test_peerConnection_iceFailure.html (2919B)
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: "Wait for ICE failure" 12 }); 13 14 // Test iceFailure 15 16 function PC_LOCAL_SETUP_NULL_ICE_HANDLER(test) { 17 test.pcLocal.setupIceCandidateHandler(test, function() {}, function () {}); 18 } 19 function PC_REMOTE_SETUP_NULL_ICE_HANDLER(test) { 20 test.pcRemote.setupIceCandidateHandler(test, function() {}, function () {}); 21 } 22 function PC_REMOTE_ADD_FAKE_ICE_CANDIDATE(test) { 23 var cand = {"candidate":"candidate:0 1 UDP 2130379007 192.0.2.1 12345 typ host","sdpMid":"","sdpMLineIndex":0}; 24 test.pcRemote.storeOrAddIceCandidate(cand); 25 info(test.pcRemote + " Stored fake candidate: " + JSON.stringify(cand)); 26 } 27 function PC_LOCAL_ADD_FAKE_ICE_CANDIDATE(test) { 28 var cand = {"candidate":"candidate:0 1 UDP 2130379007 192.0.2.2 56789 typ host","sdpMid":"","sdpMLineIndex":0}; 29 test.pcLocal.storeOrAddIceCandidate(cand); 30 info(test.pcLocal + " Stored fake candidate: " + JSON.stringify(cand)); 31 } 32 function PC_LOCAL_WAIT_FOR_ICE_FAILURE(test) { 33 return test.pcLocal.iceFailed.then(() => { 34 ok(true, this.pcLocal + " Ice Failure Reached."); 35 }); 36 } 37 function PC_REMOTE_WAIT_FOR_ICE_FAILURE(test) { 38 return test.pcRemote.iceFailed.then(() => { 39 ok(true, this.pcRemote + " Ice Failure Reached."); 40 }); 41 } 42 function PC_LOCAL_WAIT_FOR_ICE_FAILED(test) { 43 var resolveIceFailed; 44 test.pcLocal.iceFailed = new Promise(r => resolveIceFailed = r); 45 test.pcLocal.ice_connection_callbacks.checkIceStatus = () => { 46 if (test.pcLocal._pc.iceConnectionState === "failed") { 47 resolveIceFailed(); 48 } 49 } 50 } 51 function PC_REMOTE_WAIT_FOR_ICE_FAILED(test) { 52 var resolveIceFailed; 53 test.pcRemote.iceFailed = new Promise(r => resolveIceFailed = r); 54 test.pcRemote.ice_connection_callbacks.checkIceStatus = () => { 55 if (test.pcRemote._pc.iceConnectionState === "failed") { 56 resolveIceFailed(); 57 } 58 } 59 } 60 61 runNetworkTest(async () => { 62 await pushPrefs( 63 ['media.peerconnection.ice.stun_client_maximum_transmits', 3], 64 ['media.peerconnection.ice.trickle_grace_period', 3000], 65 ); 66 var test = new PeerConnectionTest(); 67 test.setMediaConstraints([{audio: true}], [{audio: true}]); 68 test.chain.replace("PC_LOCAL_SETUP_ICE_HANDLER", PC_LOCAL_SETUP_NULL_ICE_HANDLER); 69 test.chain.replace("PC_REMOTE_SETUP_ICE_HANDLER", PC_REMOTE_SETUP_NULL_ICE_HANDLER); 70 test.chain.insertAfter("PC_REMOTE_SETUP_NULL_ICE_HANDLER", PC_LOCAL_WAIT_FOR_ICE_FAILED); 71 test.chain.insertAfter("PC_LOCAL_WAIT_FOR_ICE_FAILED", PC_REMOTE_WAIT_FOR_ICE_FAILED); 72 test.chain.removeAfter("PC_LOCAL_SET_REMOTE_DESCRIPTION"); 73 test.chain.append([ 74 PC_REMOTE_ADD_FAKE_ICE_CANDIDATE, 75 PC_LOCAL_ADD_FAKE_ICE_CANDIDATE, 76 PC_LOCAL_WAIT_FOR_ICE_FAILURE, 77 PC_REMOTE_WAIT_FOR_ICE_FAILURE 78 ]); 79 await test.run(); 80 }); 81 </script> 82 </pre> 83 </body> 84 </html>