Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

feat(css): expose CSSAnimation and CSSTransition interface objects

ldm0839935826557
diff --git a/moli-renderer-v8/src/context_bootstrap/specs/registry.rs b/moli-renderer-v8/src/context_bootstrap/specs/registry.rs
index 22956003c..739cdd018 100644
--- a/moli-renderer-v8/src/context_bootstrap/specs/registry.rs
+++ b/moli-renderer-v8/src/context_bootstrap/specs/registry.rs
@@ -612,6 +612,14 @@ const CONSTRUCTOR_SPECS_BEFORE_STREAMS: &[ConstructorSpec] = &[
interface: web_api_interfaces::Animation::DESCRIPTOR,
kind: ConstructorKind::Animation,
},
+ ConstructorSpec {
+ interface: web_api_interfaces::CSSAnimation::DESCRIPTOR,
+ kind: ConstructorKind::Illegal,
+ },
+ ConstructorSpec {
+ interface: web_api_interfaces::CSSTransition::DESCRIPTOR,
+ kind: ConstructorKind::Illegal,
+ },
ConstructorSpec {
interface: web_api_interfaces::AnimationEffect::DESCRIPTOR,
kind: ConstructorKind::Illegal,
diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/misc/extracted/animations.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/misc/extracted/animations.rs
index 30782a7a4..1be609280 100644
--- a/moli-renderer-v8/src/script_vm/tests/browser_api/misc/extracted/animations.rs
+++ b/moli-renderer-v8/src/script_vm/tests/browser_api/misc/extracted/animations.rs
@@ -365,3 +365,41 @@ fn animation_private_slots_ignore_reflection_and_spoofing() {
r#"{"animationOwnSlots":[],"keyframeOwnSlots":[],"pollutedAnimationOwnSlots":["__moliAnimationEffect","__moliAnimationFinishedResolve","__moliAnimationOnfinish","__moliAnimationPlayState"],"pollutedKeyframeOwnSlots":["__moliKeyframeEffectKeyframes"],"fakeEffectOwnSlots":[],"fakeAnimationOwnSlotsAfterPlay":[],"finish":"ok","real":"running|url(\"https://animations-declared-slots.test/real.png\")|ok|finished|1|none|url(\"https://animations-declared-slots.test/updated.png\")","fake":"||"}"#
);
}
+
+#[test]
+fn css_animation_interfaces_have_realm_local_constructors_and_exposure() {
+ for url in [
+ "https://interface-exposure.test/",
+ "http://interface-exposure.test/",
+ ] {
+ let mut vm = new_storage_test_vm(url);
+ assert_eq!(vm.eval(r#"
+(() => {
+ const assert = (ok, message) => { if (!ok) throw Error(message); };
+ const names = ["CSSAnimation", "CSSTransition"];
+ const parents = {"CSSAnimation": "Animation", "CSSTransition": "Animation"};
+ if (!document.documentElement) document.appendChild(document.createElement('html'));
+ if (!document.body) document.documentElement.appendChild(document.createElement('body'));
+ const child = document.createElement('iframe');
+ document.body.appendChild(child);
+ const other = child.contentWindow;
+ for (const realm of [window, other]) {
+ for (const name of names) {
+ const C = realm[name];
+ assert(typeof C === 'function' && C.name === name && C.length === 0, name + ' constructor');
+ assert(C.prototype.constructor === C, name + ' prototype identity');
+ assert(Object.getPrototypeOf(C.prototype) === (parents[name] ? realm[parents[name]].prototype : realm.Object.prototype), name + ' prototype inheritance');
+ assert(realm[name] === C, name + ' stable lazy materialization');
+ for (const invoke of [() => C(), () => new C(), () => Reflect.construct(C, [], function Subclass() {})]) {
+ let error;
+ try { invoke(); } catch (caught) { error = caught; }
+ assert(error instanceof realm.TypeError, name + ' rejects construction in callee realm');
+ }
+ assert(C !== (realm === window ? other[name] : window[name]), name + ' distinct realm constructors');
+ }
+ }
+ return 'passed';
+})()
+"#).unwrap(), "passed", "{url}");
+ }
+}
diff --git a/moli-renderer-v8/src/web_api_interfaces.rs b/moli-renderer-v8/src/web_api_interfaces.rs
index df9a3ac50..32aa18119 100644
--- a/moli-renderer-v8/src/web_api_interfaces.rs
+++ b/moli-renderer-v8/src/web_api_interfaces.rs
@@ -57,6 +57,7 @@ interfaces! {
BroadcastChannel: EventTarget;
ByteLengthQueuingStrategy;
CDATASection: Text;
+ CSSAnimation: Animation;
CSSConditionRule: CSSGroupingRule;
CSSContainerRule: CSSConditionRule;
CSSCounterStyleRule: CSSRule;
@@ -91,6 +92,7 @@ interfaces! {
CSSStyleSheet: StyleSheet;
CSSStyleValue;
CSSSupportsRule: CSSConditionRule;
+ CSSTransition: Animation;
CSSUnitValue: CSSNumericValue;
Cache;
CacheStorage;