Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 42583e7e49eb6eefa2a0ead1255d01e793d0689f
      
https://github.com/WebKit/WebKit/commit/42583e7e49eb6eefa2a0ead1255d01e793d0689f
  Author: Qianlang Chen <[email protected]>
  Date:   2026-09-01 (Tue, 01 Sep 2026)

  Changed paths:
    A 
LayoutTests/http/tests/site-isolation/inspector/page/frame-navigated-single-report-same-origin-iframe-expected.txt
    A 
LayoutTests/http/tests/site-isolation/inspector/page/frame-navigated-single-report-same-origin-iframe.html
    A 
LayoutTests/http/tests/site-isolation/inspector/page/resources/frame-navigated-subframe-style.css
    A 
LayoutTests/http/tests/site-isolation/inspector/page/resources/same-origin-frame-with-grandchild.html
    M Source/WebCore/inspector/InspectorIdentifierRegistry.h
    M Source/WebCore/inspector/InspectorInstrumentation.cpp
    M Source/WebKit/WebProcess/Inspector/PageAgentProxy.cpp

  Log Message:
  -----------
  [Site Isolation] Web Inspector: Don't report duplicate Page.frameNavigated 
events per frame commit
rdar://184962162
https://bugs.webkit.org/show_bug.cgi?id=321822

Reviewed by BJ Burg.

didCommitLoadImpl notified both Page providers for the same commit: the
in-process InspectorPageAgent and the per-frame PageAgentProxy. The
frontend's PageObserver is target-agnostic, so both land in the same
frameDidNavigate, and the second report is destructive rather than
idempotent -- the frontend treats a same-loaderId/same-url repeat as
confirmation that nothing changed and re-initializes the frame, which
unconditionally clears its resources, child frames, execution contexts
and provisional load. Worst case is nested frames, where a parent's
duplicate arriving after its children attached detaches a live subtree.

So dispatch to the proxy or to the in-process agent, never both. Both
getters resolve from that one call site because didCommitLoad passes the
*frame's* InstrumentingAgents: ensurePageInstrumentationForFrame
registers the proxy there, InspectorPageAgent is registered on the
page's instance, and the getters fall back page-ward when the
frame-level slot is unset.

The if / else if mirrors how the Runtime domain already resolves the
same question for didClearWindowObjectInWorld: when the frame has a
FrameRuntimeAgent, it reports and the page-level agent is skipped.
Network solved it differently, by refusing to enable the in-process
agent at all, which Page cannot copy: InspectorPageAgent still serves
nearly every Page command, and domContentEventFired, loadEventFired,
loaderDetachedFromFrame, accessibilitySettingsDidChange and
defaultAppearanceDidChange have no proxy path. Only frameNavigated
moves.

Not emitting the page agent's event also drops a side effect:
buildObjectForFrame() called frameId(), which is the only place either
IdentifierRegistry populates its reverse map, so that call was what made
the frame resolvable by frameForId() / assertFrame() afterwards. The
proxy does not replace it -- it sends the raw FrameIdentifier and the
protocol string is computed in the UIProcess, so nothing in the
WebProcess would assign an id, and every page-target command taking a
frameId (Page.getResourceContent, Page.searchInResource, and the CSS and
DOM paths that use the registry directly) would start failing with
"Missing frame for given frameId". PageAgentProxy::frameNavigated
therefore registers the frame itself, which keeps the coupling in the
code that took over the reporting duty and does not depend on the Page
agent being enabled: the registry belongs to PageInspectorController,
and CSS and DOM need it whether or not the Page domain is in use.

Test: 
http/tests/site-isolation/inspector/page/frame-navigated-single-report-same-origin-iframe.html

The test counts raw Page.frameNavigated payloads at the observer,
because a duplicate leaves no trace in the frame model once
WI.Frame.initialize() has run, then checks that the frame tree, the
child frame's subresource, and page-target frameId resolution all
survive the commits.

* 
LayoutTests/http/tests/site-isolation/inspector/page/frame-navigated-single-report-same-origin-iframe-expected.txt:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/page/frame-navigated-single-report-same-origin-iframe.html:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/page/resources/frame-navigated-subframe-style.css:
 Added.
(p):
* 
LayoutTests/http/tests/site-isolation/inspector/page/resources/same-origin-frame-with-grandchild.html:
 Added.
* Source/WebCore/inspector/InspectorIdentifierRegistry.h:
(Inspector::IdentifierRegistry::registerFrame):
* Source/WebCore/inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didCommitLoadImpl):
* Source/WebKit/WebProcess/Inspector/PageAgentProxy.cpp:
(WebKit::PageAgentProxy::frameNavigated):

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



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

Reply via email to