mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
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.  Fixes: part of https://github.com/servo/servo/issues/36027 --------- Signed-off-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
parent
5159529888
commit
7a801f0ef5
8 changed files with 204 additions and 42 deletions
|
@ -9,7 +9,7 @@ use std::thread::{self, JoinHandle};
|
|||
use base::id::{BrowsingContextId, PipelineId, WebViewId};
|
||||
use constellation_traits::{WorkerGlobalScopeInit, WorkerScriptLoadOrigin};
|
||||
use crossbeam_channel::{Receiver, Sender, unbounded};
|
||||
use devtools_traits::DevtoolScriptControlMsg;
|
||||
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, SourceInfo};
|
||||
use dom_struct::dom_struct;
|
||||
use ipc_channel::ipc::IpcReceiver;
|
||||
use ipc_channel::router::ROUTER;
|
||||
|
@ -478,10 +478,24 @@ impl DedicatedWorkerGlobalScope {
|
|||
},
|
||||
Ok((metadata, bytes)) => (metadata, bytes),
|
||||
};
|
||||
scope.set_url(metadata.final_url);
|
||||
scope.set_url(metadata.final_url.clone());
|
||||
scope.set_csp_list(GlobalScope::parse_csp_list_from_metadata(&metadata.headers));
|
||||
global_scope.set_https_state(metadata.https_state);
|
||||
let source = String::from_utf8_lossy(&bytes);
|
||||
if let Some(chan) = global_scope.devtools_chan() {
|
||||
let pipeline_id = global_scope.pipeline_id();
|
||||
let source_info = SourceInfo {
|
||||
url: metadata.final_url,
|
||||
external: true, // Worker scripts are always external.
|
||||
worker_id: Some(global.upcast::<WorkerGlobalScope>().get_worker_id()),
|
||||
content: source.to_string(),
|
||||
content_type: metadata.content_type.map(|c_type| c_type.0.to_string()),
|
||||
};
|
||||
let _ = chan.send(ScriptToDevtoolsControlMsg::ScriptSourceLoaded(
|
||||
pipeline_id,
|
||||
source_info,
|
||||
));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
// Handle interrupt requests
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
|||
|
||||
use constellation_traits::{StructuredSerializedData, WorkerScriptLoadOrigin};
|
||||
use crossbeam_channel::{Sender, unbounded};
|
||||
use devtools_traits::{DevtoolsPageInfo, ScriptToDevtoolsControlMsg, SourceInfo, WorkerId};
|
||||
use devtools_traits::{DevtoolsPageInfo, ScriptToDevtoolsControlMsg, WorkerId};
|
||||
use dom_struct::dom_struct;
|
||||
use ipc_channel::ipc;
|
||||
use js::jsapi::{Heap, JSObject};
|
||||
|
@ -224,16 +224,6 @@ impl WorkerMethods<crate::DomTypeHolder> for Worker {
|
|||
devtools_sender.clone(),
|
||||
page_info,
|
||||
));
|
||||
|
||||
let source_info = SourceInfo {
|
||||
url: worker_url.clone(),
|
||||
external: true, // Worker scripts are always external.
|
||||
worker_id: Some(worker_id),
|
||||
};
|
||||
let _ = chan.send(ScriptToDevtoolsControlMsg::ScriptSourceLoaded(
|
||||
pipeline_id,
|
||||
source_info,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue