Bug 1337246 - Part 3 - Add a test for hostnameIsLocalIPAddress. r=valentin
MozReview-Commit-ID: 11nCKJFsv6i
new file mode 100644
--- /dev/null
+++ b/netwerk/test/unit/test_hostnameIsLocalIPAddress.js
@@ -0,0 +1,29 @@
+var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
+
+function run_test() {
+ let testURIs = [
+ ["http://example.com", false],
+ ["about:robots", false],
+ ["http://9.255.255.255", false],
+ ["http://10.0.0.0", true],
+ ["http://10.0.23.31", true],
+ ["http://10.255.255.255", true],
+ ["http://11.0.0.0", false],
+ ["http://172.15.255.255", false],
+ ["http://172.16.0.0", true],
+ ["http://172.25.110.0", true],
+ ["http://172.31.255.255", true],
+ ["http://172.32.0.0", false],
+ ["http://192.167.255.255", false],
+ ["http://192.168.0.0", true],
+ ["http://192.168.127.10", true],
+ ["http://192.168.255.255", true],
+ ["http://192.169.0.0", false],
+ ];
+
+ for (let [uri, isLocal] of testURIs) {
+ let nsuri = ioService.newURI(uri);
+ equal(isLocal, ioService.hostnameIsLocalIPAddress(nsuri));
+ }
+}
+
--- a/netwerk/test/unit/xpcshell.ini
+++ b/netwerk/test/unit/xpcshell.ini
@@ -212,16 +212,17 @@ skip-if = bits != 32
[test_filestreams.js]
[test_freshconnection.js]
[test_gre_resources.js]
[test_gzipped_206.js]
[test_head.js]
[test_header_Accept-Language.js]
[test_header_Accept-Language_case.js]
[test_headers.js]
+[test_hostnameIsLocalIPAddress.js]
[test_http_headers.js]
[test_httpauth.js]
[test_httpcancel.js]
[test_httpResponseTimeout.js]
[test_httpsuspend.js]
[test_idnservice.js]
[test_idn_blacklist.js]
[test_idn_urls.js]