Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 270a9fa5f16205d2e841328a6664bede890aff79
      
https://github.com/WebKit/WebKit/commit/270a9fa5f16205d2e841328a6664bede890aff79
  Author: Anthony Tarbinian <[email protected]>
  Date:   2026-05-28 (Thu, 28 May 2026)

  Changed paths:
    M LayoutTests/http/tests/iframe-monitor/blob-resource.html
    M LayoutTests/http/tests/iframe-monitor/cached-resource.html
    M LayoutTests/http/tests/iframe-monitor/compressed-resource.html
    M LayoutTests/http/tests/iframe-monitor/dark-mode.html
    M LayoutTests/http/tests/iframe-monitor/data-url-resource.html
    M LayoutTests/http/tests/iframe-monitor/eligibility.html
    M LayoutTests/http/tests/iframe-monitor/iframe-unload.html
    M LayoutTests/http/tests/iframe-monitor/just-use-eligible-subresource.html
    M LayoutTests/http/tests/iframe-monitor/resources/monitor-setup.js
    M LayoutTests/http/tests/iframe-monitor/throttler.html
    M 
LayoutTests/http/tests/iframe-monitor/workers/service-worker-not-count-twice.html
    M LayoutTests/http/tests/iframe-monitor/workers/service-worker.html
    M LayoutTests/http/tests/iframe-monitor/workers/shared-worker.html
    M LayoutTests/platform/ios-site-isolation/TestExpectations
    M LayoutTests/platform/mac-site-isolation/TestExpectations
    M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
    M Source/WebCore/loader/LocalFrameLoaderClient.cpp
    M Source/WebCore/loader/LocalFrameLoaderClient.h
    M Source/WebCore/page/LocalFrame.cpp
    M Source/WebCore/page/LocalFrame.h
    M Source/WebCore/testing/Internals.cpp
    M Source/WebCore/testing/Internals.h
    M Source/WebCore/testing/Internals.idl
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebPageProxy.messages.in
    M Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.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] iframe monitor tests are failing
https://bugs.webkit.org/show_bug.cgi?id=315664
rdar://178052024

Reviewed by Sihui Liu.

The following tests are failing with site isolation:

http/tests/iframe-monitor/eligibility.html
http/tests/iframe-monitor/iframe-unload.html
http/tests/iframe-monitor/throttler.html
http/tests/iframe-monitor/workers/service-worker-not-count-twice.html
http/tests/iframe-monitor/workers/service-worker.html
http/tests/iframe-monitor/workers/shared-worker.html

These 6 tests in http/tests/iframe-monitor/ timed out under
--site-isolation. The tests use a WebKit feature
which enforces a resource usage threshold for iframes. When an
iframe goes over the resource usage threshold, the iframe is killed
by getting swapped out with a gray placeholder iframe that reads:
"this frame is hidden".

The first bug was that WebLocalFrameLoaderClient::didExceedNetworkUsageThreshold
assumes that the main frame is a local frame. This isn't true with
site isolation. It uses the local main frame to grab the URL of the
main frame and send it via the 
Messages::NetworkConnectionToWebProcess::ShouldOffloadIFrameForHost
IPC message.

With site isolation enabled, the main frame's document wasn't available
and didExceedNetworkUsageThreshold returned early, never sending the
NetworkConnectionToWebProcess::ShouldOffloadIFrameForHost IPC message.

To fix this bug, this patch replaces the main frame downcast to LocalFrame
(in WebLocalFrameLoaderClient::didExceedNetworkUsageThreshold) with
Page::mainFrameURL which avoids the early return.

The second bug was that LocalFrame::showResourceMonitoringError
tried to use ownerElement() to set the srcdoc of the iframe.
With site isolation enabled, the owner element was in a different process
and was nullptr.

To fix this bug, this patch sets the srcdoc with the help of
IPC from the child frame -> UIProcess -> parent frame:
1. The iframe starts by sending an IPC message to the UIProcess
    (Messages::WebPageProxy::ApplyResourceMonitorUnloadToFrameOwner)
