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");
}
test(function () {
const style = document.createElement("div").style;
assert_equals(Object.prototype.toString.call(style), "[object CSSStyleProperties]");
assert_true(style instanceof CSSStyleProperties);
assert_true(style instanceof CSSStyleDeclaration);
style.setProperty("color", "red");
assert_equals(style.getPropertyValue("color"), "red");
assert_equals(style.color, "red");
style.cssText = "display: block; background-color: blue !important";
assert_equals(style.getPropertyValue("display"), "block");
assert_equals(style.getPropertyValue("background-color"), "blue");
assert_equals(style.getPropertyPriority("background-color"), "important");
assert_equals(style.removeProperty("display"), "block");
assert_equals(style.getPropertyValue("display"), "");
}, "CSSStyleDeclaration supports property mutation, priority, cssText, and removeProperty");
test(function () {
const style = document.createElement("div").style;
style.cssText = "color: red; background-color: blue; margin-left: 1px";
assert_equals(style.length, 3);
assert_equals(style.item(0), "color");
assert_equals(style.item(1), "background-color");
assert_equals(style.item(3), "", "out-of-range item() should return the empty string");
assert_equals(style.item(-1), "", "wrapped negative index should return the empty string when out of range");
assert_throws_name("TypeError", () => style.item(), "item() should require its index argument");
assert_equals(style.item(undefined), "color", "explicit undefined should convert to zero");
assert_equals(style.item(null), "color", "null should convert to zero");
assert_equals(style.item("1.9"), "background-color", "string decimals should truncate through unsigned long conversion");
assert_equals(style.item(NaN), "color", "NaN should convert to zero");
assert_equals(style.item(Infinity), "color", "Infinity should convert to zero");
assert_equals(style.item(-4294967295), "background-color", "negative values should wrap through unsigned long conversion");
assert_equals(style.item(4294967297), "background-color", "large values should wrap through unsigned long conversion");
assert_equals(
style.item({
valueOf() { return {}; },
toString() { return "2"; },
}),
"margin-left",
"object values should fall back to toString during unsigned long conversion",
);
assert_throws_name("Error", () => {
style.item({ valueOf() { throw new Error("item conversion failed"); } });
}, "item() should propagate object conversion exceptions");
assert_throws_name("TypeError", () => style.item(Symbol("index")), "item() should reject Symbol conversion");
assert_throws_name("TypeError", () => style.item(1n), "item() should reject BigInt conversion");
}, "CSSStyleDeclaration item() uses WebIDL unsigned long conversion");
test(function () {
const doc = new DOMParser().parseFromString("<html><body></body></html>", "text/html");
const style = doc.createElement("div").style;
style.cssText = "color: red; background-color: blue; margin-left: 1px";
assert_equals(style.length, 3);
assert_equals(style.item(0), "color");
assert_equals(style.item(1), "background-color");
assert_equals(style.item(3), "", "out-of-range detached item() should return the empty string");
assert_equals(style.item(-1), "", "wrapped negative detached index should return the empty string when out of range");
assert_throws_name("TypeError", () => style.item(), "detached item() should require its index argument");
assert_equals(style.item(undefined), "color", "explicit undefined should convert to zero");
assert_equals(style.item(null), "color", "null should convert to zero");
assert_equals(style.item("1.9"), "background-color", "string decimals should truncate through unsigned long conversion");
assert_equals(style.item(NaN), "color", "NaN should convert to zero");
assert_equals(style.item(Infinity), "color", "Infinity should convert to zero");
assert_equals(style.item(-4294967295), "background-color", "negative values should wrap through unsigned long conversion");
assert_equals(style.item(4294967297), "background-color", "large values should wrap through unsigned long conversion");
assert_equals(
style.item({
valueOf() { return {}; },
toString() { return "2"; },
}),
"margin-left",
"object values should fall back to toString during unsigned long conversion",
);
assert_throws_name("Error", () => {
style.item({ valueOf() { throw new Error("item conversion failed"); } });
}, "detached item() should propagate object conversion exceptions");
assert_throws_name("TypeError", () => style.item(Symbol("index")), "detached item() should reject Symbol conversion");
assert_throws_name("TypeError", () => style.item(1n), "detached item() should reject BigInt conversion");
}, "Detached CSSStyleDeclaration item() uses WebIDL unsigned long conversion");
test(function () {
assert_true(CSS.supports("color", "red"));
assert_true(CSS.supports("(color: red)"));
assert_false(CSS.supports("unknown-property", "red"));
assert_false(CSS.supports("unknown-property: red"));
assert_true(CSS.supports(
{ toString() { return "color"; } },
{ toString() { return "red"; } },
));
assert_true(CSS.supports({ toString() { return "(color: red)"; } }));
assert_false(CSS.supports(undefined), "one explicit undefined argument should stringify");
assert_false(CSS.supports("color", undefined), "explicit undefined value should stringify");
assert_throws_name("TypeError", () => CSS.supports(), "CSS.supports() should require an overload argument");
assert_throws_name("TypeError", () => CSS.supports(Symbol("condition")), "conditionText Symbol conversion should throw");
assert_throws_name("TypeError", () => CSS.supports("color", Symbol("value")), "value Symbol conversion should throw");
assert_throws_name("Error", () => {
CSS.supports({ toString() { throw new Error("condition conversion failed"); } });
}, "conditionText stringification errors should propagate");
assert_throws_name("Error", () => {
CSS.supports("color", { toString() { throw new Error("value conversion failed"); } });
}, "value stringification errors should propagate");
}, "CSS.supports() uses WebIDL overload string conversion");
</script>