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 check that a frequently visited site
7 // will not be evicted over an infrequently visited site.
9 let stateFile = do_get_profile();
10 stateFile.append(SSS_STATE_FILE_NAME);
11 // Assuming we're working with a clean slate, the file shouldn't exist
12 // until we create it.
13 ok(!stateFile.exists());
14 let outputStream = FileUtils.openFileOutputStream(stateFile);
15 let now = new Date().getTime();
16 let key = "frequentlyused.example.com";
17 let value = `${now + 100000},1,0`;
18 append_line_to_data_storage_file(outputStream, 4, 1000, key, value);
20 let siteSecurityService = Cc["@mozilla.org/ssservice;1"].getService(
21 Ci.nsISiteSecurityService
23 notEqual(siteSecurityService, null);
24 // isSecureURI blocks until the backing data is read.
26 siteSecurityService.isSecureURI(
27 Services.io.newURI("https://frequentlyused.example.com")
30 // The storage limit is currently 2048, so this should cause evictions.
31 for (let i = 0; i < 3000; i++) {
32 let uri = Services.io.newURI("http://bad" + i + ".example.com");
33 siteSecurityService.processHeader(uri, "max-age=1000");
35 // The frequently used entry should not be evicted.
37 siteSecurityService.isSecureURI(
38 Services.io.newURI("https://frequentlyused.example.com")