|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
4 */ |
|
5 "use strict"; |
|
6 |
|
7 // bug 961528: chart.apis.google.com doesn't handle https. Check that |
|
8 // it isn't considered HSTS (other example.apis.google.com hosts should be |
|
9 // HSTS as long as they're on the preload list, however). |
|
10 function run_test() { |
|
11 let SSService = Cc["@mozilla.org/ssservice;1"] |
|
12 .getService(Ci.nsISiteSecurityService); |
|
13 do_check_false(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS, |
|
14 "chart.apis.google.com", 0)); |
|
15 do_check_false(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS, |
|
16 "CHART.APIS.GOOGLE.COM", 0)); |
|
17 do_check_false(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS, |
|
18 "sub.chart.apis.google.com", 0)); |
|
19 do_check_false(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS, |
|
20 "SUB.CHART.APIS.GOOGLE.COM", 0)); |
|
21 do_check_true(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS, |
|
22 "example.apis.google.com", 0)); |
|
23 do_check_true(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS, |
|
24 "EXAMPLE.APIS.GOOGLE.COM", 0)); |
|
25 do_check_true(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS, |
|
26 "sub.example.apis.google.com", 0)); |
|
27 do_check_true(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS, |
|
28 "SUB.EXAMPLE.APIS.GOOGLE.COM", 0)); |
|
29 // also check isSecureURI |
|
30 let chartURI = Services.io.newURI("http://chart.apis.google.com", null, null); |
|
31 do_check_false(SSService.isSecureURI(Ci.nsISiteSecurityService.HEADER_HSTS, |
|
32 chartURI, 0)); |
|
33 let otherURI = Services.io.newURI("http://other.apis.google.com", null, null); |
|
34 do_check_true(SSService.isSecureURI(Ci.nsISiteSecurityService.HEADER_HSTS, |
|
35 otherURI, 0)); |
|
36 } |