Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f56eb24b31957067cad7f5fec90ee8f8f486f090
      
https://github.com/WebKit/WebKit/commit/f56eb24b31957067cad7f5fec90ee8f8f486f090
  Author: Brent Fulgham <[email protected]>
  Date:   2026-09-04 (Fri, 04 Sep 2026)

  Changed paths:
    M Source/WebDriver/CommandResult.cpp
    M Source/WebKit/UIProcess/Automation/Automation.json
    M Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp
    M Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.js

  Log Message:
  -----------
  WebDriver reports "stale element reference" for a node reference from a 
different browsing context
https://bugs.webkit.org/show_bug.cgi?id=323386
rdar://186615759

Reviewed by Tim Nguyen.

Each frame's injected WebAutomationSessionProxy.js keeps its own map of node 
handles.
_nodeForIdentifier() throws NodeNotFound whenever a handle is absent from that 
map, which
conflates two different situations:
(1) the node was in this frame and has since been detached (a stale handle)
(2) the node was never in this frame, because it belongs to a different frame 
or window

CommandResult.cpp maps NodeNotFound to StaleElementReference, so both report 
stale element
reference. Per the spec, the second case is no such element (or no such shadow 
root for a
shadow root reference).

_clearStaleNodes() already knows the difference: it evicts only those handles 
whose node
is no longer rooted in this document. Recording what it evicts lets 
_nodeForIdentifier()
throw a distinct StaleNode error for the detached case and keep NodeNotFound 
for the
foreign one.

Tests: webdriver/tests/classic/execute_script/arguments.py
       webdriver/tests/classic/execute_async_script/arguments.py

* Source/WebDriver/CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Source/WebKit/UIProcess/Automation/Automation.json:
* Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::evaluateJavaScriptCallback):
* Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.js:
(let.AutomationSessionProxy):
(let.AutomationSessionProxy.prototype._nodeForIdentifier):
(let.AutomationSessionProxy.prototype._clearStaleNodes):

Canonical link: https://commits.webkit.org/320518@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to