|
1 function check_ip(s, v, ip) { |
|
2 do_check_false(s.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS, ip, 0)); |
|
3 |
|
4 let str = "https://"; |
|
5 if (v == 6) { |
|
6 str += "["; |
|
7 } |
|
8 str += ip; |
|
9 if (v == 6) { |
|
10 str += "]"; |
|
11 } |
|
12 str += "/"; |
|
13 |
|
14 let uri = Services.io.newURI(str, null, null); |
|
15 |
|
16 let parsedMaxAge = {}; |
|
17 let parsedIncludeSubdomains = {}; |
|
18 s.processHeader(Ci.nsISiteSecurityService.HEADER_HSTS, uri, |
|
19 "max-age=1000;includeSubdomains", 0, |
|
20 parsedMaxAge, parsedIncludeSubdomains); |
|
21 |
|
22 /* Test that processHeader will ignore headers for an uri, if the uri |
|
23 * contains an IP address not a hostname. |
|
24 * If processHeader indeed ignore the header, then the output parameters will |
|
25 * remain empty, and we shouldn't see the values passed as the header. |
|
26 */ |
|
27 do_check_neq(parsedMaxAge.value, 1000); |
|
28 do_check_neq(parsedIncludeSubdomains.value, true); |
|
29 } |
|
30 |
|
31 function run_test() { |
|
32 let SSService = Cc["@mozilla.org/ssservice;1"] |
|
33 .getService(Ci.nsISiteSecurityService); |
|
34 |
|
35 check_ip(SSService, 4, "127.0.0.1"); |
|
36 check_ip(SSService, 4, "10.0.0.1"); |
|
37 check_ip(SSService, 6, "2001:db8::1"); |
|
38 check_ip(SSService, 6, "1080::8:800:200C:417A"); |
|
39 } |