Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
<!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 src="/wpt/runtime/fixture-server-config.js"></script>
<script>
const WORKER_URL = new URL(
"/wpt/ported/worker/resources/worker-fetch-credentials-streaming-worker.js",
location.href,
).href;
function alternate_url(path) {
return location.protocol + "//" + location.hostname + ":" + __lmFixtureServerConfig.alternatePort + path;
}
function streaming_path(mode, operation) {
return `/wpt/runtime/fetch/credentials/streaming/${mode}/${operation}`;
}
function next_worker_message(worker, expectedKind) {
return new Promise(function (resolve, reject) {
function cleanup() {
worker.removeEventListener("message", onmessage);
worker.removeEventListener("error", onerror);
}
function onmessage(event) {
if (!event.data || event.data.kind !== expectedKind) {
return;
}
cleanup();
resolve(event.data);
}
function onerror(event) {
cleanup();
reject(event.error || new Error(event.message || "worker error"));
}
worker.addEventListener("message", onmessage);
worker.addEventListener("error", onerror, { once: true });
});
}
async function run_worker_case(kind, setUrl, checkUrl, credentials) {
const worker = new Worker(WORKER_URL);
try {
worker.postMessage({ kind, setUrl, checkUrl, credentials });
const message = await next_worker_message(worker, kind);
assert_equals(message.error, undefined, "worker fetch should not reject");
assert_equals(message.status, 200, "worker streaming fetch response status");
return message;
} finally {
worker.terminate();
}
}
promise_test(async function () {
const message = await run_worker_case(
"include",
alternate_url(streaming_path("include", "set")),
alternate_url(streaming_path("include", "check")),
"include",
);
assert_equals(
message.beforeBody,
"streaming-include-response-cookie=seen",
"worker credentialed streaming response Set-Cookie should commit before body completion",
);
assert_equals(
message.body,
"streaming-include-response-cookie=head-tail",
"worker credentialed streaming response body should remain readable",
);
assert_equals(
message.afterBody,
"streaming-include-response-cookie=seen",
"worker credentialed streaming response Set-Cookie should stay committed after body completion",
);
}, "Dedicated worker fetch credentials=include stores streaming cross-origin response cookies before body completion");
promise_test(async function () {
const message = await run_worker_case(
"default",
alternate_url(streaming_path("default", "set")),
alternate_url(streaming_path("default", "check")),
);
assert_equals(
message.beforeBody,
"streaming-default-response-cookie=missing",
"worker default cross-origin streaming response Set-Cookie should not commit before body completion",
);
assert_equals(
message.body,
"streaming-default-response-cookie=head-tail",
"worker default streaming response body should still complete",
);
assert_equals(
message.afterBody,
"streaming-default-response-cookie=missing",
"worker default cross-origin streaming response Set-Cookie should remain ignored after body completion",
);
}, "Dedicated worker fetch default credentials ignores streaming cross-origin response cookies");
promise_test(async function () {
const message = await run_worker_case(
"omit",
streaming_path("omit", "set"),
streaming_path("omit", "check"),
"omit",
);
assert_equals(
message.beforeBody,
"streaming-omit-response-cookie=missing",
"worker same-origin streaming response Set-Cookie should not commit when credentials=omit",
);
assert_equals(
message.body,
"streaming-omit-response-cookie=head-tail",
"worker omit streaming response body should still complete",
);
assert_equals(
message.afterBody,
"streaming-omit-response-cookie=missing",
"worker credentials=omit should keep ignoring Set-Cookie after body completion",
);
}, "Dedicated worker fetch credentials=omit ignores streaming same-origin response cookies");
</script>