diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /netwerk/test/unit/test_hostnameIsLocalIPAddress.js | |
parent | Initial commit. (diff) | |
download | firefox-e51783d008170d9ab27d25da98ca3a38b0a41b67.tar.xz firefox-e51783d008170d9ab27d25da98ca3a38b0a41b67.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test/unit/test_hostnameIsLocalIPAddress.js')
-rw-r--r-- | netwerk/test/unit/test_hostnameIsLocalIPAddress.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/netwerk/test/unit/test_hostnameIsLocalIPAddress.js b/netwerk/test/unit/test_hostnameIsLocalIPAddress.js new file mode 100644 index 0000000000..64d246c633 --- /dev/null +++ b/netwerk/test/unit/test_hostnameIsLocalIPAddress.js @@ -0,0 +1,37 @@ +"use strict"; + +function run_test() { + let testURIs = [ + ["http://example.com", false], + ["about:robots", false], + // 10/8 prefix (RFC 1918) + ["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], + // 169.254/16 prefix (Link Local) + ["http://169.253.255.255", false], + ["http://169.254.0.0", true], + ["http://169.254.42.91", true], + ["http://169.254.255.255", true], + ["http://169.255.0.0", false], + // 172.16/12 prefix (RFC 1918) + ["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], + // 192.168/16 prefix (RFC 1918) + ["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 = Services.io.newURI(uri); + equal(isLocal, Services.io.hostnameIsLocalIPAddress(nsuri)); + } +} |