test_sss_readstate_huge.js (2157B)
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 "use strict"; 5 6 // The purpose of this test is to create an old site security service state 7 // file that is too large and see that the site security service migrates it to 8 // the new format properly. 9 10 function run_test() { 11 let profileDir = do_get_profile(); 12 let stateFile = profileDir.clone(); 13 stateFile.append(SSS_STATE_OLD_FILE_NAME); 14 // Assuming we're working with a clean slate, the file shouldn't exist 15 // until we create it. 16 ok(!stateFile.exists()); 17 let outputStream = FileUtils.openFileOutputStream(stateFile); 18 let expiryTime = Date.now() + 100000; 19 let lines = []; 20 for (let i = 0; i < 10000; i++) { 21 // The 0s will all get squashed down into one 0 when they are read. 22 // This is just to make the file size large (>2MB). 23 lines.push( 24 `example${i}.example.com\t` + 25 "0000000000000000000000000000000000000000000000000\t" + 26 "00000000000000000000000000000000000000\t" + 27 `${expiryTime},1,0` 28 ); 29 } 30 writeLinesAndClose(lines, outputStream); 31 32 let siteSecurityService = Cc["@mozilla.org/ssservice;1"].getService( 33 Ci.nsISiteSecurityService 34 ); 35 notEqual(siteSecurityService, null); 36 37 ok( 38 siteSecurityService.isSecureURI( 39 Services.io.newURI("https://example0.example.com") 40 ) 41 ); 42 ok( 43 siteSecurityService.isSecureURI( 44 Services.io.newURI("https://example423.example.com") 45 ) 46 ); 47 ok( 48 siteSecurityService.isSecureURI( 49 Services.io.newURI("https://example1023.example.com") 50 ) 51 ); 52 ok( 53 !siteSecurityService.isSecureURI( 54 Services.io.newURI("https://example1024.example.com") 55 ) 56 ); 57 ok( 58 !siteSecurityService.isSecureURI( 59 Services.io.newURI("https://example1025.example.com") 60 ) 61 ); 62 ok( 63 !siteSecurityService.isSecureURI( 64 Services.io.newURI("https://example9000.example.com") 65 ) 66 ); 67 ok( 68 !siteSecurityService.isSecureURI( 69 Services.io.newURI("https://example99999.example.com") 70 ) 71 ); 72 }