Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7254a2893c2e75d2afb35756dcad0d11721ce0ca
      
https://github.com/WebKit/WebKit/commit/7254a2893c2e75d2afb35756dcad0d11721ce0ca
  Author: Anthony Tarbinian <[email protected]>
  Date:   2026-05-19 (Tue, 19 May 2026)

  Changed paths:
    M LayoutTests/platform/ios-site-isolation/TestExpectations
    M LayoutTests/platform/mac-site-isolation/TestExpectations
    M Source/WebCore/loader/FrameLoader.cpp
    M Source/WebCore/page/RemoteFrameClient.h
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebPageProxy.messages.in
    M Source/WebKit/WebProcess/WebCoreSupport/WebRemoteFrameClient.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebRemoteFrameClient.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in

  Log Message:
  -----------
  [Site Isolation] Handle RemoteFrames when deciding to dispatch beforeUnload 
event
https://bugs.webkit.org/show_bug.cgi?id=312207
rdar://174697142

Reviewed by Brady Eidson.

When running 
http/tests/misc/iframe-beforeunload-dialog-not-matching-ancestor-securityorigin.html
with site isolation enabled, WebKit does not log the following message:

"Blocked attempt to show beforeunload confirmation dialog on behalf of a frame 
with different security origin."

For context, the beforeUnload event gets run before a frame is about to be 
unloaded.
The main use case for this event is to provide the user with a confirmation 
dialog to
avoid closing the page and losing unsaved work.

In FrameLoader::shouldClose, WebKit goes through all descendent LocalFrames of 
the navigating
frame and in FrameLoader::dispatchBeforeUnloadEvent it checks if those 
descendent frames
match the security origin of the ancestors until the navigating frame. If the 
security origin
of a descendent frame doesn't match, then it logs the error: "Blocked attempt 
to show beforeunload...".

Under site isolation, cross-origin RemoteFrames were silently skipped and the 
console
message was never emitted.

With this patch, we consider both Local and Remote Frames when collecting 
descendants
to consider dispatching beforeUnload to.

For RemoteFrames, when it comes time to dispatch the beforeUnload event, now 
FrameLoader::shouldClose
sends an async IPC message to the RemoteFrame that checks if the RemoteFrame 
has a beforeunload listener
registered. If not, the RemoteFrame itself logs the "Blocked attempt to 
show..." message.

This patch fixes 
http/tests/misc/iframe-beforeunload-dialog-not-matching-ancestor-securityorigin.html
with site isolation enabled.

* LayoutTests/platform/ios-site-isolation/TestExpectations:
* LayoutTests/platform/mac-site-isolation/TestExpectations:
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::shouldClose):
* Source/WebCore/page/RemoteFrameClient.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::dispatchCrossOriginBeforeUnloadCheckForFrame):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/WebProcess/WebCoreSupport/WebRemoteFrameClient.cpp:
(WebKit::WebRemoteFrameClient::dispatchCrossOriginBeforeUnloadCheck):
* Source/WebKit/WebProcess/WebCoreSupport/WebRemoteFrameClient.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::dispatchCrossOriginBeforeUnloadCheckForFrame):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

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



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

Reply via email to