Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/tests/mochitest/fetch/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 4 kB image not shown  

Quelle  test_headers_mainthread.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/dom/tests/mochitest/fetch/test_headers_mainthread.html


<!-- Any copyright is dedicated to the Public Domain.
   - http://creativecommons.org/publicdomain/zero/1.0/ -->

<!DOCTYPE HTML>
<html>
<head>
  <title>Test Fetch Headers - Basic</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script type="text/javascript" src="test_headers_common.js"> </script>
<script type="text/javascript">
// Main thread specific tests because they need SpecialPowers.  Expects
// test_headers_common.js to already be loaded.

function TestRequestHeaders() {
  is(typeof Headers, "function""Headers global constructor exists.");
  var headers = new Headers();
  ok(headers, "Constructed empty Headers object");
  SpecialPowers.wrap(headers).guard = "request";
  TestCoreBehavior(headers, "foo");
  var forbidden = [
    "Accept-Charset",
    "Accept-Encoding",
    "Access-Control-Request-Headers",
    "Access-Control-Request-Method",
    "Connection",
    "Content-Length",
    "Cookie",
    "Cookie2",
    "Date",
    "DNT",
    "Expect",
    "Host",
    "Keep-Alive",
    "Origin",
    "Referer",
    "TE",
    "Trailer",
    "Transfer-Encoding",
    "Upgrade",
    "Via",
    "Proxy-Authorization",
    "Proxy-blarg",
    "Proxy-",
    "Sec-foo",
    "Sec-"
  ];

  for (var i = 0, n = forbidden.length; i < n; ++i) {
    var name = forbidden[i];
    headers.append(name, "hmm");
    checkNotHas(headers, name, "Should not be able to append " + name + " to request headers");
    headers.set(name, "hmm");
    checkNotHas(headers, name, "Should not be able to set " + name + " on request headers");
  }
}

function TestRequestNoCorsHeaders() {
  is(typeof Headers, "function""Headers global constructor exists.");
  var headers = new Headers();
  ok(headers, "Constructed empty Headers object");
  SpecialPowers.wrap(headers).guard = "request-no-cors";

  headers.append("foo""bar");
  checkNotHas(headers, "foo""Should not be able to append arbitrary headers to request-no-cors headers.");
  headers.set("foo""bar");
  checkNotHas(headers, "foo""Should not be able to set arbitrary headers on request-no-cors headers.");

  var simpleNames = [
    "Accept",
    "Accept-Language",
    "Content-Language"
  ];

  var simpleContentTypes = [
    "application/x-www-form-urlencoded",
    "multipart/form-data",
    "text/plain",
    "application/x-www-form-urlencoded; charset=utf-8",
    "multipart/form-data; charset=utf-8",
    "text/plain; charset=utf-8"
  ];

  for (var i = 0, n = simpleNames.length; i < n; ++i) {
    var name = simpleNames[i];
    headers.append(name, "hmm");
    checkHas(headers, name, "Should be able to append " + name + " to request-no-cors headers");
    headers.set(name, "hmm");
    checkHas(headers, name, "Should be able to set " + name + " on request-no-cors headers");
  }

  for (var i = 0, n = simpleContentTypes.length; i < n; ++i) {
    var value = simpleContentTypes[i];
    headers.append("Content-Type", value);
    checkHas(headers, "Content-Type""Should be able to append " + value + " Content-Type to request-no-cors headers");
    headers.delete("Content-Type");
    headers.set("Content-Type", value);
    checkHas(headers, "Content-Type""Should be able to set " + value + " Content-Type on request-no-cors headers");
  }
}

function TestResponseHeaders() {
  is(typeof Headers, "function""Headers global constructor exists.");
  var headers = new Headers();
  ok(headers, "Constructed empty Headers object");
  SpecialPowers.wrap(headers).guard = "response";
  TestCoreBehavior(headers, "foo");
  var forbidden = [
    "Set-Cookie",
    "Set-Cookie2"
  ];

  for (var i = 0, n = forbidden.length; i < n; ++i) {
    var name = forbidden[i];
    headers.append(name, "hmm");
    checkNotHas(headers, name, "Should not be able to append " + name + " to response headers");
    headers.set(name, "hmm");
    checkNotHas(headers, name, "Should not be able to set " + name + " on response headers");
  }
}

function TestImmutableHeaders() {
  is(typeof Headers, "function""Headers global constructor exists.");
  var headers = new Headers();
  ok(headers, "Constructed empty Headers object");
  TestCoreBehavior(headers, "foo");
  headers.append("foo""atleastone");

  SpecialPowers.wrap(headers).guard = "immutable";

  shouldThrow(function() {
    headers.append("foo""wat");
  }, TypeError, "Should not be able to append to immutable headers");

  shouldThrow(function() {
    headers.set("foo""wat");
  }, TypeError, "Should not be able to set immutable headers");

  shouldThrow(function() {
    headers.delete("foo");
  }, TypeError, "Should not be able to delete immutable headers");

  checkHas(headers, "foo""Should be able to check immutable headers");
  ok(headers.get("foo"), "Should be able to get immutable headers");
}

TestRequestHeaders();
TestRequestNoCorsHeaders();
TestResponseHeaders();
TestImmutableHeaders();
</script>
</body>
</html>


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

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