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(accessibility): use descendant text alternatives in control names
ldm09b726d582129
diff --git a/moli-cdp-smoke/README.md b/moli-cdp-smoke/README.mdindex 0b38c339c..17e2170cb 100644--- a/moli-cdp-smoke/README.md+++ b/moli-cdp-smoke/README.md@@ -188,6 +188,23 @@ The separate Moli layout-policy group passed all 37 scenarios; AX style readsdo not publish or refresh layout. Viewport-dependent content-visibility:autodisplay locking remains outside this visibility contract.+The Puppeteer descendant-name workflow was calibrated on 2026-10-10 with the+same client and Chromium executable, then run unchanged against Moli.+`puppeteer_accessibility_names.mjs` checks 28 parent-button name cases from+child SVG/span ARIA alternatives, native image+`alt`, external hidden labels, cycles and shared references, mixed inline text,+visibility overrides, inert/ARIA-hidden descendants, and closed-shadow slots.+It starts with a cold partial AX request, compares both snapshot modes, resolves+the parent button's backend ref through ARIA, and requires two trusted clicks.+Changing or hiding the icon updates its parent's name without changing refs.+Whitespace-only contents preserve tooltip names and inline word boundaries.+The complete Puppeteer group passed all 25 scenarios against each engine; the+separate Moli layout-policy group passed all 37 scenarios. Live Bootstrap 5.3+Modal and Offcanvas pages also matched Chromium for all 22 icon-labelled Copy+buttons and their ARIA backend refs. Each page completed a trusted ARIA-handle+click after explicit scrolling and screenshot layout publication.+AX name reads do not publish layout or change the frozen-layout policy.+The `navigation-outcomes` group was calibrated on 2026-08-23 against Debian`/usr/bin/chromium` 145.0.7632.116 and then run unchanged against Moli. Itdirectly drives `Page.navigate` and correlates the result with the matchingdiff --git a/moli-cdp-smoke/moli_cdp_smoke/puppeteer_accessibility_names.mjs b/moli-cdp-smoke/moli_cdp_smoke/puppeteer_accessibility_names.mjsnew file mode 100644index 000000000..13cae90d6--- /dev/null+++ b/moli-cdp-smoke/moli_cdp_smoke/puppeteer_accessibility_names.mjs@@ -0,0 +1,121 @@+import assert from 'node:assert/strict';++const cases = [+ ['copy', '<svg role="img" aria-label="Copy"><use href="#clipboard"></use></svg>', 'Copy'],+ ['span', '<span aria-label="Copy">visual text</span>', 'Copy'],+ ['mixed', 'Save<span aria-label="document"></span>now', 'Save document now'],+ ['inline', 'foo<span>bar</span>baz', 'foobarbaz'],+ ['inline-space', 'foo<span> </span>bar', 'foo bar'],+ ['image', '<img alt="Copy">', 'Copy'],+ ['labelledby', '<span aria-labelledby="external" aria-label="Wrong">visual</span>', 'External'],+ ['empty', '<span aria-label="">Fallback</span>', 'Fallback'],+ ['presentational', '<span role="none" aria-label="Presentation">Fallback</span>', 'Presentation'],+ ['hidden', 'Start<span style="display:none" aria-label="Secret">Visual</span>End', 'StartEnd'],+ ['visibility', 'Start<span style="visibility:hidden" aria-label="Secret"><span style="visibility:visible" aria-label="Visible"></span></span>End', 'Start Visible End'],+ ['inert', 'Start<span inert aria-label="Secret">Visual</span>End', 'StartEnd'],+ ['cv', 'Start<span style="content-visibility:hidden" aria-label="CV">Visual</span>End', 'Start CV End'],+ ['cv-block', 'Before<span style="content-visibility:hidden;display:block">CV hidden</span>After', 'Before After'],+ ['ariahidden', 'Start<span aria-hidden="true" aria-label="Secret">Visual</span>End', 'StartEnd'],+ ['child-self', '<span id="self" aria-labelledby="self" aria-label="Copy">visual</span>', 'Copy'],+ ['child-parent', 'Prefix<span aria-labelledby="child-parent" aria-label="Fallback">visual</span>Suffix', 'Prefix Prefix Fallback Suffix'],+ ['reference', '', 'Inner', 'aria-labelledby="outer"'],+ ['explicit', '<svg aria-label="Copy"></svg>', 'Primary', 'aria-label="Primary"'],+ ['shared', '<span aria-labelledby="external"></span><span aria-labelledby="external"></span>', 'External External'],+ ['title-empty', '<span title="Tooltip"></span>', ''],+ ['title-content', '<span title="Tooltip">Contents</span>', 'Contents'],+ ['title-whitespace', ' ', 'Tooltip', 'title="Tooltip"'],+ ['title-wrapper-whitespace', '<span> </span>', 'Tooltip', 'title="Tooltip"'],+ ['title-empty-block', '<div></div>', 'Tooltip', 'title="Tooltip"'],+ ['reference-title', '', 'Tooltip', 'aria-labelledby="tooltip"'],+ ['reference-title-descendant', '', 'Tooltip child', 'aria-labelledby="tooltip-parent"'],+];++function buttonNames(snapshot) {+ const names = [];+ const pending = snapshot ? [snapshot] : [];+ while (pending.length) {+ const node = pending.pop();+ if (node.role === 'button') names.push(node.name ?? '');+ pending.push(...(node.children ?? []));+ }+ return names.sort();+}++export async function runPuppeteerAccessibilityNamesSmoke(page) {+ await page.goto('about:blank');+ await page.evaluate(cases => {+ document.body.innerHTML = `+ <span id="external" hidden>External</span><span id="end">End</span>+ <span id="outer" hidden><span aria-labelledby="end" aria-label="Inner">visual</span></span>+ <span id="tooltip" hidden title="Tooltip"></span>+ <span id="tooltip-parent" hidden><span title="Tooltip child"></span></span>+ ${cases.map(([id, html, , attrs = '']) => `<button id="${id}" ${attrs}>${html}</button>`).join('')}+ <div id="name-host" role="button"><span slot="action" aria-label="Slotted">visual</span></div>+ `;+ const shadow = document.getElementById('name-host').attachShadow({mode: 'closed'});+ shadow.innerHTML = '<svg role="img" aria-label="Shadow Copy"></svg><slot name="action" aria-label="Wrong slot"></slot>';+ globalThis.__nameClicks = [];+ for (const id of ['copy', 'span']) {+ document.getElementById(id).addEventListener('click', event => {+ __nameClicks.push({id, trusted: event.isTrusted});+ });+ }+ }, cases);++ const client = await page.createCDPSession();+ try {+ // Start with a local request: a full snapshot must not warm name inputs.+ const copy = await page.$('#copy');+ assert.ok(copy);+ const backend = await copy.backendNodeId();+ const partial = async () => (await client.send('Accessibility.getPartialAXTree', {+ backendNodeId: backend, fetchRelatives: false,+ })).nodes[0];+ const first = await partial();+ assert.equal(first.ignored, false);+ assert.equal(first.name?.value, 'Copy', 'The parent button must use its icon\'s text alternative');++ const expected = [...cases.map(([, , name]) => name), 'Shadow Copy Slotted'].sort();+ for (const interestingOnly of [true, false]) {+ assert.deepEqual(buttonNames(await page.accessibility.snapshot({interestingOnly})), expected);+ }+ for (const id of ['copy', 'span']) {+ const target = await page.$('#' + id);+ const expectedBackend = await target.backendNodeId();+ await target.dispose();+ const handles = await page.$$('aria/Copy[role="button"]');+ try {+ const matches = [];+ for (const handle of handles) if (await handle.backendNodeId() === expectedBackend) matches.push(handle);+ assert.equal(matches.length, 1, 'ARIA must resolve the parent button snapshot ref');+ await matches[0].click();+ } finally { await Promise.all(handles.map(handle => handle.dispose())); }+ }+ assert.deepEqual(await page.evaluate(() => __nameClicks), [+ {id: 'copy', trusted: true}, {id: 'span', trusted: true},+ ]);++ await page.evaluate(() => document.querySelector('#copy svg').setAttribute('aria-label', 'Copied'));+ const updated = await partial();+ assert.equal(updated.name.value, 'Copied');+ assert.equal(updated.nodeId, first.nodeId);+ assert.equal(updated.backendDOMNodeId, backend);+ const renamed = await page.$('aria/Copied[role="button"]');+ assert.ok(renamed);+ try { assert.equal(await renamed.backendNodeId(), backend); } finally { await renamed.dispose(); }+ const old = await page.$$('aria/Copy[role="button"]');+ try {+ for (const handle of old) assert.notEqual(await handle.backendNodeId(), backend);+ } finally { await Promise.all(old.map(handle => handle.dispose())); }++ await page.evaluate(() => { document.querySelector('#copy svg').style.display = 'none'; });+ const hidden = await partial();+ assert.equal(hidden.ignored, false, 'Hiding the icon must retain the parent button');+ assert.equal(hidden.name?.value ?? '', '');+ assert.equal(await page.$('aria/Copied[role="button"]'), null);+ await page.evaluate(() => { document.querySelector('#copy svg').style.removeProperty('display'); });+ assert.equal((await partial()).name.value, 'Copied');+ await copy.dispose();+ return {cases: cases.length + 1, trustedClicks: 2, stableReference: true, coldPartial: true};+ } finally { await client.detach(); }+}diff --git a/moli-cdp-smoke/moli_cdp_smoke/puppeteer_smoke.mjs b/moli-cdp-smoke/moli_cdp_smoke/puppeteer_smoke.mjsindex 85c25fe27..d9ea18be8 100644--- a/moli-cdp-smoke/moli_cdp_smoke/puppeteer_smoke.mjs+++ b/moli-cdp-smoke/moli_cdp_smoke/puppeteer_smoke.mjs@@ -7,6 +7,7 @@ import path from 'node:path';import { runPuppeteerAriaQuerySmoke } from './puppeteer_aria_queries.mjs';import { runPuppeteerShadowAccessibilitySmoke } from './puppeteer_shadow_accessibility.mjs';import { runPuppeteerAccessibilityVisibilitySmoke } from './puppeteer_accessibility_visibility.mjs';+import { runPuppeteerAccessibilityNamesSmoke } from './puppeteer_accessibility_names.mjs';import {activateXPathElement,runPuppeteerDomInteractionSmoke,@@ -458,6 +459,12 @@ async function main() {);record('puppeteer_accessibility_visibility_workflow', accessibilityVisibilityResult);+ const accessibilityNamesResult = await withTimeout(+ 'Puppeteer accessibility descendant names',+ runPuppeteerAccessibilityNamesSmoke(page),+ );+ record('puppeteer_accessibility_names_workflow', accessibilityNamesResult);+const domInteractionResult = await withTimeout('Puppeteer DOM interaction matrix',runPuppeteerDomInteractionSmoke(page),diff --git a/moli-dom/src/accessibility/ax_dom.rs b/moli-dom/src/accessibility/ax_dom.rsindex cf2debe6e..c18cfb7df 100644--- a/moli-dom/src/accessibility/ax_dom.rs+++ b/moli-dom/src/accessibility/ax_dom.rs@@ -1,8 +1,4 @@-use crate::{NodeData, NodeId, native::DomHost};--use super::ax_projection::{AxTreeProjection, AxUnavailable};--pub(super) const MAX_AX_NAME_VISITED_OBJECTS: usize = 100;+use crate::{NodeId, native::DomHost};pub(super) fn ax_child_ids(document: &DomHost,@@ -48,56 +44,3 @@ fn composed_child_ids(document: &DomHost, node_id: NodeId) -> Option<Vec<NodeId>}None}--pub(super) fn ax_content_text(- document: &DomHost,- projection: &mut AxTreeProjection<'_, '_>,- node_id: NodeId,- include_hidden: bool,-) -> Result<String, AxUnavailable> {- if projection.state(node_id)?.hides_contents && !include_hidden {- return Ok(String::new());- }- let mut text = String::new();- let mut pending = ax_child_ids_reversed(document, node_id)- .map(Some)- .collect::<Vec<_>>();- let mut remaining = MAX_AX_NAME_VISITED_OBJECTS;- while let Some(entry) = pending.pop() {- let Some(node_id) = entry else {- text.push(' ');- continue;- };- if remaining == 0 {- break;- }- remaining -= 1;- let Some(node) = document.node(node_id) else {- continue;- };- let state = projection.state(node_id)?;- if state.inert_reason.is_some()- || (!include_hidden && (state.not_rendered || state.aria_hidden_root.is_some()))- {- continue;- }- // Unrendered ARIA references have no shared inline formatting context.- if state.block_level || (include_hidden && state.not_rendered) {- text.push(' ');- pending.push(None);- }- if state.hides_contents && !include_hidden {- continue;- }- match node.kind() {- NodeData::Text(value) if include_hidden || state.visibility_visible => {- text.push_str(value.data())- }- NodeData::CDataSection(value) if include_hidden || state.visibility_visible => {- text.push_str(value.data())- }- _ => pending.extend(ax_child_ids_reversed(document, node_id).map(Some)),- }- }- Ok(text)-}diff --git a/moli-dom/src/accessibility/ax_properties.rs b/moli-dom/src/accessibility/ax_properties.rsindex 8da671480..d896dc2f9 100644--- a/moli-dom/src/accessibility/ax_properties.rs+++ b/moli-dom/src/accessibility/ax_properties.rs@@ -7,14 +7,38 @@ use serde_json::{Value, json};use std::collections::HashSet;use url::Url;-use super::ax_dom::{MAX_AX_NAME_VISITED_OBJECTS, ax_content_text};+use super::ax_dom::ax_child_ids;use super::ax_projection::{AxTreeProjection, AxUnavailable};use super::ax_roles::{ax_role, heading_level};-// Keep relation recursion within Blink's text-alternative object budget.+const MAX_AX_NAME_VISITED_OBJECTS: usize = 100;++#[derive(Default)]+struct AxName {+ value: String,+ from_contents: bool,+}++impl AxName {+ fn contents(value: String) -> Self {+ Self {+ value,+ from_contents: true,+ }+ }++ fn alternative(value: String) -> Self {+ Self {+ value,+ from_contents: false,+ }+ }+}+#[derive(Debug, Clone, Copy, PartialEq, Eq)]enum AxNameTraversal {Direct,+ Contents,AriaReference { include_hidden: bool },NativeLabel,}@@ -36,6 +60,13 @@ impl AxNameTraversal {})}++ fn descendants(self) -> Self {+ match self {+ Self::AriaReference { .. } => self,+ _ => Self::Contents,+ }+ }}pub(super) fn ax_name(@@ -45,13 +76,16 @@ pub(super) fn ax_name() -> Result<String, AxUnavailable> {match node.kind() {NodeData::Document(_) => Ok(ax_document_name(document)),- NodeData::Element(_) => ax_node_name(- document,- projection,- node.id(),- AxNameTraversal::Direct,- &mut HashSet::new(),- ),+ NodeData::Element(_) => Ok(normalize_ax_whitespace(+ &ax_node_name(+ document,+ projection,+ node.id(),+ AxNameTraversal::Direct,+ &mut HashSet::new(),+ )?+ .value,+ )),NodeData::Text(text) => Ok(normalize_ax_whitespace(text.data())),NodeData::CDataSection(cdata) => Ok(normalize_ax_whitespace(cdata.data())),_ => Ok(String::new()),@@ -66,28 +100,44 @@ fn ax_node_name(node_id: NodeId,traversal: AxNameTraversal,visited: &mut HashSet<NodeId>,-) -> Result<String, AxUnavailable> {+) -> Result<AxName, AxUnavailable> {let state = projection.state(node_id)?;- if state.inert_reason.is_some() || (!traversal.includes_hidden() && state.hidden_for_name()) {- return Ok(String::new());+ if state.inert_reason.is_some()+ || (!traversal.includes_hidden()+ && (state.not_rendered+ || state.aria_hidden_root.is_some()+ || (traversal == AxNameTraversal::Direct && !state.visibility_visible)))+ {+ return Ok(AxName::default());}- if visited.len() >= MAX_AX_NAME_VISITED_OBJECTS || !visited.insert(node_id) {- return Ok(String::new());+ // Blink shares its visited-object budget between contents and relations.+ // ARIA targets may be revisited, with further labelledby traversal disabled.+ if visited.len() > MAX_AX_NAME_VISITED_OBJECTS+ || (visited.contains(&node_id)+ && !matches!(traversal, AxNameTraversal::AriaReference { .. }))+ {+ return Ok(AxName::default());}+ visited.insert(node_id);let node = document.node(node_id).ok_or(AxUnavailable)?;- let name = match node.kind() {+ Ok(match node.kind() {NodeData::Element(element) => ax_element_name(document, projection, node_id, node, element, traversal, visited,)?,- NodeData::Text(text) => normalize_ax_whitespace(text.data()),- NodeData::CDataSection(cdata) => normalize_ax_whitespace(cdata.data()),- NodeData::Document(_) => ax_document_name(document),- _ => String::new(),- };-- visited.remove(&node_id);- Ok(name)+ NodeData::Text(text) if traversal.includes_hidden() || state.visibility_visible => {+ AxName::contents(text.data().to_owned())+ }+ NodeData::CDataSection(cdata)+ if traversal.includes_hidden() || state.visibility_visible =>+ {+ AxName::contents(cdata.data().to_owned())+ }+ NodeData::DocumentFragment(_) => AxName::contents(ax_content_text(+ document, projection, node_id, traversal, visited,+ )?),+ _ => AxName::default(),+ })}fn ax_element_name(@@ -98,7 +148,24 @@ fn ax_element_name(element: &Element,traversal: AxNameTraversal,visited: &mut HashSet<NodeId>,-) -> Result<String, AxUnavailable> {+) -> Result<AxName, AxUnavailable> {+ // Slots cannot be named, but their assigned/fallback contents contribute.+ if element.is_html_element("slot") {+ return Ok(if traversal.includes_contents() {+ AxName::contents(ax_content_text(+ document, projection, node_id, traversal, visited,+ )?)+ } else {+ AxName::default()+ });+ }+ // A visibility:hidden wrapper can have visible descendants. Its own+ // alternative is hidden, but the contents traversal must reach them.+ if !traversal.includes_hidden() && !projection.state(node_id)?.visibility_visible {+ return Ok(AxName::contents(ax_content_text(+ document, projection, node_id, traversal, visited,+ )?));+ }if traversal.follows_aria_labelledby()&& let Some(labelled_by) = element.attribute("aria-labelledby")@@ -120,45 +187,49 @@ fn ax_element_name(AxNameTraversal::AriaReference { include_hidden },visited,)?;- if !part.is_empty() {- parts.push(part);+ if !part.value.is_empty() {+ parts.push(part.value);}}- return Ok(parts.join(" "));+ return Ok(AxName::alternative(parts.join(" ")));}}if let Some(aria_label) = element.attribute("aria-label") {let aria_label = normalize_ax_whitespace(aria_label);if !aria_label.is_empty() {- return Ok(aria_label);+ return Ok(AxName::alternative(aria_label));}}if let Some(native_name) =ax_native_element_name(document, projection, node_id, element, visited)?{- return Ok(native_name);+ return Ok(AxName::alternative(native_name));}- // Relation targets contribute contents independently of their AX inclusion.- // Direct traversal retains the role's name-from-content restrictions.+ // Recursive descendants contribute text alternatives even when their own+ // role does not take a name from contents.let content =if traversal.includes_contents() || ax_name_comes_from_contents(document, node, element) {- normalize_ax_whitespace(&ax_content_text(- document,- projection,- node_id,- traversal.includes_hidden(),- )?)+ ax_content_text(document, projection, node_id, traversal, visited)?} else {String::new()};- if !content.is_empty() {- return Ok(content);+ if content.chars().any(|character| !character.is_whitespace()) {+ return Ok(AxName::contents(content));+ }++ // Generic descendants do not acquire a name solely from a tooltip.+ if matches!(+ traversal,+ AxNameTraversal::Contents | AxNameTraversal::NativeLabel+ ) && ax_role(node) == "generic"+ {+ return Ok(AxName::contents(content));}- Ok(element+ let alternative = element.attribute("title").map(normalize_ax_whitespace).filter(|title| !title.is_empty())@@ -172,7 +243,57 @@ fn ax_element_name(.flatten().filter(|placeholder| !placeholder.is_empty())})- .unwrap_or_default())+ .unwrap_or_default();+ Ok(if alternative.is_empty() {+ AxName::contents(content)+ } else {+ AxName::alternative(alternative)+ })+}++fn ax_content_text(+ document: &DomHost,+ projection: &mut AxTreeProjection<'_, '_>,+ node_id: NodeId,+ traversal: AxNameTraversal,+ visited: &mut HashSet<NodeId>,+) -> Result<String, AxUnavailable> {+ if projection.state(node_id)?.hides_contents && !traversal.includes_hidden() {+ return Ok(String::new());+ }+ let mut text = String::new();+ for child in ax_child_ids(document, node_id) {+ if visited.len() > MAX_AX_NAME_VISITED_OBJECTS {+ break;+ }+ let state = projection.state(child)?;+ if state.inert_reason.is_some()+ || (!traversal.includes_hidden()+ && (state.not_rendered || state.aria_hidden_root.is_some()))+ {+ continue;+ }+ let name = ax_node_name(+ document,+ projection,+ child,+ traversal.descendants(),+ visited,+ )?;+ // Inline DOM text stays contiguous. Author-provided alternatives and+ // block boundaries separate words, as in Blink's TextFromDescendants.+ let separate = (!name.value.is_empty() && !name.from_contents)+ || state.block_level+ || (traversal.includes_hidden() && state.not_rendered);+ if separate {+ text.push(' ');+ }+ text.push_str(&name.value);+ if separate {+ text.push(' ');+ }+ }+ Ok(text)}fn ax_native_element_name(@@ -194,8 +315,8 @@ fn ax_native_element_name(AxNameTraversal::NativeLabel,visited,)?;- if !part.is_empty() {- parts.push(part);+ if !part.value.is_empty() {+ parts.push(part.value);}}return Ok(Some(parts.join(" ")));@@ -936,6 +1057,107 @@ mod tests {assert_eq!(node_name(&document, button), "");}+ #[test]+ fn contents_use_descendant_aria_and_native_text_alternatives() {+ for tag in ["span", "svg", "img"] {+ let (mut document, root) = document_with_root();+ let button = document.create_element("button");+ document.append_child(root, button);+ let child = if tag == "svg" {+ document+ .create_element_ns(Some("http://www.w3.org/2000/svg"), tag)+ .expect("SVG element")+ } else {+ document.create_element(tag)+ };+ document.append_child(button, child);+ document.set_attribute(+ child,+ if tag == "img" { "alt" } else { "aria-label" },+ "Copy",+ );+ append_text(&mut document, child, "Visual fallback");+ assert_eq!(node_name(&document, button), "Copy", "{tag}");++ document.set_attribute(button, "aria-label", "Explicit");+ assert_eq!(node_name(&document, button), "Explicit", "{tag}");+ }+ }++ #[test]+ fn contents_preserve_inline_text_and_separate_author_alternatives() {+ let (mut document, root) = document_with_root();+ let button = document.create_element("button");+ document.append_child(root, button);+ append_text(&mut document, button, "Save");+ let span = document.create_element("span");+ document.append_child(button, span);+ append_text(&mut document, span, "document");+ append_text(&mut document, button, "now");+ assert_eq!(node_name(&document, button), "Savedocumentnow");+ document.set_attribute(span, "aria-label", "document");+ assert_eq!(node_name(&document, button), "Save document now");+ }++ #[test]+ fn whitespace_contents_preserve_inline_spacing_and_tooltip_names() {+ let (mut document, root) = document_with_root();+ let button = document.create_element("button");+ document.set_attribute(button, "title", "Tooltip");+ document.append_child(root, button);+ let span = document.create_element("span");+ document.append_child(button, span);+ append_text(&mut document, span, " \n ");+ assert_eq!(node_name(&document, button), "Tooltip");++ let before = document.create_text_node("Before");+ document.insert_before(button, before, Some(span));+ append_text(&mut document, button, "After");+ assert_eq!(node_name(&document, button), "Before After");+ }++ #[test]+ fn contents_and_relations_share_cycle_detection() {+ let (mut document, root) = document_with_root();+ let button = document.create_element("button");+ document.set_attribute(button, "id", "button");+ document.append_child(root, button);+ append_text(&mut document, button, "Prefix");+ let span = document.create_element("span");+ document.set_attribute(span, "aria-labelledby", "button");+ document.set_attribute(span, "aria-label", "Fallback");+ document.append_child(button, span);+ append_text(&mut document, button, "Suffix");+ assert_eq!(+ node_name(&document, button),+ "Prefix Prefix Fallback Suffix"+ );++ document.set_attribute(span, "id", "self");+ document.set_attribute(span, "aria-labelledby", "self");+ assert_eq!(node_name(&document, button), "Prefix Fallback Suffix");+ }++ #[test]+ fn contents_and_relations_share_the_object_budget() {+ for depth in [99, 100] {+ let (mut document, root) = document_with_root();+ let button = document.create_element("button");+ document.append_child(root, button);+ let mut parent = button;+ for _ in 0..depth {+ let span = document.create_element("span");+ document.append_child(parent, span);+ parent = span;+ }+ append_text(&mut document, parent, "End");+ assert_eq!(+ node_name(&document, button),+ if depth == 99 { "End" } else { "" }+ );+ }+ }+fn alternating_relation_chain_name(pair_count: usize) -> String {let (mut document, root) = document_with_root();diff --git a/moli-dom/src/accessibility/tests.rs b/moli-dom/src/accessibility/tests.rsindex 5798dc7a7..ab997e428 100644--- a/moli-dom/src/accessibility/tests.rs+++ b/moli-dom/src/accessibility/tests.rs@@ -532,6 +532,50 @@ fn required_content_and_child_id_styles_fail_the_whole_request() {}}+#[test]+fn descendant_text_alternatives_read_only_required_external_styles() {+ let (mut document, host) = document_with_host();+ let target = append_element(&mut document, host, "button");+ let child = append_element(&mut document, target, "span");+ document.set_attribute(child, "aria-labelledby", "external");+ let root = document.document_node_id();+ let label = append_element(&mut document, root, "span");+ document.set_attribute(label, "id", "external");+ document.set_attribute(label, "aria-label", "Copy");+ let unrelated = append_element(&mut document, root, "div");+ for query in [+ AccessibilityRequest::Node,+ AccessibilityRequest::Partial {+ fetch_relatives: false,+ },+ ] {+ let mut styles = RecordingStyles::new(&document);+ styles.facts.insert(+ label,+ AccessibilityStyle {+ display_none: true,+ visibility_visible: true,+ hides_contents: false,+ block_level: false,+ },+ );+ styles.missing.insert(unrelated);+ let nodes = request(&document, &mut styles, target, query).expect("local named AX node");+ assert_eq!(node_by_id(&nodes, target)["name"]["value"], "Copy");+ assert_eq!(+ styles.reads.iter().copied().collect::<HashSet<_>>(),+ HashSet::from([host, target, child, label])+ );+ styles.assert_read_once();++ styles.missing.insert(label);+ assert!(+ request(&document, &mut styles, target, query).is_none(),+ "required descendant reference styles must not become an empty name"+ );+ }+}+#[test]fn full_tree_does_not_read_styles_below_a_not_rendered_branch() {let (mut document, host) = document_with_host();