Skip to content

[py] [js] interaction-readiness reference implementation: quiescence oracle as a BiDi preload - #18255

Draft
AutomatedTester wants to merge 53 commits into
trunkfrom
py-quiescence-bidi-preload
Draft

AutomatedTester wants to merge 53 commits into
trunkfrom
py-quiescence-bidi-preload

Conversation

@AutomatedTester

@AutomatedTester AutomatedTester commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

🔗 Related Issues

Reference implementation for ADR #17886, "Selenium waits for interaction readiness before it interacts". Draft: this exists so the ADR has something concrete to point at and CI to run against. It is not the proposed API shape, and it isn't ready to merge until the ADR is accepted.

💥 What does this PR do?

Adds a page-script oracle that answers "is this page done?" and "can this element be interacted with right now?", installed as a BiDi preload script.

  • Pending-work ledger. Tracks timers, intervals, animation frames, fetch, XHR, WebSocket and subresource loads (images, media, frames, objects, dynamically inserted scripts and stylesheets). Long-delay timers, long-period intervals, and periodic tasks observed to have no effect are classified inert, so clocks and keep-alive polls don't block.
  • DOM settledness. No meaningful mutation for a settle window. Layout-irrelevant attribute churn, regions annotated inert, and periodic noise don't count; running CSS animations and transitions do. Settling can be scoped to a subtree, and open shadow roots are observed.
  • Element actionability. The element must be visible, enabled (including aria-disabled and the fieldset/legend exception), editable when the interaction writes, in the viewport, unobstructed at its interaction point, and not moving. The checks that apply depend on the interaction. Viewport and obstruction are checked in every ancestor document up to the first cross-origin one.
  • Python. The binding registers the atom as a preload on BiDi navigation and exposes driver.wait_for_dom_settled() and driver.wait_until_actionable(). ADR decisions 4 and 5 replace these two methods; they're here to make the semantics testable.
  • @selenium/atoms. The atom is javascript/atoms/typescript/quiescence.ts and is published as @selenium/atoms/quiescence (installQuiescence). The function is self-contained, so other tools can install it with installQuiescence.toString() as a BiDi, CDP or Playwright preload.

🔧 Implementation Notes

  • The interaction path consults actionability only (ADR decisions 1 and 2). Settle-then-act is opt-in per call. Composing them by default made every click on a long-polling page pay the whole settle timeout.
  • The halting problem is designed in, not ignored. An element moved by an infinite-iteration animation is reported actionable, with the animated node named in perpetualMotion, because waiting for it provably never ends. Sub-pixel motion under 0.5px doesn't count as movement.
  • Limits are reported, not hidden. A check that couldn't be made is listed in unobservable, e.g. cross-origin-ancestor, closed-shadow, or late-install when the atom was injected into an already-loaded document rather than preloaded. Each of these means "couldn't check", not "passed". The full list of limitations is in the header of quiescence.ts, and ADR decision 10 mirrors it.
  • TypeScript port. A 1:1 port from the original JS. The four suites passed unchanged before and after. It builds through the same ATOMS registry as every other TypeScript atom, and package.json was regenerated with generate-exports.cjs.
  • Built natively, not vendored, after discussion with Jim Evans. Scenario coverage was cross-checked against jimevans/acquiescence's test suite.

💡 Additional Considerations

Open before this can leave draft:

  • ADR question 3, naming: the final names and shapes of the narrow named exports (decision 8).
  • Sync vs stable: resolved in the ADR (71677c3): pendingWork and settledness are synchronous; actionability returns a promise because stability is sampled across animation frames, which is what this implementation does.
  • Not built yet (blocked on ADR acceptance): the se:interactionReadiness capability, the implicit-wait replacement, client-side element-location retry, readiness error subclasses, and the settled page load strategy.
  • Size: this is large because it's a reference implementation. Once the ADR settles I'd expect to split it, e.g. the atom and package first, then the binding.
  • Cross-binding parity is follow-up work; only Python consumes the atom today.
  • High-risk areas touched: javascript/atoms/ (BUILD, defs.bzl registry, package.json, index.ts; additive only, no existing atom changes) and common/src/web/ (two new fixtures).

Tests: 134 browser tests across four suites under py/test/selenium/webdriver/common/bidi/: quiescence 27, DOM quiescence 21, resource quiescence 15, element actionability 71. All pass on Chrome over BiDi. Also //javascript/atoms:quiescence-portable (verified to fail when the function references module scope), atoms-load-in-node and exports-up-to-date.

🤖 AI assistance

  • No substantial AI assistance used
  • AI assisted (complete below)
    • Tool(s): Claude Code
    • What was generated: most of the atom implementation, its TypeScript port, the Python wiring, and the test suites, written test-first (RED/GREEN commits) under my direction
    • I reviewed all AI output and can explain the change

🔄 Types of changes

  • New feature (non-breaking change which adds functionality and tests!)

🤖 Generated with Claude Code

@selenium-ci

Copy link
Copy Markdown
Member

/agentic_describe

@selenium-ci selenium-ci added C-py Python Bindings B-atoms JavaScript chunks generated by Google closure B-build Includes scripting, bazel and CI integrations B-devtools Includes everything BiDi or Chrome DevTools related labels Oct 28, 2026
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Prototype interaction readiness with a BiDi quiescence preload

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Add a preload oracle for pending work, DOM settledness, and element actionability.
• Expose experimental Python waits and publish the installer through @selenium/atoms.
• Add browser coverage for readiness behavior and limits that page scripts cannot observe.
Diagram

graph TD
  Driver["Python WebDriver"] --> Navigate["BiDi navigation"] --> Atom["Packaged atom"] --> Oracle["Page oracle"] --> Ledger["Pending-work ledger"]
  Oracle --> DOM["DOM observer"]
  Oracle --> Action["Actionability checks"]
  Driver --> Oracle
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Implement readiness in browser-native BiDi
  • ➕ Could observe more asynchronous and cross-origin activity.
  • ➕ Would avoid wrapping page APIs.
  • ➖ Requires protocol agreement and browser implementations before the semantics can be tested broadly.
  • ➖ Does not provide a near-term portable ADR reference.

Recommendation: Keep the preload as an experimental reference implementation rather than a final API. It supports testing the ADR now; browser-native BiDi is the stronger long-term solution for the reported observability gaps.

Files changed (18) +4061 / -5

