Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/security/manager/ssl/tests/unit/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 3 kB image not shown  

Quelle  test_sss_resetState.js   Sprache: JAVA

 
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

"use strict";

// Tests that resetting HSTS state in the way the "forget about this site"
// functionality does works as expected for preloaded and non-preloaded sites.

do_get_profile();

var gSSService = Cc["@mozilla.org/ssservice;1"].getService(
  Ci.nsISiteSecurityService
);

function test_removeState(originAttributes) {
  info(`running test_removeState(originAttributes=${originAttributes})`);
  // Simulate visiting a non-preloaded site by processing an HSTS header check
  // that the HSTS bit gets set, simulate "forget about this site" (call
  // removeState), and then check that the HSTS bit isn't set.
  let notPreloadedURI = Services.io.newURI("https://not-preloaded.example.com");
  ok(!gSSService.isSecureURI(notPreloadedURI, originAttributes));
  gSSService.processHeader(notPreloadedURI, "max-age=1000;", originAttributes);
  ok(gSSService.isSecureURI(notPreloadedURI, originAttributes));
  gSSService.resetState(notPreloadedURI, originAttributes);
  ok(!gSSService.isSecureURI(notPreloadedURI, originAttributes));

  // Simulate visiting a non-preloaded site that unsets HSTS by processing
  // an HSTS header with "max-age=0", check that the HSTS bit isn't
  // set, simulate "forget about this site" (call removeState), and then check
  // that the HSTS bit isn't set.
  gSSService.processHeader(notPreloadedURI, "max-age=0;", originAttributes);
  ok(!gSSService.isSecureURI(notPreloadedURI, originAttributes));
  gSSService.resetState(notPreloadedURI, originAttributes);
  ok(!gSSService.isSecureURI(notPreloadedURI, originAttributes));

  // Simulate visiting a preloaded site by processing an HSTS header, check
  // that the HSTS bit is still set, simulate "forget about this site"
  // (call removeState), and then check that the HSTS bit is still set.
  let preloadedHost = "includesubdomains.preloaded.test";
  let preloadedURI = Services.io.newURI(`https://${preloadedHost}`);
  ok(gSSService.isSecureURI(preloadedURI, originAttributes));
  gSSService.processHeader(preloadedURI, "max-age=1000;", originAttributes);
  ok(gSSService.isSecureURI(preloadedURI, originAttributes));
  gSSService.resetState(preloadedURI, originAttributes);
  ok(gSSService.isSecureURI(preloadedURI, originAttributes));

  // Simulate visiting a preloaded site that unsets HSTS by processing an
  // HSTS header with "max-age=0", check that the HSTS bit is what we
  // expect (see below), simulate "forget about this site" (call removeState),
  // and then check that the HSTS bit is set.
  gSSService.processHeader(preloadedURI, "max-age=0;", originAttributes);
  ok(!gSSService.isSecureURI(preloadedURI, originAttributes));
  gSSService.resetState(preloadedURI, originAttributes);
  ok(gSSService.isSecureURI(preloadedURI, originAttributes));
}

function run_test() {
  test_removeState({});
  test_removeState({ privateBrowsingId: 1 });
}

Messung V0.5
C=70 H=100 G=86

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.