tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_sts_fqdn.js (1299B)


      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 */
      5 "use strict";
      6 
      7 function run_test() {
      8  let SSService = Cc["@mozilla.org/ssservice;1"].getService(
      9    Ci.nsISiteSecurityService
     10  );
     11  let uri = Services.io.newURI("https://example.com");
     12  let uri1 = Services.io.newURI("https://example.com.");
     13  let uri2 = Services.io.newURI("https://example.com..");
     14  ok(!SSService.isSecureURI(uri));
     15  ok(!SSService.isSecureURI(uri1));
     16  // These cases are only relevant as long as bug 1118522 hasn't been fixed.
     17  ok(!SSService.isSecureURI(uri2));
     18 
     19  SSService.processHeader(uri, "max-age=1000;includeSubdomains");
     20  ok(SSService.isSecureURI(uri));
     21  ok(SSService.isSecureURI(uri1));
     22  ok(SSService.isSecureURI(uri2));
     23 
     24  SSService.resetState(uri);
     25  ok(!SSService.isSecureURI(uri));
     26  ok(!SSService.isSecureURI(uri1));
     27  ok(!SSService.isSecureURI(uri2));
     28 
     29  // Somehow creating this malformed URI succeeds - we need to handle it
     30  // gracefully.
     31  uri = Services.io.newURI("https://../foo");
     32  equal(uri.host, "..");
     33  throws(
     34    () => {
     35      SSService.isSecureURI(uri);
     36    },
     37    /NS_ERROR_UNEXPECTED/,
     38    "Malformed URI should be rejected"
     39  );
     40 }