Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
fix(events): expose global touch handlers
ldm04306c48b2464
diff --git a/moli-benchmark/wpt-cross-current/failed-cases.txt b/moli-benchmark/wpt-cross-current/failed-cases.txtindex adccb9740..462b90557 100644--- a/moli-benchmark/wpt-cross-current/failed-cases.txt+++ b/moli-benchmark/wpt-cross-current/failed-cases.txt@@ -3889,7 +3889,6 @@ svg/types/scripted/SVGList-parse-invalid-clears-items.htmlsvg/types/scripted/SVGMatrix-tentative.htmlsvg/types/scripted/SVGPoint.htmlsvg/types/scripted/SVGRect.html-touch-events/touch-globaleventhandler-interface.htmltrusted-types/Document-write-appending-line-feed.htmltrusted-types/Document-write.htmltrusted-types/Element-setAttribute-respects-Elements-node-documents-globals-CSP-after-adoption-from-TT-realm.htmldiff --git a/moli-benchmark/wpt-cross-current/passed-cases.txt b/moli-benchmark/wpt-cross-current/passed-cases.txtindex ba909d7b4..9ce6f0b90 100644--- a/moli-benchmark/wpt-cross-current/passed-cases.txt+++ b/moli-benchmark/wpt-cross-current/passed-cases.txt@@ -7518,6 +7518,7 @@ svg/types/scripted/SVGLengthList-getItem.htmlsvg/types/scripted/SVGPathElement.getTotalLength-01.htmltouch-events/expose-legacy-touch-event-apis.htmltouch-events/historical.html+touch-events/touch-globaleventhandler-interface.htmltouch-events/touch-touchevent-constructor.htmltrusted-types/DOMParser-parseFromString.htmltrusted-types/DedicatedWorker-block-eval-function-constructor.htmldiff --git a/moli-renderer-v8/src/context_bootstrap/window_events.rs b/moli-renderer-v8/src/context_bootstrap/window_events.rsindex cc06c72c6..b926a8400 100644--- a/moli-renderer-v8/src/context_bootstrap/window_events.rs+++ b/moli-renderer-v8/src/context_bootstrap/window_events.rs@@ -72,6 +72,10 @@ pub(crate) const WINDOW_EVENT_HANDLER_PROPERTIES: &[&str] = &["onsubmit","onsuspend","ontimeupdate",+ "ontouchcancel",+ "ontouchend",+ "ontouchmove",+ "ontouchstart","onunhandledrejection","onunload","onvolumechange",diff --git a/moli-renderer-v8/src/native_bridge/element/event_handlers/generic.rs b/moli-renderer-v8/src/native_bridge/element/event_handlers/generic.rsindex adfd14189..8ca0c6e6d 100644--- a/moli-renderer-v8/src/native_bridge/element/event_handlers/generic.rs+++ b/moli-renderer-v8/src/native_bridge/element/event_handlers/generic.rs@@ -41,6 +41,10 @@ pub(crate) const GENERIC_EVENT_HANDLER_PROPERTIES: &[&str] = &["onpointercancel","ongotpointercapture","onlostpointercapture",+ "ontouchstart",+ "ontouchend",+ "ontouchmove",+ "ontouchcancel","onsubmit","onreset","onchange",diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/misc.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/misc.rsindex 1314fbb0a..7149fb3af 100644--- a/moli-renderer-v8/src/script_vm/tests/browser_api/misc.rs+++ b/moli-renderer-v8/src/script_vm/tests/browser_api/misc.rs@@ -6500,7 +6500,7 @@ fn zhihu_bot_detection_harness_fixture_matches_stable_moli_baseline() {assert_eq!(value["screenTouch"]["orientationType"], "landscape-primary");assert_eq!(value["screenTouch"]["touchType"], "function");assert_eq!(value["screenTouch"]["touchEventType"], "function");- assert_eq!(value["screenTouch"]["ontouchstartType"], "undefined");+ assert_eq!(value["screenTouch"]["ontouchstartType"], "object");assert_eq!(value["canvasWebgl"]["canvasCtor"], "HTMLCanvasElement");assert_eq!(value["canvasWebgl"]["canvasTag"], "CANVAS");diff --git a/moli-renderer-v8/src/script_vm/tests/dom_elements/live_document.rs b/moli-renderer-v8/src/script_vm/tests/dom_elements/live_document.rsindex 51666c8d6..e996e45a0 100644--- a/moli-renderer-v8/src/script_vm/tests/dom_elements/live_document.rs+++ b/moli-renderer-v8/src/script_vm/tests/dom_elements/live_document.rs@@ -4221,6 +4221,56 @@ fn global_drag_event_handlers_cover_window_document_and_elements() {);}+#[test]+fn global_touch_event_handlers_live_on_mixin_owners() {+ let mut vm = new_parsed_test_vm(+ "https://global-touch-event-handlers.test/",+ "<!doctype html><html><head></head><body></body></html>",+ );++ let result = vm+ .eval(+ r#"+(() => {+ const names = ['ontouchstart', 'ontouchend', 'ontouchmove', 'ontouchcancel'];+ const owners = [window, HTMLElement.prototype, SVGElement.prototype, Document.prototype];+ const descriptorIsEventHandler = (owner, name) => {+ const descriptor = Object.getOwnPropertyDescriptor(owner, name);+ return !!descriptor &&+ typeof descriptor.get === 'function' &&+ typeof descriptor.set === 'function' &&+ descriptor.enumerable && descriptor.configurable;+ };+ const ownAccessors = names.every(name =>+ owners.every(owner => descriptorIsEventHandler(owner, name))+ );+ const absentFromElement = names.every(name => !(name in Element.prototype));++ const div = document.createElement('div');+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');+ const calls = [];+ for (const [label, target] of [+ ['window', window],+ ['document', document],+ ['html', div],+ ['svg', svg]+ ]) {+ target.ontouchstart = event => calls.push(`${label}:${event.type}`);+ target.dispatchEvent(new Event('touchstart'));+ }++ return JSON.stringify({ ownAccessors, absentFromElement, calls });+})()+"#,+ )+ .expect("GlobalEventHandlers touch surface should evaluate");++ assert_eq!(+ result,+ r#"{"ownAccessors":true,"absentFromElement":true,"calls":["window:touchstart","document:touchstart","html:touchstart","svg:touchstart"]}"#+ );+}+#[test]fn media_accessors_live_on_owner_prototypes() {let mut vm = new_parsed_test_vm(