Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1b2344ce06b4afcee8298859e686a04aec7f2bcc
      
https://github.com/WebKit/WebKit/commit/1b2344ce06b4afcee8298859e686a04aec7f2bcc
  Author: Qianlang Chen <[email protected]>
  Date:   2026-10-06 (Tue, 06 Oct 2026)

  Changed paths:
    A 
LayoutTests/http/tests/site-isolation/inspector/debugger/stack-trace-page-target-expected.txt
    A 
LayoutTests/http/tests/site-isolation/inspector/debugger/stack-trace-page-target.html
    M 
LayoutTests/http/tests/site-isolation/inspector/network/cross-origin-iframe-network-initiator-expected.txt
    M 
LayoutTests/http/tests/site-isolation/inspector/network/cross-origin-iframe-network-initiator.html
    M Source/WebInspectorUI/UserInterface/Controllers/ConsoleManager.js
    M Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js
    M Source/WebInspectorUI/UserInterface/Controllers/TargetManager.js
    M Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js
    M Source/WebInspectorUI/UserInterface/Models/Animation.js
    M Source/WebInspectorUI/UserInterface/Models/CallFrame.js
    M Source/WebInspectorUI/UserInterface/Models/Canvas.js
    M Source/WebInspectorUI/UserInterface/Models/StackTrace.js
    M Source/WebInspectorUI/UserInterface/Protocol/Target.js

  Log Message:
  -----------
  [Site Isolation] Web Inspector: Stack traces lose source locations for 
scripts owned by another target
rdar://186582847
https://bugs.webkit.org/show_bug.cgi?id=323341

Reviewed by BJ Burg.

The frontend resolves a stack frame's script identifier against one
target. Under Site Isolation the page target owns no scripts:
PageDebugger doesn't attach to any frame, and each frame target's
FrameDebuggerAgent reports its own frame's scripts instead. So stack
traces that domains still deliver on the page target, such as
Animation and Timeline, name scripts the page target has never seen.

WI.CallFrame.fromPayload falls back to two URL-keyed lookups, so only
frames with no URL (eval, new Function, code run through
Runtime.evaluate, sourceURL-tagged code such as webpack's eval
devtool) lose their location and show as native code.

Add WI.DebuggerManager.prototype.scriptForStackTraceIdentifier, which
retries a missed page target lookup against the main frame target.
That is only correct for a stack trace that came over the page
target's own connection, which only reaches the main frame's process.
A Debugger.ScriptId is a JSC SourceID drawn from a per-process
counter, so an identifier from another process can name an unrelated
script in the main frame target, which is worse than resolving it to
nothing. Network initiator stack traces are such a case: under Site
Isolation the UI process forwards Network events from every process,
and NetworkManager resolves their initiators against the page target.
So the retry is opt-in through a new deliveredOnTarget option of
WI.StackTrace.fromPayload and WI.CallFrame.fromPayload. Animation,
Canvas, Console, and Timeline, which resolve stack traces against the
target that delivered them, opt in. Network does not.

The main frame target is the non-provisional WI.FrameTarget whose
execution context belongs to WI.networkManager.mainFrame, so no
protocol change is needed. The retry is a stopgap and goes away with
the page target (https://bugs.webkit.org/show_bug.cgi?id=325881).

It is a new method rather than a change to scriptForIdentifier, so
that it applies to stack traces only. Only the frame's source location
crosses targets; the target recorded on the WI.CallFrame is unchanged.

(Not addressed here: scripts of same-origin iframes, which share the
main frame's process but are owned by their own frame targets. They
still don't resolve from the page target. They also show up on other
frame targets' stack traces, because a JS stack walk crosses frame
boundaries while script ownership does not. Resolving them safely
needs script identifiers that are unique across processes, which is
tracked in https://bugs.webkit.org/show_bug.cgi?id=326433.)

As a drive-by, remove the FIXMEs for bugs 298909 and 298910, which
assumed that frame targets lack the Runtime and Debugger domains; the
current protocol gives frame targets both. Target.js still skips its
Runtime and Debugger asserts for frame targets from macOS and iOS 26.2
and 26.4 backends, which had frame targets but no domains for them.
Also fix WI.WorkerTarget construction in TargetManager._createTarget,
which passed five arguments to a six-parameter constructor, so the
name went in as the URL, the connection as the display name, and the
options as the connection. No backend creates a worker target through
Target.TargetInfo today, which is why this went unnoticed.

The new test checks that an Animation backtrace resolves a URL-less
script owned by the main frame target, that the retry needs
deliveredOnTarget, and that it consults no target other than the main
frame target. The cross-origin iframe Network initiator test now also
checks that initiator frames resolve to the iframe's own script rather
than to a main frame script with the same identifier.

Test: http/tests/site-isolation/inspector/target/target-process-id.html

* Source/WebInspectorUI/UserInterface/Controllers/ConsoleManager.js:
(WI.ConsoleManager.prototype.messageWasAdded):
* Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js:
(WI.DebuggerManager.prototype.scriptForIdentifierInSameProcess):
(WI.DebuggerManager.prototype.scriptForStackTraceIdentifier):
* Source/WebInspectorUI/UserInterface/Controllers/TargetManager.js:
(WI.TargetManager.prototype._createTarget):
* Source/WebInspectorUI/UserInterface/Models/CallFrame.js:
(WI.CallFrame.fromPayload):
(WI.CallFrame):
(WI.CallFrame.prototype.fromPayload):
* Source/WebInspectorUI/UserInterface/Protocol/Target.js:
(WI.Target.prototype.get processId):
* 
LayoutTests/http/tests/site-isolation/inspector/debugger/stack-trace-page-target-expected.txt:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/debugger/stack-trace-page-target.html:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/network/cross-origin-iframe-network-initiator-expected.txt:
* 
LayoutTests/http/tests/site-isolation/inspector/network/cross-origin-iframe-network-initiator.html:
* Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js:
(WI.TimelineManager.prototype._stackTraceFromPayload):
* Source/WebInspectorUI/UserInterface/Models/Animation.js:
(WI.Animation.fromPayload):
* Source/WebInspectorUI/UserInterface/Models/Canvas.js:
(WI.Canvas.fromPayload):
* Source/WebInspectorUI/UserInterface/Models/StackTrace.js:
(WI.StackTrace.prototype.fromPayload):
(WI.StackTrace.fromPayload): Deleted.

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



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

Reply via email to