netwerk/test/unit/test_bug504014.js

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

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

mercurial