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>
function next_message(worker) {
return new Promise(function (resolve, reject) {
worker.addEventListener("message", resolve, { once: true });
worker.addEventListener("error", function (event) {
reject(new Error(event.message || "worker error"));
}, { once: true });
});
}
promise_test(async function () {
const workerUrl = new URL(
"/wpt/ported/worker/resources/worker-fetch-abort.js",
location.href,
).href;
const targetUrl = new URL("/wpt/runtime/xhr/slow", location.href).href;
const worker = new Worker(workerUrl);
try {
worker.postMessage({ mode: "preaborted", targetUrl: targetUrl });
const message = await next_message(worker);
assert_equals(message.data.mode, "preaborted", "worker should report the preaborted mode");
assert_equals(message.data.name, "AbortError", "preaborted fetch should reject with AbortError");
assert_equals(
message.data.message,
"The operation was aborted.",
"preaborted fetch should keep the AbortError message",
);
assert_true(message.data.isDomException, "preaborted fetch should reject with DOMException");
} finally {
worker.terminate();
}
}, "Dedicated workers reject fetch() when given a pre-aborted AbortSignal");
promise_test(async function () {
const workerUrl = new URL(
"/wpt/ported/worker/resources/worker-fetch-abort.js",
location.href,
).href;
const targetUrl = new URL("/wpt/runtime/xhr/slow", location.href).href;
const worker = new Worker(workerUrl);
try {
worker.postMessage({ mode: "preaborted-custom-reason", targetUrl: targetUrl });
const message = await next_message(worker);
assert_equals(
message.data.mode,
"preaborted-custom-reason",
"worker should report the preaborted-custom-reason mode",
);
assert_true(message.data.sameReason, "pre-aborted fetch should reject with signal.reason");
assert_equals(message.data.name, "Error", "custom reason error name");
assert_equals(message.data.message, "worker custom preabort reason", "custom reason message");
assert_false(message.data.isDomException, "custom Error reason should not be replaced");
} finally {
worker.terminate();
}
}, "Dedicated workers reject pre-aborted custom reasons with signal.reason");
promise_test(async function () {
const workerUrl = new URL(
"/wpt/ported/worker/resources/worker-fetch-abort.js",
location.href,
).href;
const targetUrl = new URL("/wpt/runtime/xhr/slow", location.href).href;
const worker = new Worker(workerUrl);
try {
worker.postMessage({ mode: "inflight-abort", targetUrl: targetUrl });
const message = await next_message(worker);
assert_equals(
message.data.mode,
"inflight-abort",
"worker should report the inflight-abort mode",
);
assert_array_equals(
message.data.events,
["error:AbortError:true:The operation was aborted."],
"aborting an in-flight worker fetch should reject once and ignore the late completion",
);
} finally {
worker.terminate();
}
}, "Dedicated workers reject in-flight fetch() aborts and ignore late completion");
promise_test(async function () {
const workerUrl = new URL(
"/wpt/ported/worker/resources/worker-fetch-abort.js",
location.href,
).href;
const targetUrl = new URL("/wpt/runtime/xhr/slow", location.href).href;
const worker = new Worker(workerUrl);
try {
worker.postMessage({ mode: "inflight-custom-reason", targetUrl: targetUrl });
const message = await next_message(worker);
assert_equals(
message.data.mode,
"inflight-custom-reason",
"worker should report the inflight-custom-reason mode",
);
assert_true(message.data.sameReason, "in-flight fetch should reject with signal.reason");
assert_equals(message.data.kind, "worker-custom-inflight-reason", "custom object reason");
assert_false(message.data.isDomException, "custom object reason should not be replaced");
} finally {
worker.terminate();
}
}, "Dedicated workers reject in-flight custom reasons with signal.reason");
promise_test(async function () {
const workerUrl = new URL(
"/wpt/ported/worker/resources/worker-fetch-abort.js",
location.href,
).href;
const targetUrl = new URL(
"/wpt/ported/worker/resources/fetch-target.js",
location.href,
).href;
const worker = new Worker(workerUrl);
try {
worker.postMessage({ mode: "null-signal-override", targetUrl: targetUrl });
const message = await next_message(worker);
assert_equals(
message.data.mode,
"null-signal-override",
"worker should report the null-signal-override mode",
);
assert_equals(message.data.error, undefined, "signal: null should not reject");
assert_equals(message.data.status, 200, "signal: null fetch status");
assert_equals(
message.data.text,
"hello from worker fetch",
"signal: null should clear an inherited aborted Request signal",
);
} finally {
worker.terminate();
}
}, "Dedicated worker fetch(request, { signal: null }) clears an inherited Request signal");
</script>