Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 function check_ip(s, v, ip) {
2 do_check_false(s.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS, ip, 0));
4 let str = "https://";
5 if (v == 6) {
6 str += "[";
7 }
8 str += ip;
9 if (v == 6) {
10 str += "]";
11 }
12 str += "/";
14 let uri = Services.io.newURI(str, null, null);
16 let parsedMaxAge = {};
17 let parsedIncludeSubdomains = {};
18 s.processHeader(Ci.nsISiteSecurityService.HEADER_HSTS, uri,
19 "max-age=1000;includeSubdomains", 0,
20 parsedMaxAge, parsedIncludeSubdomains);
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 }
31 function run_test() {
32 let SSService = Cc["@mozilla.org/ssservice;1"]
33 .getService(Ci.nsISiteSecurityService);
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 }