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(geometry): align DOMRect factory descriptors and dictionary order
ldm04ca389adb2fa
diff --git a/moli-renderer-v8/src/context_bootstrap/dom_rect.rs b/moli-renderer-v8/src/context_bootstrap/dom_rect.rsindex c91bdb886..6fe99b016 100644--- a/moli-renderer-v8/src/context_bootstrap/dom_rect.rs+++ b/moli-renderer-v8/src/context_bootstrap/dom_rect.rs@@ -136,7 +136,7 @@ struct DomRectPrototypeDeclaration {}#[derive(WebApiFunctionTemplate)]-#[webapi(interface = web_api_interfaces::DOMRectReadOnly)]+#[webapi(interface = web_api_interfaces::DOMRectReadOnly, enumerable)]struct DomRectReadOnlyConstructorDeclaration {#[webapi(static_method = "fromRect",@@ -147,7 +147,7 @@ struct DomRectReadOnlyConstructorDeclaration {}#[derive(WebApiFunctionTemplate)]-#[webapi(interface = web_api_interfaces::DOMRect)]+#[webapi(interface = web_api_interfaces::DOMRect, enumerable)]struct DomRectConstructorDeclaration {#[webapi(static_method = "fromRect",@@ -216,13 +216,13 @@ struct DomRectReadOnlyConstructorArgs {#[webidl(prefix = "DOMRectInit")]struct DomRectInit {#[webidl(default = 0.0)]- x: f64,- #[webidl(default = 0.0)]- y: f64,+ height: f64,#[webidl(default = 0.0)]width: f64,#[webidl(default = 0.0)]- height: f64,+ x: f64,+ #[webidl(default = 0.0)]+ y: f64,}pub(super) fn dom_rect_readonly_constructor_callback<'s>(diff --git a/moli-renderer-v8/src/script_vm/tests/dom_rect_factory_descriptors.rs b/moli-renderer-v8/src/script_vm/tests/dom_rect_factory_descriptors.rsnew file mode 100644index 000000000..01e75b418--- /dev/null+++ b/moli-renderer-v8/src/script_vm/tests/dom_rect_factory_descriptors.rs@@ -0,0 +1,50 @@+use super::*;++#[test]+fn dom_rect_static_factories_use_webidl_descriptors_and_dictionary_order() {+ let mut vm = new_storage_test_vm("https://rect-factory.test/");+ assert_eq!(vm.eval(r#"+(() => {+ const check = (ok, message) => { if (!ok) throw Error(message); };+ if (!document.documentElement) document.appendChild(document.createElement('html'));+ if (!document.body) document.documentElement.appendChild(document.createElement('body'));+ const iframe = document.createElement('iframe');+ document.body.appendChild(iframe);+ for (const realm of [window, iframe.contentWindow]) {+ for (const name of ['DOMRect', 'DOMRectReadOnly']) {+ const Constructor = realm[name];+ const descriptor = Object.getOwnPropertyDescriptor(Constructor, 'fromRect');+ check(descriptor.enumerable && descriptor.writable && descriptor.configurable, name + ' descriptor');+ check(descriptor.value.name === 'fromRect' && descriptor.value.length === 0, name + ' method signature');+ check(Object.keys(Constructor).includes('fromRect'), name + ' own enumerable factory');+ const order = [];+ const value = descriptor.value.call(null, {+ get y() { order.push('y'); return NaN; },+ get x() { order.push('x'); return -0; },+ get width() { order.push('width'); return -3; },+ get height() {+ order.push('height');+ return { valueOf() { order.push('height:valueOf'); return -4; } };+ }+ });+ check(order.join(',') === 'height,height:valueOf,width,x,y', name + ' dictionary conversion');+ check(Object.getPrototypeOf(value) === Constructor.prototype, name + ' factory realm');+ check(Object.is(value.x, -0) && Number.isNaN(value.y) && value.width === -3 && value.height === -4, name + ' values');+ const reads = [];+ const sentinel = {};+ let error;+ try {+ descriptor.value.call(null, {+ get y() { reads.push('y'); return 0; },+ get x() { reads.push('x'); return 0; },+ get width() { reads.push('width'); return 0; },+ get height() { reads.push('height'); throw sentinel; }+ });+ } catch (caught) { error = caught; }+ check(error === sentinel && reads.join(',') === 'height', name + ' getter failure stops conversion');+ }+ }+ return 'passed';+})()+"#).unwrap(), "passed");+}diff --git a/moli-renderer-v8/src/script_vm/tests/mod.rs b/moli-renderer-v8/src/script_vm/tests/mod.rsindex 306bc17f0..622eb3f7e 100644--- a/moli-renderer-v8/src/script_vm/tests/mod.rs+++ b/moli-renderer-v8/src/script_vm/tests/mod.rs@@ -2184,3 +2184,5 @@ mod intersection_target_order;mod observer_element_arguments;mod media_device_interfaces;++mod dom_rect_factory_descriptors;