Enhancement (5) +1582 / -4
index.tsExport quiescence installer +1/-0

Export quiescence installer

• Adds 'installQuiescence' to the package's main exports.

javascript/atoms/index.ts

quiescence.tsImplement page-script readiness oracle +1373/-0

Implement page-script readiness oracle

• Installs pending-work and resource tracking, DOM settledness checks, and interaction-specific actionability checks. Exposes policies, inert annotations, diagnostics, and optional settle-then-act behavior.

javascript/atoms/typescript/quiescence.ts

generate_bidi.pyGive generated browsing contexts driver access +1/-1

Give generated browsing contexts driver access

• Extends generated 'browsingContext' construction to retain a driver reference.

py/generate_bidi.py

bidi_enhancements_manifest.pyRegister preload before BiDi navigation +23/-0

Register preload before BiDi navigation

• Adds a 'navigate' enhancement that requests preload registration before sending the navigation command.

py/private/bidi_enhancements_manifest.py

webdriver.pyExpose experimental Python readiness waits +184/-3

Expose experimental Python readiness waits

• Registers the packaged preload once for BiDi sessions, with a current-document fallback and failure logging. Adds DOM-settled and actionable waits with script-timeout management.

py/selenium/webdriver/remote/webdriver.py

Tests (9) +2422 / -0
quiescence.htmlAdd interactive quiescence harness +121/-0

Add interactive quiescence harness

• Provides controls for timers, network requests, periodic work, and inert annotations. Displays state transitions and blockers.

common/src/web/quiescence.html

slow_loading_resources.htmlAdd slow parser-created image fixture +10/-0

Add slow parser-created image fixture

• Supplies a delayed image for testing resource tracking during navigation.

common/src/web/slow_loading_resources.html

BUILD.bazelRegister atom portability test +12/-0

Register atom portability test

• Adds a Bazel test of the compiled installer's standalone source text.

javascript/atoms/BUILD.bazel

quiescence-portable.mjsTest standalone installer source +47/-0

Test standalone installer source

• Evaluates 'installQuiescence.toString()' in an isolated VM and verifies timer tracking and quiet waiting.

javascript/atoms/typescript/quiescence-portable.mjs

dom_quiescence_tests.pyTest DOM settledness and observation limits +430/-0

Test DOM settledness and observation limits

• Covers mutation classification, scoped waits, animations, shadow roots, Python waits, and late-install diagnostics.

py/test/selenium/webdriver/common/bidi/dom_quiescence_tests.py

element_actionability_tests.pyTest interaction-specific readiness +1055/-0

Test interaction-specific readiness

• Covers element state, scrolling, obstruction, stability, optional settling, shadow DOM, frames, and perpetual motion.

py/test/selenium/webdriver/common/bidi/element_actionability_tests.py

quiescence_tests.pyTest preload lifecycle and pending work +433/-0

Test preload lifecycle and pending work

• Covers navigation persistence; timer, network, socket, interval, and animation-frame blockers; and policy and annotation behavior.

py/test/selenium/webdriver/common/bidi/quiescence_tests.py

resource_quiescence_tests.pyTest subresource blockers +294/-0

Test subresource blockers

• Covers images, frames, scripts, stylesheets, objects, media, completion, and resource policies.

py/test/selenium/webdriver/common/bidi/resource_quiescence_tests.py

webserver.pyServe delayed readiness-test responses +20/-0

Serve delayed readiness-test responses

• Adds a capped '/slow' endpoint returning delayed text or PNG responses.

py/test/selenium/webdriver/common/webserver.py

Documentation (1) +35 / -0
README.npm.mdDocument quiescence preload usage +35/-0

Document quiescence preload usage

• Shows BiDi, CDP, and Playwright installation and example waits. Identifies the API as an ADR prototype.

javascript/atoms/README.npm.md

Other (3) +22 / -1
package.jsonPublish quiescence subpath +6/-1

Publish quiescence subpath

• Adds '@selenium/atoms/quiescence' and its declaration to export and type mappings.

javascript/atoms/package.json

defs.bzlRegister quiescence atom +9/-0

Register quiescence atom

• Includes the installer in generated atom builds.

javascript/atoms/typescript/defs.bzl

BUILD.bazelPackage compiled preload for Python +7/-0

Package compiled preload for Python

• Copies the generated atom into the Selenium Python package and adds its library dependency.

py/BUILD.bazel

@qodo-code-review

qodo-code-review Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (1) 📜 Skill insights (0)

Grey Divider


Action required

1. Navigation loses its generated contract ✓ Resolved

Resolving commit: 029b576

Resolution reason
Removed the custom navigate extra_method that replaced the generated method and moved the
quiescence preload registration into a before_execute enhancement for browsingContext.navigate, so
the schema-generated method (with its typed signature, serialization, and contract handling) is
retained.
Description
The enhancement manifest defines a replacement navigate method with untyped Any parameters and
raw command construction instead of extending the schema-generated method. Because the generator
excludes any command whose name appears in extra_methods, existing BrowsingContext.navigate
callers receive the replacement behavior and no longer get the generated signature, serialization,
and contract handling.

2. Page errors in timer callbacks vanish silently ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
At head, runTracked (lines 239-250) records the effect flag from finally via a record callback and
does not return from finally, so exceptions from fn.apply propagate to the page's error handlers.
Description
runTracked returns effectful from a finally block, overriding exceptions thrown by fn.apply.
When a page interval callback fails, or an animation-frame chain reaches the loop threshold and its
callback fails, the exception never reaches the browser’s console, window.onerror, error-reporting
SDKs, or BiDi log.entryAdded JavaScript-error events on pages with the preload installed.

3. Early page changes escape observation ✓ Resolved

Resolving commit: 4d12d81

Resolution reason
The current code observes the Document node rather than documentElement, so the observer attaches at
preload time before the root element exists and DOM changes made before DOMContentLoaded are
captured. The same applies to ensureObserver() for the effect-tracking observer.
Description
ensureDomObserver() returns when document.documentElement does not yet exist and is retried only
at DOMContentLoaded. If the preload runs before the root exists, DOM changes and dynamically
started resources before that event are absent from the observers despite installation preceding
page scripts.

View high (1)
4. Long readiness waits are killed by the browser ✓ Resolved

Resolving commit: 8f6a061

