Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
import assert from "node:assert/strict";
import test from "node:test";
import { escapeHtml, htmlFor } from "../scripts/html.mjs";
test("escapeHtml encodes text and attribute metacharacters", () => {
assert.equal(
escapeHtml(`Tom & <friends> say "hello" and 'goodbye'`),
"Tom & <friends> say "hello" and 'goodbye'",
);
});
test("htmlFor escapes every catalog-derived or generated interpolation", () => {
const html = htmlFor(
{
framework: `rea"ct&<`,
family: `forms"><script>bad()</script>&'`,
title: `A </title><script>bad()</script> & "'`,
},
`./entry.mjs?value=<bad>"e="'`,
);
assert.match(
html,
/<title>A <\/title><script>bad\(\)<\/script> & "'<\/title>/,
);
assert.match(html, /data-fixture-framework="rea"ct&<"/);
assert.match(
html,
/data-fixture-family="forms"><script>bad\(\)<\/script>&'"/,
);
assert.match(
html,
/src="\.\/entry\.mjs\?value=<bad>&quote="'"/,
);
assert.doesNotMatch(html, /<script>bad\(\)<\/script>/);
});
test("htmlFor keeps the Angular host element", () => {
assert.match(
htmlFor(
{ framework: "angular", family: "components", title: "Angular fixture" },
"./entry.mjs",
),
/<smoke-root><\/smoke-root>/,
);
});