test_peerConnection_localhostPolicy.html (2710B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script type="application/javascript" src="pc.js"></script> 5 <script type="application/javascript" src="iceTestUtils.js"></script> 6 <script type="application/javascript" src="helpers_from_wpt/sdp.js"></script></head> 7 <body> 8 <pre id="test"> 9 <script type="application/javascript"> 10 createHTML({ 11 bug: "1973521", 12 title: "Test the media.peerconnection.ice.loopback pref" 13 }); 14 15 const tests = [ 16 // checkNoSrflx takes a while to run, so we want to run similar tests in 17 // one go, but we still want to break them up a bit 18 async function v4IceServerAddresses() { 19 await checkNoSrflx([{urls: ["stun:127.0.0.1", "stun:127.0.0.2", "turn:127.0.0.1", "turn:127.0.0.2"], username, credential}]); 20 }, 21 22 async function v6IceServerAddresses() { 23 await checkNoSrflx([{urls: ["stun:[::1]", "turn:[::1]"], username, credential}]); 24 }, 25 26 async function localhostIceServerName() { 27 await checkNoSrflx([{urls: ["stun:localhost", "turn:localhost"], username, credential}]); 28 }, 29 30 async function v4StunRedirect() { 31 // This is the address we will configure the NAT simulator to respond 32 // with redirects for. We use an address from TEST-NET since it is really 33 // unlikely we'll see that on a real machine, and also because we do not 34 // have special-case code in nICEr for TEST-NET (like we do for 35 // link-local, for example). 36 const redirectAddressV4 = "198.51.100.1"; 37 38 await pushPrefs( 39 ["media.peerconnection.nat_simulator.redirect_address", `${redirectAddressV4}`], 40 ["media.peerconnection.nat_simulator.redirect_targets", "127.0.0.1"]); 41 try { 42 await checkNoSrflx([{urls: [`stun:${redirectAddressV4}`, `turn:${redirectAddressV4}`], username, credential}]); 43 } finally { 44 await SpecialPowers.popPrefEnv(); 45 } 46 }, 47 48 ]; 49 50 runNetworkTest(async () => { 51 const turnServer = iceServersArray.find(server => "username" in server); 52 username = turnServer.username; 53 credential = turnServer.credential; 54 55 await pushPrefs(["media.peerconnection.ice.loopback", false]); 56 57 try { 58 for (const test of tests) { 59 info(`Running test: ${test.name}`); 60 try { 61 await test(); 62 } catch (e) { 63 ok(false, `Caught ${e.name}: ${e.message} ${e.stack}`); 64 } 65 info(`Done running test: ${test.name}`); 66 // Make sure we don't build up a pile of GC work, and also get PCImpl to 67 // print their timecards. 68 await new Promise(r => SpecialPowers.exactGC(r)); 69 } 70 } finally { 71 await SpecialPowers.popPrefEnv(); 72 } 73 74 }, { useIceServer: true }); 75 </script> 76 </pre> 77 </body> 78 </html>