Resolution reason
The PR head no longer uses the self.timeouts.script = needed pattern. A new helper
_script_timeout_of_at_least (webdriver.py lines ~656-680 at head) reads the script timeout via a
raw Command.GET_TIMEOUTS call and widens it with a direct Command.SET_TIMEOUTS execute,
restoring it in finally with another direct SET_TIMEOUTS. Both wait_for_dom_settled and
wait_until_actionable wrap their in-page waits with this helper, so the browser's script timeout
is actually raised for the wait and the diagnostic result can return. The docstring explicitly notes
that assigning to a Timeouts attribute changes nothing, so the bug is addressed by a different but
valid implementation.
Description
self.timeouts.script = needed sets an attribute on the throwaway Timeouts object returned by the
timeouts property getter; the session's script timeout is never changed, and the finally restore
is a no-op too. With the default 30s script timeout, any
wait_for_dom_settled/wait_until_actionable call with timeout of 25s or more raises a
script-timeout error before the in-page wait can return its diagnostic result.


Remediation recommended

5. Navigate silently patches every page 📘 Rule violation ⚙ Maintainability
Description
The before_execute hook on the generated browsingContext.navigate calls
_ensure_quiescence_preload() on every navigation, and the first call registers a BiDi preload that
wraps setTimeout, setInterval, requestAnimationFrame, fetch, XHR and WebSocket and adds
window.__quiescence to every later page in the session. Existing users of the stable public
navigate method get this global side effect without opting in, and neither its signature nor its
docstring discloses it.
Code

py/private/bidi_enhancements_manifest.py[R224-233]

+        "navigate": {
+            "before_execute": [
+                "# Register the quiescence preload (once) so window.__quiescence is",
+                "# installed on the document this navigation creates. Unlike the classic",
+                "# GET command, browsingContext.navigate does not wait for the page to",
+                "# load, so the quiescence oracle is registered here rather than in get().",
+                "if self._driver is not None:",
+                "    self._driver._ensure_quiescence_preload()",
+            ],
+        },
Evidence
The navigate enhancement runs _ensure_quiescence_preload() unconditionally before every
browsingContext.navigate call, so an existing public method gains a page-wide side effect without
an explicit request or an opt-out. This changes default public behaviour, which the compliance rule
forbids without an explicit request.

AGENTS.md: Preserve Public API and ABI Compatibility and Deprecate Before Removal
py/private/bidi_enhancements_manifest.py[224-233]
py/selenium/webdriver/remote/webdriver.py[621-653]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The generated `browsingContext.navigate` now registers the quiescence preload on every call, which injects global wrappers into every page the session loads. Callers who only want navigation get this side effect silently.

## Fix Focus Areas
- py/private/bidi_enhancements_manifest.py[224-233]
- py/selenium/webdriver/remote/webdriver.py[621-653]

## Recommended Fix
Remove the `before_execute` hook from the `navigate` enhancement. Register the preload only from `wait_for_dom_settled()` and `wait_until_actionable()`, which already call `_ensure_quiescence_preload()`. If navigation-time installation is required, make it opt-in through a documented session or capability flag, and state the behaviour change in the docstring.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


6. Shadow-root waits miss ongoing changes ✓ Resolved

Resolving commit: 029b576

Resolution reason
withinRoot now ORs plain DOM containment with composed containment, so a ShadowRoot scope matches
its descendants and a shadow host scope still matches its shadow tree; a regression test scopes a
wait to a ShadowRoot while its children churn.
Description
withinRoot() now uses composed-tree containment, but composedParent() skips the ShadowRoot
when walking from one of its descendants to the host. When a caller passes an open shadow root
directly as the scope, awaitDomSettled() can report settled: true after one window despite
continuing mutations inside it.

7. Script-timeout adjustment failures are hidden at debug level ✓ Resolved

Resolving commit: 029b576

Resolution reason
Timeout-adjustment failures are now logged at warning level with an explanation that the wait may be
aborted by the browser's script timeout, instead of being hidden at debug level. The failure is
still not propagated.
Description
_script_timeout_of_at_least() catches failures to read or raise the session script timeout, logs
them only at debug level, and proceeds with the async wait. If the original timeout is shorter than
the requested wait, the browser can abort wait_for_dom_settled or wait_until_actionable before
the in-page oracle returns a diagnostic result, leaving default-configured users without an
explanation that the timeout adjustment failed.

View medium (22)
8. A focused test run can stall on shutdown ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
Shortened the unread-body server delay from 60s (capped at 30s) to 3s in the test, and made the
server's body write tolerant of client disconnect, so the request thread no longer sleeps for 30
seconds and shutdown is no longer stalled for that long.
Description
test_unread_fetch_body_does_not_block starts a request whose handler sleeps for 30 seconds after
sending headers, but never consumes or cancels the body. When that test is run alone, its assertion
can finish within five seconds while the server's non-daemon request thread keeps the test process
alive for the remainder of the sleep.

9. Repeated replacements look settled ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
The structural check now also fires when any added or removed node is an element
(hasElement(rec.addedNodes) || hasElement(rec.removedNodes)), so an equal-count element-for-element
replacement re-promotes the target (valueOnly=false, classifiedNoise=false). The comment explicitly
calls out that swapping one element for another at a steady cadence is a re-render, not a ticking
value. Additionally, classifiedNoise is cleared when the interval coefficient of variation exceeds
cadenceCV. This addresses the equal-count replacement case without the suggested test, using a
different implementation.
Description
updateFingerprint() calls a child-list mutation structural only when its added and removed node
counts differ. Replacing one child with another at a regular cadence preserves valueOnly, so those
structural replacements can be classified as noise and stop delaying a DOM-settled wait.

10. Console log listeners get flooded with debug messages ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
The console.debug call is now gated behind a new policy flag debugLog (default false) added to the
policy object, so by default no console entry is written on state transitions. The listener
notification via onStateChanged is unchanged. This is an opt-in gate rather than the suggested
debugConsole flag name, but it addresses the same issue: the debug channel is off by default and
settable through setPolicy.
Description
Every quiet/busy transition in scheduleEmit runs `console.debug('[quiescence] stateChanged',
JSON.stringify(payload))`, and the payload serializes the full blocker list. After a single
browsing_context.navigate(), the preload stays registered for every later document in the session.
Each timer, fetch or XHR start and finish then emits a console entry that shows up in users' BiDi
log.entryAdded / console-message handlers and in browser logs.

