tor-browser

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

test_bug504014.js (1872B)


      1 "use strict";
      2 
      3 var valid_URIs = [
      4  "http://[::]/",
      5  "http://[::1]/",
      6  "http://[1::]/",
      7  "http://[::]/",
      8  "http://[::1]/",
      9  "http://[1::]/",
     10  "http://[1:2:3:4:5:6:7::]/",
     11  "http://[::1:2:3:4:5:6:7]/",
     12  "http://[1:2:a:B:c:D:e:F]/",
     13  "http://[1::8]/",
     14  "http://[1:2::8]/",
     15  "http://[0000:0123:4567:89AB:CDEF:abcd:ef00:0000]/",
     16  "http://[::192.168.1.1]/",
     17  "http://[1::0.0.0.0]/",
     18  "http://[1:2::255.255.255.255]/",
     19  "http://[1:2:3::255.255.255.255]/",
     20  "http://[1:2:3:4::255.255.255.255]/",
     21  "http://[1:2:3:4:5::255.255.255.255]/",
     22  "http://[1:2:3:4:5:6:255.255.255.255]/",
     23 ];
     24 
     25 var invalid_URIs = [
     26  "http://[1]/",
     27  "http://[192.168.1.1]/",
     28  "http://[:::]/",
     29  "http://[:::1]/",
     30  "http://[1:::]/",
     31  "http://[::1::]/",
     32  "http://[1:2:3:4:5:6:7:]/",
     33  "http://[:2:3:4:5:6:7:8]/",
     34  "http://[1:2:3:4:5:6:7:8:]/",
     35  "http://[:1:2:3:4:5:6:7:8]/",
     36  "http://[1:2:3:4:5:6:7:8::]/",
     37  "http://[::1:2:3:4:5:6:7:8]/",
     38  "http://[1:2:3:4:5:6:7]/",
     39  "http://[1:2:3:4:5:6:7:8:9]/",
     40  "http://[00001:2:3:4:5:6:7:8]/",
     41  "http://[0001:2:3:4:5:6:7:89abc]/",
     42  "http://[A:b:C:d:E:f:G:h]/",
     43  "http://[::192.168.1]/",
     44  "http://[::192.168.1.]/",
     45  "http://[::.168.1.1]/",
     46  "http://[::192..1.1]/",
     47  "http://[::0192.168.1.1]/",
     48  "http://[::256.255.255.255]/",
     49  "http://[::1x.255.255.255]/",
     50  "http://[::192.4294967464.1.1]/",
     51  "http://[1:2:3:4:5:6::255.255.255.255]/",
     52  "http://[1:2:3:4:5:6:7:255.255.255.255]/",
     53 ];
     54 
     55 function run_test() {
     56  for (let i = 0; i < valid_URIs.length; i++) {
     57    try {
     58      Services.io.newURI(valid_URIs[i]);
     59    } catch (e) {
     60      do_throw("cannot create URI:" + valid_URIs[i]);
     61    }
     62  }
     63 
     64  for (let i = 0; i < invalid_URIs.length; i++) {
     65    try {
     66      Services.io.newURI(invalid_URIs[i]);
     67      do_throw("should throw: " + invalid_URIs[i]);
     68    } catch (e) {
     69      Assert.equal(e.result, Cr.NS_ERROR_MALFORMED_URI);
     70    }
     71  }
     72 }