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>
async function assert_rejects_name(expectedName, promise, description) {
  try {
    await promise;
  } catch (error) {
    assert_equals(error.name, expectedName, description);
    return;
  }
  throw new Error(description || "expected rejection");
}

function assert_throws_name(expectedName, callback, description) {
  try {
    callback();
  } catch (error) {
    assert_equals(error.name, expectedName, description);
    return;
  }
  throw new Error(description || "expected exception");
}

const echoUrl = "/wpt/runtime/fetch/credentials/request-cookie/check";

promise_test(async function () {
  await assert_rejects_name(
    "TypeError",
    fetch(echoUrl, { credentials: "credentialed" }),
    "fetch() should reject invalid RequestInit.credentials",
  );
}, "fetch rejects invalid RequestInit.credentials");

test(function () {
  assert_throws_name("TypeError", function () {
    new Request(echoUrl, { credentials: "credentialed" });
  }, "Request constructor should throw for invalid credentials");
}, "Request constructor rejects invalid RequestInit.credentials");

test(function () {
  assert_equals(new Request(echoUrl, { credentials: "same-origin" }).credentials, "same-origin");
  assert_equals(new Request(echoUrl, { credentials: "include" }).credentials, "include");
  assert_equals(new Request(echoUrl, { credentials: "omit" }).credentials, "omit");
}, "Request constructor stores valid RequestInit.credentials values");
</script>