test_peerConnection_relayOnly.html (2144B)
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: "1187775", 11 title: "peer connection ICE fails on relay-only without TURN" 12 }); 13 14 function PC_LOCAL_NO_CANDIDATES(test) { 15 var isnt = can => is(can, null, "No candidates: " + JSON.stringify(can)); 16 test.pcLocal._pc.addEventListener("icecandidate", e => isnt(e.candidate)); 17 } 18 19 function PC_BOTH_WAIT_FOR_ICE_FAILED(test) { 20 var isFail = (f, reason, msg) => 21 f().then(() => { throw new Error(msg + " must fail"); }, 22 e => is(e.message, reason, msg + " must fail with: " + e.message)); 23 24 return Promise.all([ 25 isFail(() => test.pcLocal.waitForIceConnected(), "ICE failed", "Local ICE"), 26 isFail(() => test.pcRemote.waitForIceConnected(), "ICE failed", "Remote ICE") 27 ]) 28 .then(() => ok(true, "ICE on both sides must fail.")); 29 } 30 31 runNetworkTest(async options => { 32 await pushPrefs( 33 ['media.peerconnection.ice.stun_client_maximum_transmits', 3], 34 ['media.peerconnection.ice.trickle_grace_period', 5000] 35 ); 36 options = options || {}; 37 options.config_local = options.config_local || {}; 38 const servers = options.config_local.iceServers || []; 39 // remove any turn servers 40 options.config_local.iceServers = servers.filter(server => 41 server.urls.every(u => !u.toLowerCase().startsWith('turn'))); 42 43 // Here's the setting we're testing. Comment out and this test should fail: 44 options.config_local.iceTransportPolicy = "relay"; 45 46 const test = new PeerConnectionTest(options); 47 test.setMediaConstraints([{audio: true}, {video: true}], 48 [{audio: true}, {video: true}]); 49 test.chain.remove("PC_LOCAL_SETUP_ICE_LOGGER"); // Needed to suppress failing 50 test.chain.remove("PC_REMOTE_SETUP_ICE_LOGGER"); // on ICE-failure. 51 test.chain.insertAfter("PC_LOCAL_SETUP_ICE_HANDLER", PC_LOCAL_NO_CANDIDATES); 52 test.chain.replace("PC_LOCAL_WAIT_FOR_ICE_CONNECTED", PC_BOTH_WAIT_FOR_ICE_FAILED); 53 test.chain.removeAfter("PC_BOTH_WAIT_FOR_ICE_FAILED"); 54 await test.run(); 55 }); 56 57 </script> 58 </pre> 59 </body> 60 </html>