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(window): expose status through native string accessors
ldm0a2dc94d6b264
diff --git a/moli-renderer-v8/src/context_bootstrap/runtime_state.rs b/moli-renderer-v8/src/context_bootstrap/runtime_state.rsindex 77cf7aaa0..93bc4ca9c 100644--- a/moli-renderer-v8/src/context_bootstrap/runtime_state.rs+++ b/moli-renderer-v8/src/context_bootstrap/runtime_state.rs@@ -56,6 +56,7 @@ pub(crate) const ORIGINAL_WEBASSEMBLY_GLOBAL_VALUE_GETTER_SLOT: &str ="__moliOriginalWebAssemblyGlobalValueGetter";const WINDOW_INDEXED_DB_SURFACE_SLOT: &str = "moli.Window.indexedDB";const WINDOW_ORIGIN_RUNTIME_SLOT: &str = "__moliWindowOriginRuntime";+const WINDOW_STATUS_RUNTIME_SLOT: &str = "__moliWindowStatusRuntime";const WINDOW_INTRINSIC_EVAL_SLOT: &str = "__moliWindowIntrinsicEval";pub(in crate::context_bootstrap) const WINDOW_SECURE_CONTEXT_AVAILABLE_SLOT: &str ="__moliWindowSecureContextAvailable";@@ -284,6 +285,13 @@ struct WindowPublicSurfaceAccessorsDeclaration<'scope> {setter = window_name_runtime_setter)]name: (),+ #[webapi(+ accessor_property,+ enumerable,+ getter = window_status_runtime_getter,+ setter = window_status_runtime_setter+ )]+ status: (),}#[derive(Default, WebApiObject)]@@ -941,6 +949,44 @@ fn window_name_runtime_setter<'s>(define_non_enumerable_string_property(scope, receiver, WINDOW_NAME_SLOT, &next);}+fn window_status_runtime_getter<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ args: v8::FunctionCallbackArguments<'s>,+ mut rv: v8::ReturnValue<'s, v8::Value>,+) {+ let receiver = callback_this_object(scope, &args);+ if !super::is_window_receiver(scope, receiver) {+ throw_type_error(+ scope,+ "Window.status getter called on incompatible receiver.",+ );+ return;+ }+ rv.set(+ get_private_value(scope, receiver, WINDOW_STATUS_RUNTIME_SLOT)+ .unwrap_or_else(|| v8::String::empty(scope).into()),+ );+}++fn window_status_runtime_setter<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ args: v8::FunctionCallbackArguments<'s>,+ _rv: v8::ReturnValue<'s, v8::Value>,+) {+ let receiver = callback_this_object(scope, &args);+ if !super::is_window_receiver(scope, receiver) {+ throw_type_error(+ scope,+ "Window.status setter called on incompatible receiver.",+ );+ return;+ }+ let Some(next) = args.get(0).to_string(scope) else {+ return;+ };+ set_private_value(scope, receiver, WINDOW_STATUS_RUNTIME_SLOT, next.into());+}+fn install_public_window_surface_accessors<'s>(scope: &mut v8::PinScope<'s, '_>,global: v8::Local<'s, v8::Object>,@@ -1067,6 +1113,7 @@ fn install_public_window_surface_accessors<'s>(session_storage: (),indexed_db: (),name: (),+ status: (),}.initialize(scope, global)?;WindowLegacySurfaceAccessorsDeclaration {diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/misc.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/misc.rsindex a23ab0b92..4ebf99e7f 100644--- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/misc.rs+++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/misc.rs@@ -322,6 +322,49 @@ fn child_window_same_realm_alias_boundary_is_explicit() {);}+#[test]+fn window_status_uses_native_accessors_and_preserves_dom_strings() {+ let mut vm = new_parsed_test_vm("https://window-status.test/", "<!doctype html><body>");+ vm.eval("globalThis.frame = document.body.appendChild(document.createElement('iframe'))")+ .unwrap();+ materialize_single_child_default_realm_for_test(&mut vm, "Window.status child Realm");+ assert_eq!(+ vm.eval(+ r#"(() => {+ const check = (value, label) => { if (!value) throw new Error(label); };+ const other = frame.contentWindow;+ const descriptor = Object.getOwnPropertyDescriptor(other, 'status');+ check(typeof descriptor.get === 'function' && typeof descriptor.set === 'function' &&+ descriptor.enumerable && descriptor.configurable && !('value' in descriptor), 'descriptor');+ check(status === '' && other.status === '', 'defaults');+ status = 'parent';+ descriptor.set.call(other, '\ud800');+ check(other.status === '\ud800' && status === 'parent', 'separate UTF-16 state');+ descriptor.set.call(self, null);+ check(status === 'null', 'borrowed setter conversion');+ let conversions = 0;+ const value = {toString() { conversions++; return 'converted'; }};+ for (const receiver of [{}, Object.create(other), new Proxy(other, {})]) {+ let error;+ try { descriptor.set.call(receiver, value); } catch (caught) { error = caught; }+ check(error instanceof other.TypeError, 'callee realm receiver error');+ }+ check(conversions === 0, 'validation before conversion');+ const sentinel = {};+ let error;+ try { other.status = {toString() { throw sentinel; }}; } catch (caught) { error = caught; }+ check(error === sentinel && other.status === '\ud800', 'conversion exception');+ descriptor.set.call(null, 'child');+ check(descriptor.get.call(undefined) === 'child', 'global interface receiver');+ frame.remove();+ return true;+ })()"#+ )+ .expect("Window.status fixture should evaluate"),+ "true"+ );+}+#[test]fn window_global_accessors_use_the_borrowed_window_receiver() {let mut vm = new_storage_test_vm("https://window-accessor-receiver.test/");