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/. */
6 // The purpose of this test is to create an empty site security service state
7 // file and see that the site security service doesn't fail when reading it.
10 let profileDir = do_get_profile();
11 let stateFile = profileDir.clone();
12 stateFile.append(SSS_STATE_FILE_NAME);
13 // Assuming we're working with a clean slate, the file shouldn't exist
14 // until we create it.
15 ok(!stateFile.exists());
16 stateFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0x1a4); // 0x1a4 == 0o644
17 ok(stateFile.exists());
18 // Initialize nsISiteSecurityService after do_get_profile() so it
19 // can read the state file.
20 let siteSecurityService = Cc["@mozilla.org/ssservice;1"].getService(
21 Ci.nsISiteSecurityService
23 notEqual(siteSecurityService, null);
24 // nsISiteSecurityService.isSecureURI blocks until the backing file has been read.
25 // nonexistent.example.com should never be an HSTS host
27 !siteSecurityService.isSecureURI(
28 Services.io.newURI("https://nonexistent.example.com")
32 siteSecurityService.isSecureURI(
33 Services.io.newURI("https://includesubdomains.preloaded.test")
36 // notexpired.example.com is an HSTS host in a different test - we
37 // want to make sure that test hasn't interfered with this one.
39 !siteSecurityService.isSecureURI(
40 Services.io.newURI("https://notexpired.example.com")