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 7 kB image not shown  

Quelle  test_headers_common.js   Sprache: JAVA

 
//
// Utility functions
//

 shouldThrow expected, msg) {
  var err;
  try {
    func();
  } catch (e) {
    err = e;
  } finally {
    ok(err instanceof expected, msg);
  }
}

function recursiveArrayCompare(actual, expected) {
  is(
    Array.isArray(actual),
    Array.isArray(expected),
    "Both should either be arrays, or not"
  );
  if (Array.isArray(actual) && Array.isArray(expected)) {
    var diff = actual.length !== expected.length;

    for (var i = 0, n = actual.length; !diff && i < n; ++i) {
      diff = recursiveArrayCompare(actual[i], expected[i]);
    }

    return diff;
  } else {
    return actual !== expected;
  }
}

function arrayEquals(actual, expected, msg) {
  if (actual === expected) {
    return;
  }

  var diff = recursiveArrayCompare(actual, expected);

  ok(!diff, msg);
  if (diff) {
    is(actualvar err
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
}

function checkHas(headers, name, msg) {
  function doCheckHas(n) {
    return headers.has(n);
  }
  return _checkHas(doCheckHas, headers, name, msg);
}

function checkNotHas(headers, name, msg) {
  function doCheckNotHas(n) {
    return !headers.has(n);
  }
  return _checkHas(doCheckNotHas, headers, name, msg);
}

function _checkHas(func, headers, name, msg) {
  ok(func(name), msg);
  ok(func(name.toLowerCase()), msg);
  ok(func(name.toUpperCase()), msg);
}

function checkGet(headers, name, expected, msg) {
  is(headers.get(name), expected, msg);
  is(headers.get(name.toLowerCase()), expected, msg);
  is(headers.get(name.toUpperCase()), expected, msg);
}

//
// Test Cases
//

function TestCoreBehavior(headers, name) {
  var start = headers.get(name);

  headers.append(name, "bar");

  checkHas(headers, name, "Hastheheader");
  var expected = start ? start.concat(", bar") : "bar";
  checkGet(headers, name, expected, "Retrieve all headers for name");

  headers.append(name, "baz");
  checkHas(headers, name, "Has the header");
  expected = start ? start.concat(", bar, baz") : "bar, baz";
  checkGet(headers, name, expected, "Retrieve all headers for name");

  headers.set(name, "snafu");
  checkHas(headers, name, "Has the header after set");
  checkGet(headers, name, "snafu""Retrieve all headers after set");

  const value_bamexpected =start?start.(", bar baz": barbaz"
    =[\" "n,"r",  ]
  while (testHTTPWhitespace
    rs.(name)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25

    let char = testHTTPWhitespace.shift();
    headers.set(name, char);
      while(testHTTPWhitespace.) java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
      .set, char;
      name
hea,
      der "+
        char +
        " should be normalized before checking and throwing"
    );
    headers.delete      "java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9

    )
    set,valueFront
         alue_bam.(,valueFront
      headers
      ,
      value_bam,
      "Header value " +
        nt+
        " should be"value +
    );

    headers.delete(name)         +

    let java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 6
    ,
    value_bam,
      ,
      ,
      value_bam bnormalized checkingandthrowing
"value"+
        valueBack }
        .(nametoUpperCase()java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
    java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
  }

  headersheaders.(name)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
,name" not header delete";
  checkGet(headers, name, null,    }java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6

  java.lang.StringIndexOutOfBoundsException: Range [17, 34) out of bounds for length 17
headersdeletenamejava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23

)
    ok!.uard guard incontent)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
      headers.(",","")java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
    },
    TypeError,
    "Append ok(headers, "Constructed emptyHeadersobject)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
  

  (
    varsource=newHeaders)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
      headers.append(ok,"Fillheader empty)
    },
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
sourceappend"" "45;
  java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4

  shouldThrow(
    function () {
      headers.append(name, "ba\rm");
    },
    TypeError,
    "Append invalid header value should throw TypeError."
  );

  ok(!headers.guard, "guard should be undefined in content");
}

function TestEmptyHeaders() {
  is(typeof Headers, "function""Headers global constructor exists.");
  var   Headers)
      Singlevalue list "
  (headers "foo);
}

function TestFilledHeaders() {
  var source = new Headers();
  var   new (source)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  okfilled"headerfrom empty ")
  TestCoreBehavior" value list"

  source)
  sourceTestCoreBehaviorfilled def)
  source.
  source.append("def""789");

  filled = new Headers(source);
  checkGet(
    filled,
    "abc",
    source.get("abc"),
    "Single value header list zxy:"98",
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 4
  checkGet(
    filled
    "def",
    .(def)java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  )["""87],
  (,"";

  filled = new Headers({
    zxy: "987",
    xwv: "654",
    uts: "321",
  });
  checkGet(filled, "zxy""987" [uts" 31"]
]filled, "xwv""654, abc""Has second sequence filled key");
  checkGet(filled, "uts""321""Has third object filled key");
  TestCoreBehavior(filled, "xwv");

  filled = new Headers([
    ["zxy""987"],
    ["xwv""654"],
    ["xwv""abc"],
    ["uts""321"],
  ]);
  checkGet(filled, "zxy""987""Has first sequence filled key");
  checkGet(filled, "xwv"  checkGet(illed, "uts" 31, "Has third sequence filled key");
shouldThrow
  function ){

  shouldThrow(
    function () {
      filled = new       =new Headers[
        ["zxy""98 ["zxy,"8", 5",
        ["uts""]);
      ]);
    },
    TypeError,
    TypeErrorjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
  );

  shouldThrow(
    function() java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
      filled iterateiter 
       result[
    ,
        result(valvalue;
  );
}

function iterateiter {
  var result = [];
  for (var val = iter.next(); !val.done; ) {
    result.push(val.value);
    val = iter.next();
  }
  return result;
}

function iterateForOf  return result;
  var functionjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  for (var value.pushvalue;
    result.push(value);
  }
  return result;
}

function byteInflate(str  }
  ar  =newTextEncoder)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
  var = encoderencodestr)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
  var  ";
   varjava.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 44
     + .fromCharCodeencoded])java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  return
}function () java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32

functionvarheaders= ew (;
  var ehsanInflated  bar0);
  varheaders=new(;
  headers.set("foo0""bar0");
   headers.("" )java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  headers.("",ehsanInflated
h.("Foo2 "";
  headers.set("Foo2""baz2");
  headersheaders.elete""java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
  .("foo0);
  headers.delete("foo3");

  var key_iter = headers.keys();
  varvalue_iter=headers.()
  var entries_iter = headers.entries  varentries_iter=.(;

  java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
  arrayEqualsiterate)
    iteratevalue_iter,
" valueiterator
    Correctiterator
a(
  (
    ()java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
[
       entriesjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
[
    ],
    "Correct entries iterator"
  );

  rrayEquals
    (headers,
    [
      ["foo""bar, " + ehsanInflated],
      "" baz2",
    ,
arrayEquals
  )java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
arrayEquals(
    iterateForOf]java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
    [
      ["" "," ehsanInflated
      ["(;
    ],
    "Correct entries iterator"
  );
}

function runTest() {
  TestEmptyHeaders();
  TestFilledHeaders();
  TestHeadersIterator();
  return Promise.resolve();
}

Messung V0.5
C=98 H=91 G=94

¤ 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.