test_sts_preloadlist_selfdestruct.js (1175B)
1 "use strict"; 2 3 function run_test() { 4 let SSService = Cc["@mozilla.org/ssservice;1"].getService( 5 Ci.nsISiteSecurityService 6 ); 7 let uri = Services.io.newURI("https://includesubdomains.preloaded.test"); 8 9 // check that a host on the preload list is identified as an sts host 10 ok(SSService.isSecureURI(uri)); 11 12 let longUri = Services.io.newURI( 13 "https://a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.includesubdomains.preloaded.test" 14 ); 15 16 // hostname is too long, so it shouldn't be considered secure 17 ok(!SSService.isSecureURI(longUri)); 18 19 // now simulate that it's 19 weeks later than it actually is 20 let offsetSeconds = 19 * 7 * 24 * 60 * 60; 21 Services.prefs.setIntPref("test.currentTimeOffsetSeconds", offsetSeconds); 22 23 // check that the preloaded host is no longer considered sts 24 ok(!SSService.isSecureURI(uri)); 25 26 // just make sure we can get everything back to normal 27 Services.prefs.clearUserPref("test.currentTimeOffsetSeconds"); 28 ok(SSService.isSecureURI(uri)); 29 }