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

  Changed paths:
    M Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
    M Source/WebKit/UIProcess/Automation/WebAutomationSession.h
    M Source/WebKit/UIProcess/Automation/WebAutomationSession.messages.in
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp
    M Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h
    M Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.js
    M WebDriverTests/TestExpectations.json

  Log Message:
  -----------
  REGRESSION(320518@main): WebDriver returns "no such element" instead of 
"stale element reference" for a node reference from a previous document
https://bugs.webkit.org/show_bug.cgi?id=323692
rdar://187042183

Reviewed by BJ Burg.

The changes I made in 320518@main split "no such element" from "stale element 
reference",
but the stale reference map is wiped on page navigation/refresh because that 
information
is stored by the AutomationSessionProxy JS instance living on the page's global 
object.
My changed caused a set of back/forward tests to begin failing because the spec 
keys its
navigable "seen nodes" map to the navigable, which outlives the document.

This patch address this by building on the work started in Bug 230612, which 
started
recording the handles on the C++ WebAutomationSessionProxy instead. However, 
this proved
insufficient since a browsing-context-group swap replaces the web process, 
trigger a key
change.

We record the handles as they are created, and mirror those values in 
WebAutomationSession,
which belongs to the session rather than to any specific web process and 
therefore survives
during process swap. Now the Web Process consults its own map first and asks 
the UI process
only when that misses. When a process swap commits, WebPageProxy asks the 
session to move the
set from the outgoing main frame's identifier onto the committed one. This is 
done at commit
rather than when the provisional page is created, so that a provisional load 
which is
cancelled or fails leaves the previous main frame's references where they are.

The records are bounded. Each is insertion-ordered and capped per frame, and a 
frame's set
is dropped when the frame is destroyed, matching the weak map the spec 
describes. The UI
process copy is authoritative, so evicting from it can cause false negatives so 
we keep
its cap higher than the WebContent process.

This work builds on Lauro Moura's work in Bug 230612, so they should get credit 
for this
improvement, too!

The expectations for this bug are removed. 320729@main gardened the failures for
bug323692, bug323694 and bug323695 together and tagged each entry with its bug, 
so only the
24 entries tagged 323692 are removed here; the 20 belonging to the unlanded 
siblings stay,
as do those tagged 230612, which this may also clear but has not been measured 
against.
Three files had no other expectations and their entries are gone entirely.

Tests: imported/w3c/webdriver/tests/classic/back/back.py
       imported/w3c/webdriver/tests/classic/forward/forward.py
       imported/w3c/webdriver/tests/classic/navigate_to/navigate.py
       imported/w3c/webdriver/tests/classic/refresh/refresh.py
       imported/w3c/webdriver/tests/classic/refresh/user_prompts.py
       
imported/selenium/py/test/selenium/webdriver/common/stale_reference_tests.py

* Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::didDestroyFrame):
(WebKit::WebAutomationSession::transferKnownNodeReferences):
(WebKit::WebAutomationSession::addKnownNodeReference):
(WebKit::WebAutomationSession::isKnownNodeReference):
* Source/WebKit/UIProcess/Automation/WebAutomationSession.h:
* Source/WebKit/UIProcess/Automation/WebAutomationSession.messages.in:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::commitProvisionalPage):
* Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::frameAndNodeIdentifierArguments):
(WebKit::isKnownReferenceCallback):
(WebKit::addKnownReferenceCallback):
(WebKit::WebAutomationSessionProxy::isKnownReference):
(WebKit::WebAutomationSessionProxy::addKnownReference):
(WebKit::WebAutomationSessionProxy::errorTypeFromJavaScriptExceptionName):
(WebKit::WebAutomationSessionProxy::scriptObjectForFrame):
(WebKit::WebAutomationSessionProxy::elementForNodeHandle):
(WebKit::WebAutomationSessionProxy::getAccessibilityObjectForNode):
(WebKit::WebAutomationSessionProxy::resolveChildFrameWithNodeHandle):
(WebKit::WebAutomationSessionProxy::computeElementLayout):
(WebKit::WebAutomationSessionProxy::selectOptionElement):
(WebKit::WebAutomationSessionProxy::setFilesForInputFileUpload):
(WebKit::WebAutomationSessionProxy::snapshotRectForScreenshot):
* Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h:
* Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.js:
(let.AutomationSessionProxy.prototype.nodeForIdentifier):
(let.AutomationSessionProxy.prototype._nodeForIdentifier):
(let.AutomationSessionProxy.prototype._identifierForNode):
* WebDriverTests/TestExpectations.json:

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



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

Reply via email to