11. A mistyped scope silently waits on the whole page ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
A scoped wait whose root does not resolve no longer runs as an unscoped document-wide wait. It holds
until the root exists, and if it never resolves, finish() reports the missing scope via an
unobservable 'root-not-found' entry instead of silently reporting on unrelated regions.
Description
resolveRoot returns null when a string root selector matches nothing. Every caller
(awaitDomSettled, getActiveRegions, domLastMeaningfulTs, animationsActive) treats null as
"no scope". So driver.wait_for_dom_settled(root="#reslts"), or a root rendered only later, quietly
becomes a document-wide wait: unrelated churn elsewhere can make it time out, and the result gives
no sign that the scope was ignored.

12. Clipped controls appear actionable ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
Introduced clipsOverflow(cs), which returns true when any of overflow/overflowX/overflowY is
'hidden' or 'clip'. Both the visibility ancestor walk (replacing the inline hidden-only check) and
isClippingAncestor (which now uses clipsOverflow plus auto/scroll) now recognize overflow: clip.
Description
isClippingAncestor() omits overflow: clip, and the separate visibility check also recognizes
only overflow: hidden. A control wholly outside a clipped ancestor can retain a visible rectangle
and pass the hit test when that ancestor is the top hit-test result, causing readiness to report it
as actionable.

13. New script loads escape the quiet check ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
The SCRIPT branch now tracks a connected script's first src assignment when it has no inline text
(oldValue === null, text === ''), so the resource ledger holds the pending load instead of letting
the quiet wait finish early. Subsequent src changes on already-sourced scripts are still ignored to
avoid sticking.
Description
scanRecordsForResources() discards every src mutation on a SCRIPT, including the first
assignment to a connected script that previously had no source. When a page inserts an empty script
and later sets its src, the browser starts a fetch but the ledger has no resource entry, so quiet
waits can finish before it loads.

