test_dataChannel_hostnameObfuscation.html (1702B)
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: "1592620", 11 title: "Blocklist to disable hostname obfuscation" 12 }); 13 14 async function testBlocklist(options, blocklistEntry, shouldBeObfuscated) { 15 let test = new PeerConnectionTest(options); 16 addInitialDataChannel(test.chain); 17 18 if (blocklistEntry !== null) { 19 await SpecialPowers.pushPrefEnv({ 20 set: [ 21 ["media.peerconnection.ice.obfuscate_host_addresses.blocklist", 22 blocklistEntry] 23 ] 24 }); 25 } 26 27 test.chain.insertAfter('PC_LOCAL_WAIT_FOR_ICE_CONNECTED', [ 28 async function CHECK_LOCAL_CANDIDATES() { 29 const stats = await test.pcLocal.getStats(); 30 stats.forEach(s => { 31 if (s.type === 'local-candidate') { 32 if (shouldBeObfuscated) { 33 ok(s.address.includes(".local"), "address should be obfuscated"); 34 } else { 35 ok(!s.address.includes(".local"), "address should not be obfuscated"); 36 } 37 } 38 }); 39 }]); 40 41 await test.run(); 42 } 43 44 runNetworkTest(async (options) => { 45 await SpecialPowers.pushPrefEnv({ 46 set: [["media.peerconnection.ice.obfuscate_host_addresses", true]] 47 }); 48 await testBlocklist(options, null, true); 49 await testBlocklist(options, "", true); 50 await testBlocklist(options, "example.com", true); 51 await testBlocklist(options, "mochi.test", false); 52 await testBlocklist(options, "example.com,mochi.test", false); 53 await testBlocklist(options, "*.test", false); 54 }); 55 56 </script> 57 </pre> 58 </body> 59 </html>