2. Then, the UIProcess forwards 
Messages::WebPage::ApplyResourceMonitorUnloadToIFrameElement
    to the parent's WebProcess
3. The parent frame actually sets the srcdoc via a shared helper function
    LocalFrame::applyResourceMonitorErrorToIFrameElement

I considered avoiding needing the parent frame to set srcdoc
(and the addition of these IPC messages)
and instead considered having the iframe navigate itself to the
resource monitor error placeholder page. However, the tests rely on
reading the iframe's srcdoc attribute to determine if the resource
threshold was hit and the placeholder swap happened.

The third bug, involves settings on internals.* to not be propagated
to all processes which is problematic for site isolation.

To fix this bug, this patch changes the JS functions to enable this setting
to be options in WKTR headers.

Before:

internals.setResourceMonitorNetworkUsageThreshold(10 * 1024, 0.001);   // 
removed (replaced by header)
internals.shouldSkipResourceMonitorThrottling = false;                 // 
removed (was a no-op anyway)

After:

<!DOCTYPE html> <!-- webkit-test-runner [ IFrameResourceMonitoringEnabled=true 
IFrameResourceMonitorNetworkUsageThresholdForTesting=10240
IFrameResourceMonitorNetworkUsageThresholdRandomnessForTesting=0.001 ] -->

This patch fixes the following tests with --site-isolation:

http/tests/iframe-monitor/eligibility.html
http/tests/iframe-monitor/iframe-unload.html
http/tests/iframe-monitor/throttler.html
http/tests/iframe-monitor/workers/service-worker-not-count-twice.html
http/tests/iframe-monitor/workers/service-worker.html
http/tests/iframe-monitor/workers/shared-worker.html

* LayoutTests/http/tests/iframe-monitor/blob-resource.html:
* LayoutTests/http/tests/iframe-monitor/cached-resource.html:
* LayoutTests/http/tests/iframe-monitor/compressed-resource.html:
* LayoutTests/http/tests/iframe-monitor/dark-mode.html:
* LayoutTests/http/tests/iframe-monitor/data-url-resource.html:
* LayoutTests/http/tests/iframe-monitor/eligibility.html:
* LayoutTests/http/tests/iframe-monitor/iframe-unload.html:
* LayoutTests/http/tests/iframe-monitor/just-use-eligible-subresource.html:
* LayoutTests/http/tests/iframe-monitor/resources/monitor-setup.js:
(async setup):
        Remove JS calls to internals.* which gets
        replaced with the new WKTR headers.
* LayoutTests/http/tests/iframe-monitor/throttler.html:
* 
LayoutTests/http/tests/iframe-monitor/workers/service-worker-not-count-twice.html:
* LayoutTests/http/tests/iframe-monitor/workers/service-worker.html:
* LayoutTests/http/tests/iframe-monitor/workers/shared-worker.html:
* LayoutTests/platform/ios-site-isolation/TestExpectations:
* LayoutTests/platform/mac-site-isolation/TestExpectations:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/loader/LocalFrameLoaderClient.h:
* Source/WebCore/page/LocalFrame.cpp:
(WebCore::LocalFrame::applyResourceMonitorErrorToIFrameElement):
        Shared helper which performs the placeholder iframe
        swap and is used in both the local and remote case.
(WebCore::LocalFrame::showResourceMonitoringError):
* Source/WebCore/page/LocalFrame.h:
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::setResourceMonitorNetworkUsageThreshold): Deleted.
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::continueNavigationInNewProcess):
(WebKit::WebPageProxy::applyResourceMonitorUnloadToFrameOwner):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
(WebKit::WebLocalFrameLoaderClient::didExceedNetworkUsageThreshold):
(WebKit::WebLocalFrameLoaderClient::applyResourceMonitorUnloadToOwnerFrame):
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::applyResourceMonitorUnloadToIFrameElement):
(WebKit::WebPage::updatePreferences):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

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



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

Reply via email to