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(renderer): reflect hidden union values
ldm0af2f67246ab5
diff --git a/moli-benchmark/wpt-cross-current/failed-cases.txt b/moli-benchmark/wpt-cross-current/failed-cases.txtindex af6c67f6a..365833e13 100644--- a/moli-benchmark/wpt-cross-current/failed-cases.txt+++ b/moli-benchmark/wpt-cross-current/failed-cases.txt@@ -3159,10 +3159,8 @@ html/editing/the-hidden-attribute/beforematch-element-fragment-navigation.htmlhtml/editing/the-hidden-attribute/beforematch-element-removal-001.htmlhtml/editing/the-hidden-attribute/beforematch-element-removal-002.htmlhtml/editing/the-hidden-attribute/beforematch-infinite-loop.html-html/editing/the-hidden-attribute/hidden-idl.htmlhtml/editing/the-hidden-attribute/hidden-ua-stylesheet.htmlhtml/editing/the-hidden-attribute/hidden-until-found-and-details.html-html/editing/the-hidden-attribute/hidden-until-found-idl.htmlhtml/infrastructure/common-dom-interfaces/collections/historical.htmlhtml/infrastructure/common-dom-interfaces/collections/htmlallcollection.htmlhtml/infrastructure/safe-passing-of-structured-data/shared-array-buffers/window-serviceworker-failure.https.htmldiff --git a/moli-benchmark/wpt-cross-current/passed-cases.txt b/moli-benchmark/wpt-cross-current/passed-cases.txtindex 04e006b0f..7c96645e4 100644--- a/moli-benchmark/wpt-cross-current/passed-cases.txt+++ b/moli-benchmark/wpt-cross-current/passed-cases.txt@@ -5223,6 +5223,8 @@ html/editing/editing-0/contenteditable/user-interaction-editing-contenteditable.html/editing/editing-0/making-entire-documents-editable-the-designmode-idl-attribute/user-interaction-editing-designMode.htmlhtml/editing/editing-0/spelling-and-grammar-checking/spellcheck-enumerated-ascii-case-insensitive.htmlhtml/editing/editing-0/spelling-and-grammar-checking/user-interaction-editing-spellcheck.html+html/editing/the-hidden-attribute/hidden-idl.html+html/editing/the-hidden-attribute/hidden-until-found-idl.htmlhtml/embedded-content/the-img-element/attr-img-fetchpriority.htmlhtml/infrastructure/common-dom-interfaces/collections/domstringlist.htmlhtml/infrastructure/common-dom-interfaces/collections/htmlformcontrolscollection.htmldiff --git a/moli-renderer-v8/src/native_bridge/element/global_attributes.rs b/moli-renderer-v8/src/native_bridge/element/global_attributes.rsindex 7b994b26c..d5711eaff 100644--- a/moli-renderer-v8/src/native_bridge/element/global_attributes.rs+++ b/moli-renderer-v8/src/native_bridge/element/global_attributes.rs@@ -2164,9 +2164,27 @@ pub(in crate::native_bridge) fn node_autofocus_setter_function<'s>(pub(in crate::native_bridge) fn node_hidden_getter_function<'s>(scope: &mut v8::PinScope<'s, '_>,args: v8::FunctionCallbackArguments<'s>,- rv: v8::ReturnValue<'s, v8::Value>,+ mut rv: v8::ReturnValue<'s, v8::Value>,) {- boolean_attribute_property_getter_from_object_or_detached(scope, args.this(), "hidden", rv);+ let Ok((runtime_ptr, handle)) =+ node_runtime_and_handle_from_object_or_detached(scope, args.this())+ else {+ rv.set_undefined();+ return;+ };+ if !node_is_element(unsafe { &*runtime_ptr }, handle) {+ rv.set_undefined();+ return;+ }+ match element_attribute(unsafe { &*runtime_ptr }, handle, "hidden") {+ Some(value) if value.eq_ignore_ascii_case("until-found") => {+ if let Some(value) = v8_string(scope, "until-found") {+ rv.set(value.into());+ }+ }+ Some(_) => rv.set_bool(true),+ None => rv.set_bool(false),+ }}pub(in crate::native_bridge) fn node_hidden_setter_function<'s>(@@ -2174,7 +2192,39 @@ pub(in crate::native_bridge) fn node_hidden_setter_function<'s>(args: v8::FunctionCallbackArguments<'s>,mut rv: v8::ReturnValue<'s, v8::Value>,) {- set_boolean_attribute_property_on_object_or_detached(scope, args.this(), "hidden", args.get(0));+ let Ok((runtime_ptr, handle)) =+ node_runtime_and_handle_from_object_or_detached(scope, args.this())+ else {+ rv.set_undefined();+ return;+ };+ if !node_is_element(unsafe { &*runtime_ptr }, handle) {+ rv.set_undefined();+ return;+ }+ let value = args.get(0);+ if value.is_null_or_undefined() || value.is_boolean() || value.is_number() {+ set_reflected_boolean_attribute(+ scope,+ runtime_ptr,+ handle,+ "hidden",+ !value.is_null_or_undefined() && value.boolean_value(scope),+ );+ } else if let Some(value) = value.to_string(scope) {+ let value = value.to_rust_string_lossy(scope);+ if value.eq_ignore_ascii_case("until-found") {+ set_reflected_attribute(scope, runtime_ptr, handle, "hidden", "until-found");+ } else {+ set_reflected_boolean_attribute(+ scope,+ runtime_ptr,+ handle,+ "hidden",+ !value.is_empty(),+ );+ }+ }rv.set_undefined();}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 a64358911..83d42fc82 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@@ -24,6 +24,51 @@ fn document_compat_mode_reflects_parser_quirks_mode() {}}+#[test]+fn html_element_hidden_reflects_nullable_boolean_number_and_string_union() {+ let mut vm = new_parsed_test_vm(+ "https://hidden-reflection.test/",+ "<!doctype html><div id=target></div>",+ );++ let result = vm+ .eval(+ r#"+ (() => {+ const target = document.getElementById("target");+ const assignments = [+ [false, false, null],+ [true, true, ""],+ ["foo", true, ""],+ ["", false, null],+ ["UnTiL-FoUnD", "until-found", "until-found"],+ [null, false, null],+ [undefined, false, null],+ [1, true, ""],+ [0, false, null],+ [NaN, false, null],+ [{ toString() { return "UNTIL-FOUND"; } }, "until-found", "until-found"]+ ];+ const assignmentResults = assignments.map(([value, expected, attribute]) => {+ target.hidden = value;+ return target.hidden === expected && target.getAttribute("hidden") === attribute;+ });+ target.setAttribute("hidden", "uNtIl-FoUnD");+ return JSON.stringify({+ assignmentResults,+ canonicalGetter: target.hidden+ });+ })()+ "#,+ )+ .expect("HTMLElement.hidden union reflection should evaluate");++ assert_eq!(+ result,+ r#"{"assignmentResults":[true,true,true,true,true,true,true,true,true,true,true],"canonicalGetter":"until-found"}"#+ );+}+#[test]fn zhihu_probe_live_document_shape_matches_chromium_branding() {let mut vm = new_storage_test_vm("https://example.com/");