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 a site security service state file
7 // and see that the site security service reads and migrates it properly.
10 let profileDir = do_get_profile();
11 let stateFile = profileDir.clone();
12 stateFile.append(SSS_STATE_OLD_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 let outputStream = FileUtils.openFileOutputStream(stateFile);
20 `no-origin-attributes.example.com:HSTS\t0\t0\t${now + 100000},1,0`
22 lines.push(`not-hsts.example.com:HPKP\t0\t0\t${now + 100000},1,0`);
24 `with-port.example.com^partitionKey=%28http%2Cexample.com%2C8443%29:HSTS\t0\t0\t${
28 for (let i = 0; lines.length < 1024; i++) {
29 lines.push(`filler-${i}.example.com:HPKP\t0\t0\t${now + 100000},1,0`);
31 writeLinesAndClose(lines, outputStream);
32 let sss = Cc["@mozilla.org/ssservice;1"].getService(
33 Ci.nsISiteSecurityService
37 // nsISiteSecurityService.isSecureURI will block until the backing file is read.
40 Services.io.newURI("https://no-origin-attributes.example.com")
43 ok(!sss.isSecureURI(Services.io.newURI("https://not-hsts.example.com")));
45 sss.isSecureURI(Services.io.newURI("https://with-port.example.com"), {
46 partitionKey: "(http,example.com,8443)",
50 sss.isSecureURI(Services.io.newURI("https://with-port.example.com"), {
51 partitionKey: "(http,example.com)",
55 sss.isSecureURI(Services.io.newURI("https://with-port.example.com"), {
56 partitionKey: "(http,example.com,8000)",
60 sss.isSecureURI(Services.io.newURI("https://with-port.example.com"), {
61 partitionKey: "(https,example.com)",