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 assert_throws_name(expectedName, callback, description) {
let error = null;
try {
callback();
} catch (thrown) {
error = thrown;
}
assert_true(error !== null, (description || "assert_throws_name") + ": expected an exception");
assert_equals(error.name, expectedName, (description || "assert_throws_name") + ": unexpected exception name");
}
test(function () {
const div = document.createElement("div");
const input = document.createElement("input");
const button = document.createElement("button");
const select = document.createElement("select");
const textarea = document.createElement("textarea");
const anchor = document.createElement("a");
assert_equals(div.tabIndex, -1, "non-focusable elements should default to -1");
assert_equals(input.tabIndex, 0, "input should default to 0");
assert_equals(button.tabIndex, 0, "button should default to 0");
assert_equals(select.tabIndex, 0, "select should default to 0");
assert_equals(textarea.tabIndex, 0, "textarea should default to 0");
assert_equals(anchor.tabIndex, 0, "anchor should default to 0");
}, "HTMLElement.tabIndex exposes default focusability values");
test(function () {
const div = document.createElement("div");
div.setAttribute("tabindex", "");
assert_equals(div.tabIndex, -1, "empty tabindex should fall back to default");
div.setAttribute("tabindex", " 5abc");
assert_equals(div.tabIndex, 5, "tabIndex getter should parse leading integer text");
div.setAttribute("tabindex", "+6trail");
assert_equals(div.tabIndex, 6, "tabIndex getter should allow a leading plus sign");
div.setAttribute("tabindex", "-7trail");
assert_equals(div.tabIndex, -7, "tabIndex getter should allow a leading minus sign");
div.setAttribute("tabindex", "2147483647");
assert_equals(div.tabIndex, 2147483647, "tabIndex getter should allow signed long max");
div.setAttribute("tabindex", "2147483648");
assert_equals(div.tabIndex, -1, "tabIndex getter should reject values above signed long max");
div.setAttribute("tabindex", "-2147483648");
assert_equals(div.tabIndex, -2147483648, "tabIndex getter should allow signed long min");
div.setAttribute("tabindex", "-2147483649");
assert_equals(div.tabIndex, -1, "tabIndex getter should reject values below signed long min");
}, "HTMLElement.tabIndex parses the tabindex content attribute as a signed integer");
test(function () {
const div = document.createElement("div");
div.tabIndex = "1.9";
assert_equals(div.tabIndex, 1, "tabIndex setter should truncate string numbers through WebIDL long conversion");
assert_equals(div.getAttribute("tabindex"), "1", "tabIndex setter should reflect normalized integers");
div.tabIndex = NaN;
assert_equals(div.tabIndex, 0, "tabIndex setter should convert NaN to zero");
assert_equals(div.getAttribute("tabindex"), "0", "NaN should reflect as zero");
div.tabIndex = Infinity;
assert_equals(div.tabIndex, 0, "tabIndex setter should convert Infinity to zero");
div.tabIndex = -2.7;
assert_equals(div.tabIndex, -2, "tabIndex setter should preserve negative signed long values");
assert_equals(div.getAttribute("tabindex"), "-2", "negative tabIndex should reflect the converted value");
div.tabIndex = 4_294_967_297;
assert_equals(div.tabIndex, 1, "tabIndex setter should preserve WebIDL long wrapping");
div.tabIndex = {
valueOf() { return {}; },
toString() { return "3"; },
};
assert_equals(div.tabIndex, 3, "tabIndex setter should fall back to object toString conversion");
assert_throws_name("Error", function () {
div.tabIndex = { valueOf() { throw new Error("tabIndex conversion failed"); } };
}, "tabIndex setter should propagate object conversion exceptions");
assert_equals(div.tabIndex, 3, "failed object conversion should not mutate tabIndex");
assert_throws_name("TypeError", function () {
div.tabIndex = Symbol("tabIndex");
}, "tabIndex setter should reject Symbol conversion");
assert_equals(div.tabIndex, 3, "failed Symbol conversion should not mutate tabIndex");
assert_throws_name("TypeError", function () {
div.tabIndex = 1n;
}, "tabIndex setter should reject BigInt conversion");
assert_equals(div.tabIndex, 3, "failed BigInt conversion should not mutate tabIndex");
}, "HTMLElement.tabIndex setter follows WebIDL long conversion");
</script>