Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5603a455d064fee666dd95ba8bddcb21d4908f0d
      
https://github.com/WebKit/WebKit/commit/5603a455d064fee666dd95ba8bddcb21d4908f0d
  Author: BJ Burg <[email protected]>
  Date:   2026-01-29 (Thu, 29 Jan 2026)

  Changed paths:
    M Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
    M Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp

  Log Message:
  -----------
  Web Automation: Automation.evaluateJavaScriptFunction should return 
WindowNotFound instead of FrameNotFound
https://bugs.webkit.org/show_bug.cgi?id=304525
<rdar://165709196>

Reviewed by Lily Spiniolas.

In the case where the current browsing context is a frame that has just been 
destroyed by user click,
and then a command tries to evaluate JavaScript on the current browsing 
context, there are multiple
places where the evaluation could fail due to the context being gone.

The newly-added `Automation.verifyBrowsingContext` command was added to solve 
this problem in the general case,
but there are still some unfixable race conditions where this can succeed but 
the following command can
fail. We return an incorrect error type in WebAutomationSessionProxy when the 
frame is detached, as well
in many other similar places.

Upon reviewing the spec, the only commands that use FrameNotFound are those 
that switch to a child frame
using a locator that needs to be resolved in WebProcess. For example, if the 
ordinal argument is invalid,
this should return FrameNotFound. All other cases, such as failing to get a 
WebFrame from a frameID or
a frame being detached from its page, should return WindowNotFound. I audited 
all commands for this issue.

This change progresses most test_no_browsing_context cases in WebDriver Classic 
wpt suite. These were temporarily
regressed by the Safari-side adoption of Automation.validateBrowsingContext in 
<rdar://161272452>.

* Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::resolveBrowsingContext):
(WebKit::WebAutomationSession::switchToBrowsingContext):
(WebKit::WebAutomationSession::waitForNavigationToComplete):
(WebKit::WebAutomationSession::evaluateJavaScriptFunction):
(WebKit::WebAutomationSession::resolveChildFrameHandle):
(WebKit::WebAutomationSession::resolveParentFrameHandle):
(WebKit::WebAutomationSession::computeElementLayout):
(WebKit::WebAutomationSession::getComputedRole):
(WebKit::WebAutomationSession::getComputedLabel):
(WebKit::WebAutomationSession::selectOptionElement):
(WebKit::WebAutomationSession::setFilesForInputFileUpload):
(WebKit::WebAutomationSession::setStorageAccessPermissionState):
(WebKit::WebAutomationSession::performInteractionSequence):
(WebKit::WebAutomationSession::cancelInteractionSequence):
(WebKit::WebAutomationSession::takeScreenshot):
* Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::WebAutomationSessionProxy::getAccessibilityObjectForNode):
(WebKit::WebAutomationSessionProxy::willDestroyGlobalObjectForFrame):
(WebKit::WebAutomationSessionProxy::resolveChildFrameWithOrdinal):
(WebKit::WebAutomationSessionProxy::resolveChildFrameWithNodeHandle):
(WebKit::WebAutomationSessionProxy::resolveChildFrameWithName):
(WebKit::WebAutomationSessionProxy::resolveParentFrame):
(WebKit::WebAutomationSessionProxy::focusFrame):
(WebKit::WebAutomationSessionProxy::computeElementLayout):
(WebKit::WebAutomationSessionProxy::selectOptionElement):
(WebKit::WebAutomationSessionProxy::setFilesForInputFileUpload):
(WebKit::WebAutomationSessionProxy::snapshotRectForScreenshot):
(WebKit::WebAutomationSessionProxy::getCookiesForFrame):
(WebKit::WebAutomationSessionProxy::deleteCookie):

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



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

Reply via email to