Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
feat(svg): expose native animation element interface objects
ldm00b7081a51a15
diff --git a/moli-dom/src/native/element/interface_names.rs b/moli-dom/src/native/element/interface_names.rsindex d96369920..86e15bafe 100644--- a/moli-dom/src/native/element/interface_names.rs+++ b/moli-dom/src/native/element/interface_names.rs@@ -91,6 +91,10 @@ pub fn html_element_interface_name(local_name: &str) -> &'static str {pub fn svg_element_interface_name(local_name: &str) -> &'static str {match local_name {"a" => "SVGAElement",+ "animate" => "SVGAnimateElement",+ "animateMotion" => "SVGAnimateMotionElement",+ "animateTransform" => "SVGAnimateTransformElement",+ "set" => "SVGSetElement","circle" => "SVGCircleElement","defs" => "SVGDefsElement","desc" => "SVGDescElement",diff --git a/moli-renderer-v8/src/context_bootstrap/bridge_descriptor/descriptors.rs b/moli-renderer-v8/src/context_bootstrap/bridge_descriptor/descriptors.rsindex e40e22728..4858c9d2c 100644--- a/moli-renderer-v8/src/context_bootstrap/bridge_descriptor/descriptors.rs+++ b/moli-renderer-v8/src/context_bootstrap/bridge_descriptor/descriptors.rs@@ -108,6 +108,26 @@ const NODE_BRIDGE_DESCRIPTORS: &[BridgeDescriptor] = &[web_api_interfaces::SVGGeometryElement::DESCRIPTOR,ELEMENT_GROUPS,),+ descriptor(+ web_api_interfaces::SVGAnimationElement::DESCRIPTOR,+ ELEMENT_GROUPS,+ ),+ descriptor(+ web_api_interfaces::SVGAnimateElement::DESCRIPTOR,+ ELEMENT_GROUPS,+ ),+ descriptor(+ web_api_interfaces::SVGAnimateMotionElement::DESCRIPTOR,+ ELEMENT_GROUPS,+ ),+ descriptor(+ web_api_interfaces::SVGAnimateTransformElement::DESCRIPTOR,+ ELEMENT_GROUPS,+ ),+ descriptor(+ web_api_interfaces::SVGSetElement::DESCRIPTOR,+ ELEMENT_GROUPS,+ ),descriptor(web_api_interfaces::SVGAElement::DESCRIPTOR, ELEMENT_GROUPS),specialized_descriptor(web_api_interfaces::SVGCircleElement::DESCRIPTOR,diff --git a/moli-renderer-v8/src/script_vm/tests/mod.rs b/moli-renderer-v8/src/script_vm/tests/mod.rsindex 4a524d006..0a8c70c35 100644--- a/moli-renderer-v8/src/script_vm/tests/mod.rs+++ b/moli-renderer-v8/src/script_vm/tests/mod.rs@@ -2144,6 +2144,7 @@ mod element_click;mod event_receivers;mod headers_list;mod http_fixture;+mod svg_animation_interfaces;mod audio_event_interfaces;mod import_meta;diff --git a/moli-renderer-v8/src/script_vm/tests/svg_animation_interfaces.rs b/moli-renderer-v8/src/script_vm/tests/svg_animation_interfaces.rsnew file mode 100644index 000000000..e6d9f55f4--- /dev/null+++ b/moli-renderer-v8/src/script_vm/tests/svg_animation_interfaces.rs@@ -0,0 +1,48 @@+use super::*;++#[test]+fn svg_animation_interfaces_preserve_native_inheritance_and_realm_contracts() {+ let mut vm = new_storage_page_task_executor_test_vm("https://svg-animation-interfaces.test/");+ vm.eval("document.body.innerHTML = '<iframe id=child></iframe>'")+ .unwrap();+ assert_eq!(vm.eval(r#"(() => {+ const assert = (ok, message) => { if (!ok) throw Error(message); };+ const ns = 'http://www.w3.org/2000/svg';+ const child = document.getElementById('child').contentWindow;+ const detached = document.implementation.createHTMLDocument('');+ const xml = new DOMParser().parseFromString('<svg xmlns="' + ns + '"/>', 'image/svg+xml');+ for (const [name, parentName] of [["SVGAnimationElement","SVGElement"],["SVGAnimateElement","SVGAnimationElement"],["SVGAnimateMotionElement","SVGAnimationElement"],["SVGAnimateTransformElement","SVGAnimationElement"],["SVGSetElement","SVGAnimationElement"]]) {+ for (const w of [window, child]) {+ const C = w[name], parent = w[parentName];+ assert(typeof C === 'function' && C.name === name, name + ' exposed');+ assert(Object.getPrototypeOf(C.prototype) === parent.prototype, name + ' prototype inheritance');+ assert(Object.getPrototypeOf(C) === parent, name + ' interface inheritance');+ let error;+ try { new C(); } catch (caught) { error = caught; }+ assert(error instanceof w.TypeError, name + ' illegal constructor realm');+ }+ }+ const nodeType = Object.getOwnPropertyDescriptor(Node.prototype, 'nodeType').get;+ for (const [tag, name] of [["animate","SVGAnimateElement"],["animateMotion","SVGAnimateMotionElement"],["animateTransform","SVGAnimateTransformElement"],["set","SVGSetElement"]]) {+ for (const [doc, w] of [[document, window], [child.document, child], [detached, window], [xml, window]]) {+ const element = doc.createElementNS(ns, tag), C = w[name];+ assert(element instanceof C && element instanceof w.SVGElement && element instanceof w.Node, tag + ' native factory brand');+ assert(Object.getPrototypeOf(element) === C.prototype && element.constructor === C, tag + ' factory prototype');+ assert(Object.prototype.toString.call(element) === '[object ' + name + ']', tag + ' native tag');+ assert(element.cloneNode(false) instanceof C, tag + ' cloned brand');+ assert(doc.importNode(element, false) instanceof C, tag + ' imported brand');+ element.setAttribute('data-test', 'value');+ assert(element.getAttribute('data-test') === 'value' && nodeType.call(element) === 1, tag + ' inherited DOM behavior');+ for (const receiver of [Object.create(element), new Proxy(element, {})]) {+ let error;+ try { nodeType.call(receiver); } catch (caught) { error = caught; }+ assert(error instanceof TypeError, tag + ' rejects forged native identity');+ }+ assert(!(doc.createElement(tag) instanceof C), tag + ' namespace-sensitive factory');+ }+ const parsed = new DOMParser().parseFromString('<svg xmlns="' + ns + '"><' + tag + '/></svg>', 'image/svg+xml');+ assert(parsed.documentElement.firstElementChild instanceof window[name], tag + ' parsed XML brand');+ }+ return true;+})()"#).unwrap(), "true");+}diff --git a/moli-renderer-v8/src/web_api_interfaces.rs b/moli-renderer-v8/src/web_api_interfaces.rsindex 75679d83f..099e576fe 100644--- a/moli-renderer-v8/src/web_api_interfaces.rs+++ b/moli-renderer-v8/src/web_api_interfaces.rs@@ -387,6 +387,11 @@ interfaces! {SVGAnimatedNumber;SVGAnimatedNumberList;SVGAnimatedTransformList;+ SVGAnimationElement: SVGElement;+ SVGAnimateElement: SVGAnimationElement;+ SVGAnimateMotionElement: SVGAnimationElement;+ SVGAnimateTransformElement: SVGAnimationElement;+ SVGSetElement: SVGAnimationElement;SVGCircleElement: SVGGeometryElement;SVGDefsElement: SVGGraphicsElement;SVGDescElement: SVGElement;