DevTools: Implement support for showing source_content in Debugger > Source panel (#36774)

This patch adds support for showing source_content in `Debugger >
Source` panel. This works by handling the clients `source` messages in
the source actor. These source actors are already advertised as resource
via the watcher, populating the source list. We also update the
`sources` handler in thread actor for future work in thread debugging.

Note: while this PR also adds support for showing worker script
source_content, worker has been broken (See
https://github.com/servo/servo/issues/37012). I was able to confirm the
`content_type` and `source_content` for worker script in logs.


![image](https://github.com/user-attachments/assets/bd53ea29-003a-4b5e-a3e8-6e280afa4671)

Fixes: part of https://github.com/servo/servo/issues/36027

---------

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
atbrakhi 2025-06-13 11:31:33 +02:00 committed by GitHub
parent 5159529888
commit 7a801f0ef5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 204 additions and 42 deletions

View file

@ -1020,7 +1020,6 @@ impl HTMLScriptElement {
}
// TODO: Step 3. Unblock rendering on el.
let mut script = match result {
// Step 4. If el's result is null, then fire an event named error at el, and return.
Err(e) => {
@ -1034,10 +1033,22 @@ impl HTMLScriptElement {
if let Some(chan) = self.global().devtools_chan() {
let pipeline_id = self.global().pipeline_id();
// TODO: https://github.com/servo/servo/issues/36874
let content = match &script.code {
SourceCode::Text(text) => text.to_string(),
SourceCode::Compiled(compiled) => compiled.original_text.to_string(),
};
// https://html.spec.whatwg.org/multipage/#scriptingLanguages
let content_type = Some("text/javascript".to_string());
let source_info = SourceInfo {
url: script.url.clone(),
external: script.external,
worker_id: None,
content,
content_type,
};
let _ = chan.send(ScriptToDevtoolsControlMsg::ScriptSourceLoaded(
pipeline_id,