script: Add new worker globals as debuggees (#38551)

to debug workers in a page with the [SpiderMonkey Debugger
API](https://firefox-source-docs.mozilla.org/js/Debugger/), we need to
pass the worker’s global object to
[Debugger.prototype.**addDebuggee()**](https://firefox-source-docs.mozilla.org/js/Debugger/Debugger.html#adddebuggee-global).
we could pick up the global via the [onNewGlobalObject()
hook](https://firefox-source-docs.mozilla.org/js/Debugger/Debugger.html#onnewglobalobject-global),
but if our script system passes the global to the debugger script
instead, we can later add details like the PipelineId that will help
servo identify debuggees that the API is notifying us about (#38334).

this patch creates a debugger global in worker threads, runs the
debugger script in those new globals, and plumbs new worker globals from
those threads into addDebuggee() via the debugger script. since worker
threads can’t generate PipelineId values, but they only ever run workers
on behalf of one pipeline, we use that pipeline’s PipelineId as the
PipelineId of the debugger global, rather than generating a unique
PipelineId like we do in script threads.

Testing: will undergo many automated tests in #38334
Fixes: part of #36027

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
shuppy 2025-08-09 19:28:06 +08:00 committed by GitHub
parent d50f02fa73
commit a3e0a34802
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 178 additions and 24 deletions

View file

@ -7,4 +7,12 @@
[Exposed=DebuggerGlobalScope]
interface DebuggerEvent : Event {
readonly attribute object global;
readonly attribute PipelineId pipelineId;
readonly attribute DOMString? workerId;
};
[Exposed=DebuggerGlobalScope]
interface PipelineId {
readonly attribute unsigned long namespaceId;
readonly attribute unsigned long index;
};