Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b5e89ab438e8916077a57d5a085f9a8ed86a9c35
      
https://github.com/WebKit/WebKit/commit/b5e89ab438e8916077a57d5a085f9a8ed86a9c35
  Author: Alexey Proskuryakov <[email protected]>
  Date:   2026-09-03 (Thu, 03 Sep 2026)

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

  Log Message:
  -----------
  WebDriver doesn't have the correct URL in blank windows, causing assertion 
failure on some tests
https://bugs.webkit.org/show_bug.cgi?id=320504
rdar://183468933

Reviewed by BJ Burg.

WebDriver allows running commands in a browsing context that has not
done any loads yet, and WebAutomationSession::createBrowsingContext()
explicitly supports this. Such a context displays the initial empty
document, which FrameLoader::init() creates with an empty URL rather
than "about:blank". WebCore papers over this for script:
Document::urlForBindings() substitutes aboutBlankURL() when the
document URL is empty, which is why document.URL evaluates to
"about:blank" in a blank window.

PageLoadState::activeURL() has no such substitution, so the UI process
sees an empty (and therefore invalid) URL for the same state. Three
WebAutomationSession callers were not prepared for that.
deleteAllCookies() and addSingleCookie() both ASSERT(activeURL
.isValid()), which terminates the UI process in debug builds when a
cookie command is sent to a window that has never navigated.
buildBrowsingContextForPage() reports the empty URL string, so Get
Current URL answers "" instead of "about:blank" for a newly opened
window or tab.

Add a file-local activeOrInitialURL() helper that returns
aboutBlankURL() when PageLoadState::activeURL() is empty, and use it at
those three call sites. Checking for an empty URL rather than an
invalid one keeps the substitution limited to the initial empty
document: a URL that is non-empty but failed to parse is still reported
to the client verbatim.

WebDriver surfaces URLs from other sources too - WebFrameProxy::url(),
FrameInfoData::request, and WebPageProxy::currentURL() - and those have
the same empty-URL problem for the initial empty document. All of them
are on WebDriver BiDi code paths (browsingContext.getTree, the
browsingContext.context{Created,Destroyed} and navigation events)
whose tests are currently skipped or timing out for unrelated reasons,
so fixing them is left for a follow-up.

Covered by existing WPT tests, which now pass:
classic/delete_all_cookies/delete.py::test_null_response_value (was
crashing the UI process), classic/new_window/new_window.py::
test_opens_about_blank_in_new_window, and classic/new_window/new_tab.py::
test_opens_about_blank_in_new_tab.

* Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::activeOrInitialURL): Added. Substitutes about:blank for an
empty PageLoadState::activeURL(), matching Document::urlForBindings().
(WebKit::WebAutomationSession::buildBrowsingContextForPage): Report
about:blank instead of the empty string for a context that has not
navigated.
(WebKit::WebAutomationSession::addSingleCookie): Use the helper instead
of asserting the active URL is valid.
(WebKit::WebAutomationSession::deleteAllCookies): Ditto.

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



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

Reply via email to