tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_ipv6_host_literal.js (941B)


      1 var ssm = Services.scriptSecurityManager;
      2 function makeURI(uri) {
      3  return Services.io.newURI(uri);
      4 }
      5 
      6 function testIPV6Host(aHost, aExpected) {
      7  var ipv6Host = ssm.createContentPrincipal(makeURI(aHost), {});
      8  Assert.equal(ipv6Host.origin, aExpected);
      9 }
     10 
     11 function run_test() {
     12  testIPV6Host("http://[::1]/", "http://[::1]");
     13 
     14  testIPV6Host(
     15    "http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]/",
     16    "http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]"
     17  );
     18 
     19  testIPV6Host(
     20    "http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443/",
     21    "http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443"
     22  );
     23 
     24  testIPV6Host(
     25    "http://[2001:db8:85a3::1319:8a2e:370:7348]/",
     26    "http://[2001:db8:85a3:0:1319:8a2e:370:7348]"
     27  );
     28 
     29  testIPV6Host(
     30    "http://[20D1:0000:3238:DFE1:63:0000:0000:FEFB]/",
     31    "http://[20d1:0:3238:dfe1:63::fefb]"
     32  );
     33 
     34  testIPV6Host(
     35    "http://[20D1:0:3238:DFE1:63::FEFB]/",
     36    "http://[20d1:0:3238:dfe1:63::fefb]"
     37  );
     38 }