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_type_error(callback) {
let thrown = null;
try {
callback();
} catch (error) {
thrown = error;
}
assert_true(thrown instanceof TypeError, "expected TypeError");
}
function assert_throws_name(expectedName, callback) {
let thrown = null;
try {
callback();
} catch (error) {
thrown = error;
}
assert_true(!!thrown, "expected exception");
assert_equals(thrown.name, expectedName);
}
function test_substring_data(create, type) {
test(function() {
const node = create();
assert_throws_type_error(function() { node.substringData(); });
assert_throws_type_error(function() { node.substringData(0); });
}, type + ".substringData() requires two arguments");
test(function() {
const node = create();
assert_equals(node.substringData(0, 1, "ignored"), "t");
assert_equals(node.substringData(0, 0), "");
assert_equals(node.substringData(0, 4), "test");
assert_equals(node.substringData(2, 20), "st");
assert_equals(node.substringData(4, 1), "");
}, type + ".substringData() handles in-bounds offset and count");
test(function() {
const node = create();
assert_throws_name("IndexSizeError", function() { node.substringData(5, 0); });
assert_throws_name("IndexSizeError", function() { node.substringData(-1, 0); });
}, type + ".substringData() rejects offsets beyond length after conversion");
test(function() {
const node = create();
assert_equals(node.substringData(0x100000000 + 2, 1), "s");
assert_equals(node.substringData(-0x100000000 + 2, 1), "s");
assert_equals(node.substringData(0, -1), "test");
assert_equals(node.substringData("test", 3), "tes");
}, type + ".substringData() uses unsigned long conversion");
test(function() {
const node = create();
node.data = "This is the character data test, other \u8cc7\u6599\uff0c\u66f4\u591a\u6587\u5b57";
assert_equals(node.substringData(12, 4), "char");
assert_equals(node.substringData(39, 2), "\u8cc7\u6599");
}, type + ".substringData() handles non-ASCII data");
test(function() {
const node = create();
node.data = "\ud83c\udf20 test \ud83c\udf20 TEST";
assert_equals(node.substringData(5, 8), "st \ud83c\udf20 TE");
}, type + ".substringData() counts UTF-16 code units");
}
test_substring_data(function() { return document.createTextNode("test"); }, "Text");
test_substring_data(function() { return document.createComment("test"); }, "Comment");
</script>