Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Openjdk/test/jdk/java/io/   (Sun/Oracle ©)  Datei vom 13.11.2022 mit Größe 1 kB image not shown  

Quelle  browser_status_code.js   Sprache: JAVA

 

/* Any copyright is dedicated to the Public Domain.
   https://creativecommons.org/publicdomain/zero/1.0/ */


"use strict";

const TEST_PATH = getRootDirectory(gTestPath).replace(
  "chrome://mochitests/content",
  // eslint-disable-next-line @microsoft/sdl/no-insecure-url
  "http://example.com"
);

async function runTest(code, hasBody) {
  const url = `${TEST_PATH}file_status_code.sjs?code=${code}&body=${hasBody ? "1" : "0"}`;
  const desc = `${code} ${hasBody ? "with" : "without"} body`;

  const tab = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    "about:blank"
  );
  const browser = tab.linkedBrowser;

  const loaded = Promise.race([
    BrowserTestUtils.waitForErrorPage(browser),
    BrowserTestUtils.browserLoaded(browser),
  ]);
  BrowserTestUtils.startLoadingURIString(browser, url);
  await loaded;

  is(browser.currentURI.scheme, "https", `Should remain on HTTPS for ${desc}`);

  await SpecialPowers.spawn(
    browser,
    [code, hasBody],
    async function (statusCode, withBody) {
      const innerHTML = content.document.body.innerHTML;
      ok(
        !innerHTML.includes("about-httpsonly-title-alert"),
        `Should not show HTTPS-Only error page for ${statusCode}`
      );
      if (withBody) {
        ok(
          innerHTML.includes(`status=${statusCode}`),
          `Should show response body for ${statusCode}`
        );
      }
    }
  );

  BrowserTestUtils.removeTab(tab);
}

add_task(async function test_status_code() {
  await SpecialPowers.pushPrefEnv({
    set: [["dom.security.https_only_mode", true]],
  });

  for (const code of [200, 400, 404, 500, 503]) {
    await runTest(code, true);
    await runTest(code, false);
  }
});

Messung V0.5 in Prozent
C=93 H=93 G=92

¤ Dauer der Verarbeitung: 0.27 Sekunden  (vorverarbeitet am  2026-10-11) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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.