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>
test(function () {
const event = new Event("spoof");
event.__lmTrusted = true;
assert_false(event.isTrusted, "assigning the internal trusted slot must not spoof isTrusted");
assert_equals(event.__lmTrusted, true, "the legacy public property stays ordinary data");
}, "Event isTrusted cannot be spoofed through the internal trusted flag");
test(function () {
const target = new EventTarget();
const event = new Event("before", { bubbles: false, cancelable: false });
target.addEventListener("before", function () {
event.initEvent("after", true, true);
assert_equals(event.type, "before", "initEvent is ignored during detached EventTarget dispatch");
assert_false(event.bubbles, "bubbles is not mutated during dispatch");
assert_false(event.cancelable, "cancelable is not mutated during dispatch");
});
target.dispatchEvent(event);
assert_equals(event.type, "before", "type remains unchanged after dispatch");
assert_false(event.bubbles, "bubbles remains unchanged after dispatch");
assert_false(event.cancelable, "cancelable remains unchanged after dispatch");
}, "initEvent is suppressed during EventTarget dispatch");
test(function () {
const target = screen;
const event = new Event("moli-simple-init", { bubbles: false, cancelable: false });
target.addEventListener("moli-simple-init", function () {
event.initEvent("after", true, true);
assert_equals(event.type, "moli-simple-init", "initEvent is ignored during simple EventTarget dispatch");
assert_false(event.bubbles, "bubbles is not mutated during simple dispatch");
assert_false(event.cancelable, "cancelable is not mutated during simple dispatch");
}, { once: true });
target.dispatchEvent(event);
assert_equals(event.type, "moli-simple-init", "type remains unchanged after simple dispatch");
assert_false(event.bubbles, "bubbles remains unchanged after simple dispatch");
assert_false(event.cancelable, "cancelable remains unchanged after simple dispatch");
}, "initEvent is suppressed during simple EventTarget dispatch");
test(function () {
const target = screen;
const calls = [];
target.addEventListener("moli-simple-sip", function (event) {
calls.push("first");
event.stopImmediatePropagation();
}, { once: true });
target.addEventListener("moli-simple-sip", function () {
calls.push("second");
}, { once: true });
target.dispatchEvent(new Event("moli-simple-sip"));
assert_array_equals(calls, ["first"]);
}, "stopImmediatePropagation stops later simple EventTarget listeners");
test(function () {
const parent = document.createElement("div");
const target = document.createElement("button");
parent.appendChild(target);
(document.body || document.documentElement).appendChild(parent);
const calls = [];
parent.addEventListener("moli-target-stop", function () {
calls.push("parent-capture");
}, { capture: true });
parent.addEventListener("moli-target-stop", function () {
calls.push("parent-bubble");
});
target.addEventListener("moli-target-stop", function (event) {
calls.push("target-capture");
event.stopPropagation();
}, { capture: true });
target.addEventListener("moli-target-stop", function () {
calls.push("target-bubble");
});
target.dispatchEvent(new Event("moli-target-stop", { bubbles: true }));
parent.remove();
assert_array_equals(calls, [
"parent-capture",
"target-capture",
]);
}, "stopPropagation during at-target capture skips at-target bubble listeners");
test(function () {
const parent = document.createElement("div");
const target = document.createElement("button");
parent.appendChild(target);
(document.body || document.documentElement).appendChild(parent);
const calls = [];
parent.addEventListener("moli-target-handler-stop", function () {
calls.push("parent-bubble");
});
target["onmoli-target-handler-stop"] = function (event) {
calls.push("target-handler");
event.stopPropagation();
};
target.addEventListener("moli-target-handler-stop", function () {
calls.push("target-capture");
}, { capture: true });
target.addEventListener("moli-target-handler-stop", function () {
calls.push("target-bubble");
});
target.dispatchEvent(new Event("moli-target-handler-stop", { bubbles: true }));
target["onmoli-target-handler-stop"] = null;
parent.remove();
assert_array_equals(calls, [
"target-handler",
"target-capture",
]);
}, "stopPropagation from an at-target event handler skips later at-target bubble listeners");
</script>