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) {
try {
callback();
} catch (error) {
assert_equals(error.name, expectedName, description);
return;
}
throw new Error(description || "expected exception");
}
function touch(identifier, target) {
return new Touch({ identifier, target });
}
test(function () {
const target = document.createElement("div");
const first = touch(1, target);
const second = touch(2, target);
const event = new TouchEvent("touchstart", {
touches: [first, second],
targetTouches: [first],
changedTouches: [second],
});
assert_true(event instanceof TouchEvent);
assert_true(event.touches instanceof TouchList);
assert_true(event.targetTouches instanceof TouchList);
assert_true(event.changedTouches instanceof TouchList);
assert_equals(Object.prototype.toString.call(event.touches), "[object TouchList]");
assert_equals(event.touches.length, 2);
assert_equals(event.targetTouches.length, 1);
assert_equals(event.changedTouches.length, 1);
assert_equals(event.touches.item(0), first);
assert_equals(event.touches.item(1), second);
assert_equals(event.touches.item(2), null);
}, "TouchEvent exposes TouchList instances from its init dictionary");
test(function () {
const target = document.createElement("div");
const first = touch(1, target);
const second = touch(2, target);
const list = new TouchEvent("touchstart", {
touches: [first, second],
}).touches;
assert_equals(list.item(-1), null, "wrapped negative index should return null when out of range");
assert_throws_name("TypeError", () => list.item(), "TouchList.item() should require its index argument");
assert_equals(list.item(undefined), first, "explicit undefined should convert to zero");
assert_equals(list.item(null), first, "null should convert to zero");
assert_equals(list.item("1.9"), second, "string decimals should truncate through unsigned long conversion");
assert_equals(list.item(NaN), first, "NaN should convert to zero");
assert_equals(list.item(Infinity), first, "Infinity should convert to zero");
assert_equals(list.item(-4294967295), second, "negative values should wrap through unsigned long conversion");
assert_equals(list.item(4294967297), second, "large values should wrap through unsigned long conversion");
assert_equals(
list.item({
valueOf() { return {}; },
toString() { return "1"; },
}),
second,
"object values should fall back to toString during unsigned long conversion",
);
assert_throws_name("Error", () => {
list.item({ valueOf() { throw new Error("item conversion failed"); } });
}, "TouchList.item() should propagate object conversion exceptions");
assert_throws_name("TypeError", () => list.item(Symbol("index")), "TouchList.item() should reject Symbol conversion");
assert_throws_name("TypeError", () => list.item(1n), "TouchList.item() should reject BigInt conversion");
}, "TouchList.item() uses WebIDL unsigned long conversion");
</script>