michael@0: function check_ip(s, v, ip) { michael@0: do_check_false(s.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS, ip, 0)); michael@0: michael@0: let str = "https://"; michael@0: if (v == 6) { michael@0: str += "["; michael@0: } michael@0: str += ip; michael@0: if (v == 6) { michael@0: str += "]"; michael@0: } michael@0: str += "/"; michael@0: michael@0: let uri = Services.io.newURI(str, null, null); michael@0: michael@0: let parsedMaxAge = {}; michael@0: let parsedIncludeSubdomains = {}; michael@0: s.processHeader(Ci.nsISiteSecurityService.HEADER_HSTS, uri, michael@0: "max-age=1000;includeSubdomains", 0, michael@0: parsedMaxAge, parsedIncludeSubdomains); michael@0: michael@0: /* Test that processHeader will ignore headers for an uri, if the uri michael@0: * contains an IP address not a hostname. michael@0: * If processHeader indeed ignore the header, then the output parameters will michael@0: * remain empty, and we shouldn't see the values passed as the header. michael@0: */ michael@0: do_check_neq(parsedMaxAge.value, 1000); michael@0: do_check_neq(parsedIncludeSubdomains.value, true); michael@0: } michael@0: michael@0: function run_test() { michael@0: let SSService = Cc["@mozilla.org/ssservice;1"] michael@0: .getService(Ci.nsISiteSecurityService); michael@0: michael@0: check_ip(SSService, 4, "127.0.0.1"); michael@0: check_ip(SSService, 4, "10.0.0.1"); michael@0: check_ip(SSService, 6, "2001:db8::1"); michael@0: check_ip(SSService, 6, "1080::8:800:200C:417A"); michael@0: }