14. Later page updates remain invisible ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
Added a check in updateFingerprint that clears classifiedNoise when the interval coefficient of
variation exceeds domPolicy.cadenceCV ("Noise is a claim about a regular cadence; once the cadence
breaks, the target's updates count again until it settles back into a rhythm"). This re-evaluates
the noise classification before the mutation is judged, which is the core of the suggested fix,
though it is implemented as a cadence-CV check rather than a periodic-criteria re-evaluation in
isMeaningful. Also structural re-promotion now covers element add/remove.
Description
isMeaningful() rejects every mutation whose fingerprint has classifiedNoise, while
updateFingerprint() clears that flag only for a child-list change with unequal added and removed
counts. After regular text or attribute updates reach the noise threshold, a later update to that
same target—even after its cadence changes—cannot reset the settle window.

15. Eager image loads escape the quiet check ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
On a loading attribute change on an IMG, the scanner now calls trackResource on that image, so
switching an offscreen lazy image to eager adds a resource blocker instead of escaping the quiet
check.
Description
resourcePending() skips an image while its loading mode is lazy, but scanRecordsForResources()
does not reconsider it when loading changes. Changing an offscreen lazy image to eager starts
its fetch without adding a blocker, allowing quiet waits to finish during the load.

16. Users get a deprecation warning they never caused ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
Changed the preload registration to call the underlying BiDi script module
(self.script._script._add_preload_script) instead of the deprecated public Script wrapper, so no
DeprecationWarning is raised for the internal call and registration does not fail under
warnings-as-errors.
Description
_ensure_quiescence_preload calls self.script._add_preload_script(...). driver.script is the
public Script wrapper, which has no _add_preload_script, so the call falls through
Script.__getattr__, and that issues a DeprecationWarning ("driver.script._add_preload_script is
deprecated and will be removed") for every proxied name. The first browsing_context.navigate(),
wait_for_dom_settled() or wait_until_actionable() in each BiDi session therefore warns about an
internal call the user never wrote. Under -W error (or filterwarnings = error), registration
fails, the broad except catches it, and readiness is silently turned off for the session.

17. Policy changes leave old requests miscounted ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
setPolicy() now iterates the ledger after compileIgnores() and recomputes e.ignored =
urlIgnored(e.meta.url) for entries whose type is fetch, fetch-body, xhr, or resource
(URL_IGNORABLE_TYPES). In-flight requests therefore follow the newly active ignore patterns in
either direction, which is the behavior the finding asks for. The fix is implemented inside
setPolicy rather than in a separate recompute step, but it covers the same ledger entries the
suggested fix names.
Description
setPolicy() recompiles URL ignore patterns but does not update the ignored flags already stored
on ledger entries. If a policy changes while a fetch, XHR, or resource load is pending, quiet checks
continue using the policy that was in force when that load began, whether the new policy would
include or exclude it.

18. Scoped waits miss shadow-tree changes ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
withinRoot now uses composedContains(root, node), which walks the composed tree via composedParent
(crossing shadow root -> host and slot assignments), so scoped waits cover descendants inside open
shadow roots of the scoped host. Also domLastMeaningfulTs, getActiveRegions, and animationsActive
use the same withinRoot helper.
Description
withinRoot() uses root.contains(node), which does not cross from a shadow descendant to its
host. A wait scoped to an open-shadow host can report settled while meaningful mutations inside that
host's observed shadow tree continue.

19. A failed XHR send blocks the page forever ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
At PR head, XHR.prototype.send wraps origSend.apply in try/catch (quiescence.ts lines 1993-2006). On
a synchronous throw it calls remove(ledgerId) and rethrows, so the xhr entry no longer blocks
quiescence. This matches the suggested fix exactly.
Description
XHR.prototype.send adds a ledger entry and registers its only cleanup listener for loadend
before calling origSend, without removing the entry if that call throws synchronously. Calling
send before open or calling it twice can throw before a request starts, so loadend never fires
and the XHR entry continues to block quiescence, causing subsequent quiet waits to time out.

20. Parameter named settle_ms is actually seconds 🐞 Bug ⚙ Maintainability
Description
wait_for_dom_settled(settle_ms=0.1) is documented as seconds and multiplied by 1000 before
reaching awaitDomSettled, while the name says milliseconds. A caller passing settle_ms=150 (the
README's JS example uses settleMs: 150) asks for 150 seconds of quiet, which exceeds the timeout
and always returns settled=False.
Code

py/selenium/webdriver/remote/webdriver.py[R647-648]

+        settle_ms: float = 0.1,
+        require_pending_quiet: bool = True,
Evidence
The docstring says 'Seconds of quiet' and the call converts with int(settle_ms * 1000). The README
tells JS users settleMs: 150.

py/selenium/webdriver/remote/webdriver.py[643-703]
javascript/atoms/README.npm.md[83-85]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`settle_ms` is interpreted as seconds.

## Fix Focus Areas
- py/selenium/webdriver/remote/webdriver.py[643-703]

## Recommended Fix
Rename the parameter to `settle` (seconds, matching `timeout`), or keep `settle_ms`, default it to 100 and pass it through without multiplying.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


21. Typing waits accept non-text controls ✓ Resolved

Resolving commit: 8f6a061

Resolution reason
isEditable() now returns false for INPUT elements whose type is not in TEXTUAL_INPUT_TYPES (text,
search, tel, url, email, password, number), so checkbox and submit inputs are no longer reported
editable. Textarea and contenteditable handling are retained.
Description
isEditable() treats every enabled, non-read-only input as editable without considering its type. A
checkbox or submit input can consequently satisfy wait_until_actionable(..., interaction="type")
or "clear" even though it cannot accept that text-editing interaction.

22. Some stylesheets never block quiet waits ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
The current code tracks rel mutations on LINK elements (attr === 'rel' && tag === 'LINK'), so a
link changed to rel="stylesheet" starts a resource entry via trackResource/resourcePending's
stylesheet case, which is the requested remediation.
Description
scanRecordsForResources() ignores changes to a link's rel attribute even though stylesheet
tracking requires rel="stylesheet". When an already-inserted link with href is changed to a
stylesheet in a later task, its resulting load has no resource entry.

23. Concurrent waits can time out early 🐞 Bug ☼ Reliability
Description
wait_for_dom_settled() and wait_until_actionable() each temporarily change the session-wide
script timeout and restore a previously read value when their own call finishes. If two waits
overlap, one can restore a shorter timeout while the other async script is still running, causing
that script to fail before its requested wait duration.
Code

py/selenium/webdriver/remote/webdriver.py[R704-706]

+        finally:
+            if previous_script_timeout is not None:
+                self.timeouts.script = previous_script_timeout
Evidence
Both methods independently read, modify, and restore the same remote session timeout around an async
command.

py/selenium/webdriver/remote/webdriver.py[680-706]
py/selenium/webdriver/remote/webdriver.py[744-767]
py/selenium/webdriver/remote/webdriver.py[1096-1117]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Overlapping waits can restore a shared script timeout prematurely.
## Fix Focus Areas
- py/selenium/webdriver/remote/webdriver.py[680-706]
- py/selenium/webdriver/remote/webdriver.py[744-767]
## Recommended Fix
Coordinate timeout adjustment and restoration across both wait methods so one active wait cannot shorten another's timeout.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


24. Inert hosts still block settled waits ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
At PR head, nodeInert() (line 676-683 of current file) walks composedParent(n) instead of
parentNode, and composedParent (line 921-927) returns the shadow host when a node is a shadow root
or its parent is a shadow root. An inert host therefore covers its shadow tree, matching the
suggested fix. The code comment reads "Composed ancestry, so an inert shadow host covers its shadow
tree."
Description
nodeInert() follows parentNode without crossing a ShadowRoot to its host. Marking a host inert
therefore does not discount mutations in its open shadow subtree, so those mutations continue
resetting an unscoped DOM-settled wait.

25. Template script tags keep pages busy forever ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
At PR head, resourcePending's 'script' case (quiescence.ts lines 1084-1089 in the head file, under
the case 'script' block) now calls scriptWillFetch(el) before startedScripts.add(el), returning
false when el.noModule is set or when the trimmed, lowercased type attribute is not empty, 'module',
or in JS_MIME_TYPES. scriptWillFetch and JS_MIME_TYPES are defined at lines 497-508 of the head
file. Non-JavaScript data blocks and nomodule scripts are therefore never tracked, which is the fix
the finding asks for. The approach is a helper function rather than inline checks, which is a valid
different implementation.
Description
resourcePending tracks any connected <script src> without checking whether the browser will
fetch it. Scripts with a non-JavaScript type (text/template, text/x-handlebars, etc.) or
nomodule in modern browsers are never fetched and fire no load/error, so their resource entry
never settles and the ledger holds until timeout.

26. Action waits can outlive their timeout 🐞 Bug ☼ Reliability
Description
isStable() resolves only after its requested animation-frame callbacks and has no deadline. If
frames stop firing in a throttled document, waitForInteractionReady() never reaches its timeout
check; if they fire late, it can return ready after the requested timeout.
Code

javascript/atoms/typescript/quiescence.ts[R1180-1185]

+          isStable(el, { epsilonPx: o.stableEpsilonPx }).then((stable) => {
+            if (stable) { done(true, hit.point, null); return; }
+            const perpetual = perpetualMotionSource(el);
+            if (perpetual) { done(true, hit.point, null, perpetual); return; }
+            armNext(state, hit);
+          });
Evidence
The stability promise depends entirely on animation-frame callbacks, whereas the timeout check runs
only through armNext, not while sampling or on its successful completion.

javascript/atoms/typescript/quiescence.ts[1018-1039]
javascript/atoms/typescript/quiescence.ts[1178-1197]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Waiting for animation frames can bypass the action timeout.
## Fix Focus Areas
- javascript/atoms/typescript/quiescence.ts[1018-1039]
- javascript/atoms/typescript/quiescence.ts[1178-1197]
## Recommended Fix
Apply the action deadline while sampling stability, and check it again before resolving an action as ready.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


27. Mixed timer clearing leaves a stuck blocker ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
At PR head, the clear wrappers route through a shared untrackTimer(handle) helper (quiescence.ts
lines 282-287 and 288-291) that iterates over both timeoutLedgerByHandle and intervalLedgerByHandle,
removes any matching ledger entry, and deletes the mapping before delegating to native.clearTimeout.
global.clearInterval (lines 329-332) does the same. Cross-kind clearing therefore removes the ledger
entry, which is the fix the finding asks for, implemented as a single shared helper rather than the
two inline checks suggested.
Description
The clearTimeout wrapper checks only timeoutLedgerByHandle, and clearInterval checks only
intervalLedgerByHandle, even though either browser API can cancel either kind of timer. When a
caller clears an interval with clearTimeout or a timeout with clearInterval, the native timer
stops but its blocking ledger entry remains, causing awaitQuiet and awaitDomSettled calls to
time out.

28. Disabled pointer targets appear clickable 🐞 Bug ≡ Correctness
Description
obstructionAt() treats a top hit-test element that contains the target as unobstructed without
checking whether the target itself receives pointer events. With pointer-events: none on a button,
hit testing selects its ancestor instead, yet the readiness check can return true although a click
targets that ancestor.
Code

javascript/atoms/typescript/quiescence.ts[R1112-1115]

+    if (!doc.elementsFromPoint) return null;
+    const top = doc.elementsFromPoint(x, y)[0];
+    if (!top || top === target || composedContains(top, target) || composedContains(target, top)) return null;
+    if (doc.defaultView.getComputedStyle(top).pointerEvents === 'none') return null;
Evidence
The containment shortcut accepts an ancestor returned by hit testing, and waitForInteractionReady
treats a null obstruction as a passing check.

javascript/atoms/typescript/quiescence.ts[1111-1117]
javascript/atoms/typescript/quiescence.ts[1160-1180]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A pointer-disabled target is treated as hittable when its ancestor is hit instead.
## Fix Focus Areas
- javascript/atoms/typescript/quiescence.ts[1111-1117]
## Recommended Fix
Distinguish a hit on a descendant of the target from a hit on an ancestor when the target cannot receive pointer events; report the latter as non-actionable.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


29. An element can change after its checks ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
At PR head, the isStable callback in waitForInteractionReady (quiescence.ts lines 1901-1912 of the
PR diff view, i.e. the isStable(el, ...).then block) re-runs evaluate() after the stability
sampling. If the re-evaluated state is still ready, it resolves with the fresh now.hit.point;
otherwise it re-arms via armNext(now.state, now.hit). The if (!stable && !perpetual) path also
re-arms rather than resolving. This is a different implementation from the suggested fix only in
that it reuses the existing evaluate() helper, but it addresses the same stale-state issue: the
checks are repeated after the frames and the returned point comes from the fresh hit test.
Description
waitForInteractionReady() captures visibility, enabled state, viewport, obstruction, and
interaction point before awaiting isStable(), then returns the captured result if only the
rectangle remained stable. An overlay appearing or a control becoming disabled during those
animation frames can therefore produce ready: true with a stale interaction point or state.


Informational

30. Test server writes a stray 500 after a mid-body disconnect ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
The bodyMs branch's post-header writes (the b'{"slept": ' prefix write, flush, sleep, and the
closing body write) are wrapped in try/except (BrokenPipeError, ConnectionResetError) with pass, so
a client disconnect ends the handler quietly instead of reaching the generic except Exception that
would call send_error(500). This matches the suggested fix's recommended approach, with the header
writes left unchanged.
Description
In the bodyMs branch of do_GET, _send_response has already sent a 200 status and headers
before wfile.write at line 144 runs, so any exception there is caught by the generic `except
Exception at line 238, which calls send_error(500, ...)`. That second call emits a new status line
into the body stream, and if the browser has already closed the socket, the send_error write fails
again and the exception escapes the handler to socketserver's handle_error, which prints a
traceback to stderr.

31. One failed preload registration disables it for the session ✓ Resolved

Resolving commit: 4d12d81

Resolution reason
The attempted flag is now set only after _add_preload_script succeeds; on failure it stays unset so
later navigations retry registration, and the warning is logged only once.
Description
_ensure_quiescence_preload sets _quiescence_preload_attempted = True before the webSocketUrl
check and before _add_preload_script. A transient failure (for example, the BiDi socket not ready
yet) is logged once and never retried, so window.__quiescence is missing from every later BiDi
navigation in that session.

32. Animation loops are miscounted when other code requests frames ✓ Resolved

Resolving commit: 90ec1cc

Resolution reason
The PR head no longer uses a global rafChain. Each rAF call uses `const chain = currentChain || {
depth: 0, quietStreak: 0 }`, so a request made outside a frame callback creates its own chain object
captured by its closure (lines 1895-1900 of the PR head file). A module-level currentChain is set
only while a tracked callback runs (lines 1904-1906, restored in finally). This is the same design
the suggested fix describes, so unrelated requesters no longer reset an ongoing loop's depth. A
later test (test_raf_loop_becomes_inert_while_other_code_requests_frames) also covers this scenario.
Description
The animation-frame wrapper keeps one global rafChain and replaces it with a fresh {depth: 1}
whenever requestAnimationFrame is called outside a frame callback. Any unrelated caller
(scroll/resize handlers, framework schedulers) keeps resetting an ongoing loop's depth below
rafLoopChainThreshold, so effect-free loops are never classified inert and keep the page
not-quiet.

Grey Divider

Context sources
✅ Linked PRs:
  🌐 PR #17886
Review mode: Auto: ⚖️ Balanced: Runtime driver timeout handling carries meaningful session-wide behavioral risk.
✅ Fix-loop round: fix loop

Grey Divider

⚠️ Warning | Comment size exceeded, non finding content trimmed Learn more

Grey Divider

Qodo Logo

Adds javascript/atoms/quiescence.js, a prototype "quiescence oracle"
preload script that installs window.__quiescence to track a document's
pending work (timers, fetch/XHR, WebSocket, requestAnimationFrame) and
expose isQuiet()/getBlockers()/awaitQuiet()/setPolicy()/markInert().

The Python binding copies the atom into the package and registers it via
script.addPreloadScript on the first driver.get() when the session
negotiated a BiDi WebSocket, so the API is available on every navigation.
Injection is best-effort and guarded so non-BiDi sessions are unaffected.

Also adds a served test harness (common/src/web/quiescence.html), a /slow
endpoint in the test web server, and BiDi integration tests covering
network/timer/interval/rAF blockers, observed inertness, chained work,
policy boundaries, and durable cooperative markInert() annotations.
driver.get() already blocks until the page load event, so the quiescence
oracle adds little there. browsing_context.navigate() does not wait for
the page to settle, which is where window.__quiescence is useful, so the
preload is now registered from navigate().

The BiDi browsingContext module is code-generated: give it a driver
reference (like the script module already has) and override navigate() in
the enhancement manifest to register the preload before executing the
command. Tests navigate via browsing_context.navigate() accordingly.
Adds integration tests for window.__quiescence.awaitDomSettled(): idle
settle, structural burst debounce, bookkeeping-attribute filtering,
periodic-text noise classification, structural re-promotion of a noise
region, and active-region diagnostics on timeout. Fails until the atom
implements awaitDomSettled/getActiveRegions.
Adds a backward-looking DOM activity tracker to the quiescence atom: a
dedicated MutationObserver feeds a fingerprinted ledger, classifying
structural vs bookkeeping-attribute vs value-only periodic churn. Value-
only mutations on a regular cadence are reclassified as noise (observed
inertness for the DOM), and any net node change re-promotes them.

window.__quiescence.awaitDomSettled({settleMs,timeoutMs,requirePendingQuiet})
resolves once meaningful mutations stop for the settle window; on timeout
it reports the still-active regions. getActiveRegions() exposes the live
churn. Uses a second observer so runTracked's synchronous takeRecords()
does not steal activity records.
MutationObserver is blind to CSS animations/transitions. Adds tests that a
finite running animation blocks settle until it finishes, while an
infinite-iteration spinner is treated as noise. The finite case fails
until awaitDomSettled consults document.getAnimations().
awaitDomSettled now treats a running CSS animation/transition as activity
via document.getAnimations({subtree:true}), covering the MutationObserver
blind spot. Infinite-iteration animations (spinners) are excluded as
periodic noise so they do not block quiescence forever.
…(RED)

Adds tests for root-scoped settle (footer churn ignored for #main), a
durable cooperative markDomInert() annotation, setDomPolicy() disabling
CSS-animation activity, and awaitQuiet({dom:true}) composing pending-work
quiescence with DOM settle. Fails until the atom implements root filtering
and these APIs.
…(GREEN)

awaitDomSettled now accepts a root (element or CSS selector) and scopes the
settle window to that subtree, so unrelated churn elsewhere is ignored.
Replaces the event-driven re-arm with a fixed-cadence poll so a mutation
outside the scoped root cannot reset that root's window, and requires one
full settle window of observation before settling.

markDomInert(node|selector) is a sticky cooperative annotation (durable
across ticks); setDomPolicy(partial) tunes DOM thresholds; awaitQuiet({dom,
root}) composes pending-work quiescence with DOM settle.
Adds tests that mutation inside an open shadow root counts as activity,
that a closed shadow root is reported as unobservable, and that child-frame
churn does not block the parent context. The two shadow tests fail until
the atom hooks attachShadow.
Patches Element.prototype.attachShadow so open shadow roots are attached to
the DOM activity observer (MutationObserver does not cross shadow
boundaries), letting mutations inside them count toward quiescence. Closed
roots are opaque and recorded in the unobservable list surfaced by
awaitDomSettled, rather than being silently treated as settled.
Adds tests for a WebDriver.wait_for_dom_settled() wrapper: whole-document
settle, CSS-selector root, WebElement root, and active-region reporting on
timeout. Fails until the method is implemented.
Adds WebDriver.wait_for_dom_settled(root, timeout, settle_ms,
require_pending_quiet), a thin wrapper over the polyfill's awaitDomSettled.
root accepts a WebElement or a CSS selector. Installs the polyfill on the
current document if the preload never ran (classic get() path) and widens
the async-script timeout when needed so the browser does not abort the wait
before our own deadline. Refactors the loader to expose the raw IIFE source
for that one-shot install.
Viewport clipping and the obstruction hit test now run in every readable
ancestor document, translating through each frame's border and padding,
so a parent overlay or a frame scrolled out of the parent's view is no
longer reported ready. The walk stops at the first cross-origin ancestor
and the result lists cross-origin-ancestor in unobservable, so callers can
tell an unchecked boundary from a clear one.

Test file changes are formatter and docstring (D205) fixes only.
…bled

Trunk narrowed the BiDi test glob to test/selenium/webdriver/common/bidi/.
Left at common/bidi_*_tests.py, these suites were collected as classic
tests and every session started without webSocketUrl.
…um/atoms

A 1:1 port: the body is unchanged apart from the wrapper and the
annotations TypeScript needs (optional parameters, a typed listener set,
Promise<any> where it inferred unknown). The four Python BiDi suites pass
unchanged against the bundled artifact.

The atom now default-exports installQuiescence(global = globalThis) and
builds through the same registry as the other TypeScript atoms, so
@selenium/atoms gains a ./quiescence subpath and an installQuiescence
barrel export. Like every TypeScript atom, the injectable form evaluates
to the function rather than running itself, so the Python binding now
calls it with the page's window.

'use strict' is gone: it is a SyntaxError in a function with a default
parameter, and ES modules are strict already.
npm consumers install quiescence by sending installQuiescence.toString()
to the browser as a BiDi preload, a CDP new-document script or a
Playwright init script. That breaks silently the moment the function
references anything at module scope, so quiescence-portable evaluates
the source in a bare vm context and checks the ledger it installs.
Confirmed it fails with a ReferenceError when a constant is hoisted out.

README.npm.md documents the preload install and the query API, and that
the API is a prototype tracked by ADR 17886.
@AutomatedTester
AutomatedTester force-pushed the py-quiescence-bidi-preload branch from a5881a2 to 228e5f0 Compare November 3, 2026 10:23
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 228e5f0

AutomatedTester and others added 2 commits November 22, 2026 20:08
fetch() settles when headers arrive, so the ledger cleared before the
page had read and rendered the response; only the settle window stood
between "quiet" and unrendered data, and a slow body outlasts it.

Each started body read (json/text/arrayBuffer/blob/bytes/formData, on
the response or a clone) now holds a 'fetch-body' entry until it
finishes. Bodies nobody reads are not tracked, so they cannot block
forever. Streamed bodies (res.body.getReader()) remain untracked and
are listed under known limitations.

The test server's /slow endpoint gains ?bodyMs= to send headers first
and the body later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LA4X4vm8dWmqrXdvW2dvZR
native.now looked up Date on every call, unlike the timer functions
captured beside it. A page or fake-timer library that freezes
window.Date stopped every settle window from elapsing: awaitDomSettled
and awaitQuiet({dom: true}) only ever returned at their deadline, and
the actionability wait, whose timeout is a clock comparison, could poll
indefinitely.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LA4X4vm8dWmqrXdvW2dvZR
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 7c2296e

The test left a request thread sleeping out a 30 s body, and
server_close() joins request threads, so a focused run waited for it.
A 3 s body with a 2 s quiet timeout still fails if an unread body were
tracked, and frees the thread promptly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LA4X4vm8dWmqrXdvW2dvZR
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 48efb0f

Trunk added the accessibility-snapshot atoms in the same registry spots
as quiescence (BUILD.bazel tests, defs.bzl ATOMS, index.ts exports); kept
both, trunk's entries first. package.json was regenerated from the
merged registry with generate-exports.cjs, and its --check passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LA4X4vm8dWmqrXdvW2dvZR
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit ab83d67

Firefox holds fetch() until some of the body has arrived, so a response
of bare headers kept the request's plain 'fetch' blocker open in
Firefox: test_unread_fetch_body_does_not_block timed out there with
blocker type 'fetch', and the body-read test passed without ever
reaching the 'fetch-body' path. Sending the opening of the JSON with
the headers delivers the response in every engine while json()/text()
still wait for the rest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LA4X4vm8dWmqrXdvW2dvZR
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit a932dfb

…pers

Atom (each reproduced in Chromium first, then covered by a browser test):
- interval/rAF tracking no longer swallows page exceptions (return in
  finally); errors reach window.onerror again
- clearTimeout/clearInterval cancel either timer kind in the ledger too
- an XHR send() that throws no longer leaves a stuck entry
- data-block and nomodule scripts are not tracked (they never load)
- a link becoming rel=stylesheet, an img switching lazy -> eager, and the
  first src on an unstarted script are now tracked
- observers attach to the document node, so a preload that runs before
  documentElement exists misses nothing
- shadow-aware scoping and inertness: a root or inert host covers its
  open shadow tree
- noise is reclassified when its cadence breaks; swapping elements on a
  cadence is structural, not noise
- a root selector that matches nothing waits for the root and reports
  root-not-found instead of widening to the whole document
- setPolicy re-evaluates ignore patterns for requests already in flight
- console.debug transitions are opt-in (policy.debugLog)
- each rAF chain keeps its own state, so unrelated frame requests no
  longer reset a running loop
- type/clear readiness requires a textual input (bot.dom's list)
- the hit test descends open shadow roots and treats an ancestor hit as
  an obstruction (pointer-events: none targets)
- overflow: clip clips; stability waits honour the timeout and state is
  re-checked after the stability frames

Python:
- the script timeout is actually widened (and restored) around the waits;
  assigning to driver.timeouts.script changed a throwaway copy
- preload registration retries after a failure, warning once, and calls
  the BiDi module directly instead of the deprecated driver.script proxy
- /slow?bodyMs= ends quietly when the client disconnects mid-body

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LA4X4vm8dWmqrXdvW2dvZR
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 90ec1cc

AutomatedTester and others added 3 commits November 22, 2026 22:21
It took seconds, like every other timeout in the binding, but the _ms
suffix invited milliseconds: settle_ms=150 asked for 150 s of quiet and
always timed out. Unreleased, so renamed outright.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LA4X4vm8dWmqrXdvW2dvZR
The quiescence preload was registered by replacing the generated
navigate with a hand-written one (untyped parameters, raw command),
because the generator drops any command an extra method shadows. A new
before_execute enhancement inserts statements into the generated method
instead, so navigate keeps its generated signature and contract and
only gains the preload call. Regenerating from the pinned CDDL changes
nothing else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LA4X4vm8dWmqrXdvW2dvZR
…t can't be raised

Composed containment steps from a shadow root's children straight to its
host, so a wait scoped to the ShadowRoot itself stopped seeing changes
below its children (a regression from the shadow-host fix). Plain
containment covers that scope again, composed containment the host.

A failure to raise the script timeout is now a warning: the wait can
then be aborted by the browser instead of returning its diagnosis.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LA4X4vm8dWmqrXdvW2dvZR
Comment on lines +224 to +233
"navigate": {
"before_execute": [
"# Register the quiescence preload (once) so window.__quiescence is",
"# installed on the document this navigation creates. Unlike the classic",
"# GET command, browsingContext.navigate does not wait for the page to",
"# load, so the quiescence oracle is registered here rather than in get().",
"if self._driver is not None:",
" self._driver._ensure_quiescence_preload()",
],
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

5. Navigate silently patches every page 📘 Rule violation ⚙ Maintainability

The before_execute hook on the generated browsingContext.navigate calls
_ensure_quiescence_preload() on every navigation, and the first call registers a BiDi preload that
wraps setTimeout, setInterval, requestAnimationFrame, fetch, XHR and WebSocket and adds
window.__quiescence to every later page in the session. Existing users of the stable public
navigate method get this global side effect without opting in, and neither its signature nor its
docstring discloses it.
Agent Prompt
## Issue description
The generated `browsingContext.navigate` now registers the quiescence preload on every call, which injects global wrappers into every page the session loads. Callers who only want navigation get this side effect silently.

## Fix Focus Areas
- py/private/bidi_enhancements_manifest.py[224-233]
- py/selenium/webdriver/remote/webdriver.py[621-653]

## Recommended Fix
Remove the `before_execute` hook from the `navigate` enhancement. Register the preload only from `wait_for_dom_settled()` and `wait_until_actionable()`, which already call `_ensure_quiescence_preload()`. If navigation-time installation is required, make it opt-in through a documented session or capability flag, and state the behaviour change in the docstring.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 029b576

AutomatedTester and others added 2 commits November 22, 2026 22:43
timeouts.py is its own Bazel library that the BiDi test targets do not
depend on, so importing it made dom_quiescence_tests fail to collect on
every browser, and driver.timeouts (which imports it lazily) made the
script-timeout helper fall back to its warning branch there. The helper
and its test now use the Get/Set Timeouts commands directly, which
needs nothing beyond the remote module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LA4X4vm8dWmqrXdvW2dvZR
driver.script.execute returns the deserialized return value, so the
probe's check for a RemoteValue dict ({'type': 'boolean', 'value': True})
never matched: the page reported the resource blocker on the first poll
and the wait still timed out. This is the long-standing
test_parser_created_slow_image_is_awaited failure on every browser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LA4X4vm8dWmqrXdvW2dvZR
@selenium-ci

Copy link
Copy Markdown
Member

/agentic_review

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 0809b26

This branch has not been deployed

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

Labels

B-atoms JavaScript chunks generated by Google closure B-build Includes scripting, bazel and CI integrations B-devtools Includes everything BiDi or Chrome DevTools related C-py Python Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants