Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/netwerk/test/unit/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  test_port_remapping.js   Sprache: JAVA

 
// This test is checking the `network.socket.forcePort` preference has an effect.
// We remap an ilusional port `8765` to go to the port the server actually binds to.

"use strict";

const { HttpServer } = ChromeUtils.importESModule(
  "resource://testing-common/httpd.sys.mjs"
);

function make_channel(url) {
  return NetUtil.newChannel({ uri: url, loadUsingSystemPrincipal: true });
}

const REMAPPED_PORT = 8765;

add_task(async function check_protocols() {
  function contentHandler(metadata, response) {
    let responseBody = "The server should never return this!";
    response.setHeader("Content-Type""text/plain");
    response.bodyOutputStream.write(responseBody, responseBody.length);
  }

  const httpserv = new HttpServer();
  httpserv.registerPathHandler("/content", contentHandler);
  httpserv.start(-1);

  do_get_profile();
  Services.prefs.setCharPref(
    "network.socket.forcePort",
    `${REMAPPED_PORT}=${httpserv.identity.primaryPort}`
  );

  function get_response() {
    return new Promise(resolve => {
      const URL = `http://localhost:${REMAPPED_PORT}/content`;
      const channel = make_channel(URL);
      channel.asyncOpen(
        new ChannelListener((request, data) => {
          resolve(data);
        })
      );
    });
  }

  // We expect "Bad request" from the test server because the server doesn't
  // have identity for the remapped port. We don't want to add it too, because
  // that would not prove we actualy remap the port number.
  Assert.equal(await get_response(), "Bad request\n");
  await new Promise(resolve => httpserv.stop(resolve));
});

Messung V0.5
C=98 H=100 G=98

¤ Dauer der Verarbeitung: 0.13 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.