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>
promise_test(async function () {
const order = [];
let committed = false;
let finished = false;
let committedValue = null;
let finishedValue = null;
addEventListener("popstate", function () {
order.push("popstate:" + location.hash);
});
addEventListener("hashchange", function () {
order.push("hashchange:" + location.hash);
});
navigation.addEventListener("currententrychange", function (event) {
order.push("cec:" + String(event.navigationType) + ":" + location.hash);
});
history.replaceState({ base: 1 }, "", "#base");
const result = navigation.navigate(location.pathname + "#dest", {
history: "push",
state: { step: 1 },
});
result.committed.then(function (entry) {
committed = true;
committedValue = entry;
order.push("committed:" + location.hash);
});
result.finished.then(function (entry) {
finished = true;
finishedValue = entry;
order.push("finished:" + location.hash);
});
assert_equals(location.hash, "#dest", "navigate() should synchronously update location.hash");
assert_false(committed, "committed should stay pending at the synchronous call boundary");
assert_false(finished, "finished should stay pending at the synchronous call boundary");
assert_array_equals(
order,
["cec:replace:#base", "cec:push:#dest", "popstate:#dest"],
"same-document navigate() should dispatch currententrychange and popstate before hashchange",
);
assert_equals(
Object.keys(result).join(","),
"committed,finished",
"result should only expose committed and finished enumerable keys",
);
assert_equals(
Object.getOwnPropertyNames(result).join(","),
"committed,finished",
"result should only expose committed and finished own properties",
);
await new Promise(function (resolve) {
setTimeout(resolve, 0);
});
assert_true(committed, "committed should settle before the next macrotask completes");
assert_true(finished, "finished should settle before the next macrotask completes");
assert_array_equals(
order,
[
"cec:replace:#base",
"cec:push:#dest",
"popstate:#dest",
"committed:#dest",
"finished:#dest",
"hashchange:#dest",
],
"committed and finished should settle before the hashchange task",
);
assert_equals(
Object.prototype.toString.call(committedValue),
"[object NavigationHistoryEntry]",
"committed should resolve to a NavigationHistoryEntry",
);
assert_equals(
Object.prototype.toString.call(finishedValue),
"[object NavigationHistoryEntry]",
"finished should resolve to a NavigationHistoryEntry",
);
assert_equals(
committedValue?.url,
navigation.currentEntry?.url,
"committed should resolve to the new currentEntry",
);
assert_equals(
finishedValue?.url,
navigation.currentEntry?.url,
"finished should resolve to the new currentEntry",
);
assert_true(
committedValue === navigation.currentEntry,
"committed should resolve with the same currentEntry object",
);
assert_true(
finishedValue === navigation.currentEntry,
"finished should resolve with the same currentEntry object",
);
}, "top-level same-document navigation.navigate() result promises settle around hashchange");
</script>