Skip to content

read_page returns nothing under an element that has zero size #47

Open

Description

@pallaoro

read_page drops an element's whole subtree when that element itself measures 0×0, even though its children are visible and interactive.

Repro

<!doctype html><title>repro</title>
<button style="position:absolute;left:100px;top:100px;width:200px;height:80px"
        onclick="window.clicks=(window.clicks||0)+1">click</button>

read_page on this page returns only the title:

# repro

The button is missing. computer can still click it at (200, 140), and find "click" should hit the same walker.

Cause

walk() in extension/content/ax-tree.js returns before visiting children when isVisible() is false (line 143), and isVisible() requires the element's own getBoundingClientRect() to be non-zero (line 19). Here <body> has zero height, because its only child is absolutely positioned, so the walk stops at the root.

The same pruning would hide:

  • everything inside a display: contents wrapper, which has no box of its own (common in component frameworks and web components);
  • children of any zero-height container whose content overflows it, such as fixed or absolutely positioned app shells.

Suggested direction

Only prune a subtree for reasons that really hide descendants: display: none, hidden, aria-hidden="true", and visibility: hidden (where children can override it). Treat a zero-size box as "don't list this element" rather than "don't descend". find uses the same walker and has the same gap (get_page_text reads innerText and is unaffected). Add a test page covering a zero-height body, display: contents, and an overflowing zero-height container.

Found while testing in Chrome for Testing 155 (headless). Running read_page with and without other CDP clients attached gave the same result, so this isn't related to debugger sharing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions