mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Devtools: initial Debugger > Sources panel (#36164)
This patch adds support for listing scripts in the Sources panel. Classic scripts, both external and inline, are implemented, but worker scripts and imported module scripts are not yet implemented. For example: ```html <!-- sources.html --> <!doctype html><meta charset=utf-8> <script src="classic.js"></script> <script> console.log("inline classic"); new Worker("worker.js"); </script> <script type="module"> import module from "./module.js"; console.log("inline module"); </script> <script src="https://servo.org/js/load-table.js"></script> ``` ```js // classic.js console.log("external classic"); ``` ```js // worker.js console.log("external classic worker"); ``` ```js // module.js export default 1; console.log("external module"); ```  --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes partially implement #36027 <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes require tests, but they are blocked on #36325 Signed-off-by: Delan Azabani <dazabani@igalia.com> Co-authored-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
parent
40655cc06c
commit
95eedb997a
6 changed files with 143 additions and 7 deletions
|
@ -19,12 +19,13 @@ use std::net::{Shutdown, TcpListener, TcpStream};
|
|||
use std::sync::{Arc, Mutex};
|
||||
use std::thread;
|
||||
|
||||
use actors::thread::Source;
|
||||
use base::id::{BrowsingContextId, PipelineId, WebViewId};
|
||||
use crossbeam_channel::{Receiver, Sender, unbounded};
|
||||
use devtools_traits::{
|
||||
ChromeToDevtoolsControlMsg, ConsoleMessage, ConsoleMessageBuilder, DevtoolScriptControlMsg,
|
||||
DevtoolsControlMsg, DevtoolsPageInfo, LogLevel, NavigationState, NetworkEvent, PageError,
|
||||
ScriptToDevtoolsControlMsg, WorkerId,
|
||||
ScriptToDevtoolsControlMsg, SourceInfo, WorkerId,
|
||||
};
|
||||
use embedder_traits::{AllowOrDeny, EmbedderMsg, EmbedderProxy};
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
|
@ -247,6 +248,10 @@ impl DevtoolsInstance {
|
|||
console_message,
|
||||
worker_id,
|
||||
)) => self.handle_console_message(pipeline_id, worker_id, console_message),
|
||||
DevtoolsControlMsg::FromScript(ScriptToDevtoolsControlMsg::ScriptSourceLoaded(
|
||||
pipeline_id,
|
||||
source_info,
|
||||
)) => self.handle_script_source_info(pipeline_id, source_info),
|
||||
DevtoolsControlMsg::FromScript(ScriptToDevtoolsControlMsg::ReportPageError(
|
||||
pipeline_id,
|
||||
page_error,
|
||||
|
@ -498,6 +503,38 @@ impl DevtoolsInstance {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_script_source_info(&mut self, pipeline_id: PipelineId, source_info: SourceInfo) {
|
||||
let mut actors = self.actors.lock().unwrap();
|
||||
|
||||
let browsing_context_id = match self.pipelines.get(&pipeline_id) {
|
||||
Some(id) => id,
|
||||
None => return,
|
||||
};
|
||||
|
||||
let actor_name = match self.browsing_contexts.get(browsing_context_id) {
|
||||
Some(name) => name,
|
||||
None => return,
|
||||
};
|
||||
|
||||
let thread_actor_name = actors
|
||||
.find::<BrowsingContextActor>(actor_name)
|
||||
.thread
|
||||
.clone();
|
||||
|
||||
let thread_actor = actors.find_mut::<ThreadActor>(&thread_actor_name);
|
||||
thread_actor.add_source(source_info.url.clone());
|
||||
|
||||
let source = Source {
|
||||
actor: thread_actor_name.clone(),
|
||||
url: source_info.url.to_string(),
|
||||
is_black_boxed: false,
|
||||
};
|
||||
|
||||
// Notify browsing context about the new source
|
||||
let browsing_context = actors.find::<BrowsingContextActor>(actor_name);
|
||||
browsing_context.resource_available(source, "source".into());
|
||||
}
|
||||
}
|
||||
|
||||
fn allow_devtools_client(stream: &mut TcpStream, embedder: &EmbedderProxy, token: &str) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue