Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

1.6 KB
Raw Blame
<!doctype html>
<meta charset="utf-8">
<script src="/wpt/resources/testharness.js"></script>
<script src="/wpt/resources/testharnessreport.js"></script>
<script src="/wpt/resources/moli-wpt-adapter.js"></script>
<script>
test(function () {
  const headers = new Headers([
    ["X-B", "two"],
    ["x-a", "one"],
    ["X-B", "three"],
  ]);
  assert_array_equals(Array.from(headers.keys()), ["x-a", "x-b"]);
  assert_array_equals(Array.from(headers.values()), ["one", "two, three"]);
  assert_array_equals(Array.from(headers.entries()).map(pair => pair.join(":")), ["x-a:one", "x-b:two, three"]);

  const seen = [];
  headers.forEach(function (value, key, object) {
    assert_true(object === headers);
    seen.push(key + ":" + value);
  });
  assert_array_equals(seen, ["x-a:one", "x-b:two, three"]);
}, "Headers exposes iterable keys, values, entries, and forEach");

test(function () {
  const iterator = new Headers([
    ["x-a", "one"],
    ["x-b", "two"],
  ]).entries();
  assert_array_equals(iterator.next().value, ["x-a", "one"]);
  assert_false("__lmHeadersIteratorTarget" in iterator);
  assert_false("__lmHeadersIteratorIndex" in iterator);
  assert_false("__lmHeadersIteratorKind" in iterator);
  assert_false(Object.keys(iterator).includes("__lmHeadersIteratorIndex"));

  iterator.__lmHeadersIteratorTarget = null;
  iterator.__lmHeadersIteratorIndex = -100;
  iterator.__lmHeadersIteratorKind = "keys";

  assert_array_equals(iterator.next().value, ["x-b", "two"]);
  assert_true(iterator.next().done);
}, "Headers iterator internal state is hidden from JS properties");
</script>