mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Auto merge of #25161 - paulrouget:cachedMsgs, r=jdm
devtools: save and send cached messages @jdm the only real difference between your original patch and this PR is the removal of the `GetCachedMessages` messages that are not necessary anymore now that we directly send the message to the devtools. --- <!-- 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 fix #13161 (GitHub issue number if applicable)
This commit is contained in:
commit
136366bf64
8 changed files with 137 additions and 107 deletions
|
@ -18,9 +18,7 @@ use crate::dom::globalscope::GlobalScope;
|
|||
use crate::dom::node::{window_from_node, Node, ShadowIncluding};
|
||||
use crate::dom::window::Window;
|
||||
use crate::script_thread::Documents;
|
||||
use devtools_traits::TimelineMarkerType;
|
||||
use devtools_traits::{AutoMargins, CachedConsoleMessage, CachedConsoleMessageTypes};
|
||||
use devtools_traits::{ComputedNodeLayout, ConsoleAPI, PageError};
|
||||
use devtools_traits::{AutoMargins, ComputedNodeLayout, TimelineMarkerType};
|
||||
use devtools_traits::{EvaluateJSReply, Modification, NodeInfo, TimelineMarker};
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use js::jsval::UndefinedValue;
|
||||
|
@ -182,50 +180,6 @@ fn determine_auto_margins(window: &Window, node: &Node) -> AutoMargins {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn handle_get_cached_messages(
|
||||
_pipeline_id: PipelineId,
|
||||
message_types: CachedConsoleMessageTypes,
|
||||
reply: IpcSender<Vec<CachedConsoleMessage>>,
|
||||
) {
|
||||
// TODO: check the messageTypes against a global Cache for console messages and page exceptions
|
||||
let mut messages = Vec::new();
|
||||
if message_types.contains(CachedConsoleMessageTypes::PAGE_ERROR) {
|
||||
// TODO: make script error reporter pass all reported errors
|
||||
// to devtools and cache them for returning here.
|
||||
let msg = PageError {
|
||||
type_: "PageError".to_owned(),
|
||||
errorMessage: "page error test".to_owned(),
|
||||
sourceName: String::new(),
|
||||
lineText: String::new(),
|
||||
lineNumber: 0,
|
||||
columnNumber: 0,
|
||||
category: String::new(),
|
||||
timeStamp: 0,
|
||||
error: false,
|
||||
warning: false,
|
||||
exception: false,
|
||||
strict: false,
|
||||
private: false,
|
||||
};
|
||||
messages.push(CachedConsoleMessage::PageError(msg));
|
||||
}
|
||||
if message_types.contains(CachedConsoleMessageTypes::CONSOLE_API) {
|
||||
// TODO: do for real
|
||||
let msg = ConsoleAPI {
|
||||
type_: "ConsoleAPI".to_owned(),
|
||||
level: "error".to_owned(),
|
||||
filename: "http://localhost/~mihai/mozilla/test.html".to_owned(),
|
||||
lineNumber: 0,
|
||||
functionName: String::new(),
|
||||
timeStamp: 0,
|
||||
private: false,
|
||||
arguments: vec!["console error test".to_owned()],
|
||||
};
|
||||
messages.push(CachedConsoleMessage::ConsoleAPI(msg));
|
||||
}
|
||||
reply.send(messages).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_modify_attribute(
|
||||
documents: &Documents,
|
||||
pipeline: PipelineId,
|
||||
|
|
|
@ -476,9 +476,6 @@ impl DedicatedWorkerGlobalScope {
|
|||
DevtoolScriptControlMsg::EvaluateJS(_pipe_id, string, sender) => {
|
||||
devtools::handle_evaluate_js(self.upcast(), string, sender)
|
||||
},
|
||||
DevtoolScriptControlMsg::GetCachedMessages(pipe_id, message_types, sender) => {
|
||||
devtools::handle_get_cached_messages(pipe_id, message_types, sender)
|
||||
},
|
||||
DevtoolScriptControlMsg::WantsLiveNotifications(_pipe_id, bool_val) => {
|
||||
devtools::handle_wants_live_notifications(self.upcast(), bool_val)
|
||||
},
|
||||
|
|
|
@ -46,7 +46,7 @@ use crate::task_source::TaskSourceName;
|
|||
use crate::timers::{IsInterval, OneshotTimerCallback, OneshotTimerHandle};
|
||||
use crate::timers::{OneshotTimers, TimerCallback};
|
||||
use content_security_policy::CspList;
|
||||
use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
|
||||
use devtools_traits::{PageError, ScriptToDevtoolsControlMsg, WorkerId};
|
||||
use dom_struct::dom_struct;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
|
@ -1085,6 +1085,27 @@ impl GlobalScope {
|
|||
// https://html.spec.whatwg.org/multipage/#runtime-script-errors-2
|
||||
if let Some(dedicated) = self.downcast::<DedicatedWorkerGlobalScope>() {
|
||||
dedicated.forward_error_to_worker_object(error_info);
|
||||
} else if self.is::<Window>() {
|
||||
if let Some(ref chan) = self.devtools_chan {
|
||||
let _ = chan.send(ScriptToDevtoolsControlMsg::ReportPageError(
|
||||
self.pipeline_id.clone(),
|
||||
PageError {
|
||||
type_: "PageError".to_string(),
|
||||
errorMessage: error_info.message.clone(),
|
||||
sourceName: error_info.filename.clone(),
|
||||
lineText: "".to_string(), //TODO
|
||||
lineNumber: error_info.lineno,
|
||||
columnNumber: error_info.column,
|
||||
category: "script".to_string(),
|
||||
timeStamp: 0, //TODO
|
||||
error: true,
|
||||
warning: false,
|
||||
exception: true,
|
||||
strict: false,
|
||||
private: false,
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -371,9 +371,6 @@ impl ServiceWorkerGlobalScope {
|
|||
DevtoolScriptControlMsg::EvaluateJS(_pipe_id, string, sender) => {
|
||||
devtools::handle_evaluate_js(self.upcast(), string, sender)
|
||||
},
|
||||
DevtoolScriptControlMsg::GetCachedMessages(pipe_id, message_types, sender) => {
|
||||
devtools::handle_get_cached_messages(pipe_id, message_types, sender)
|
||||
},
|
||||
DevtoolScriptControlMsg::WantsLiveNotifications(_pipe_id, bool_val) => {
|
||||
devtools::handle_wants_live_notifications(self.upcast(), bool_val)
|
||||
},
|
||||
|
|
|
@ -1991,9 +1991,6 @@ impl ScriptThread {
|
|||
DevtoolScriptControlMsg::GetLayout(id, node_id, reply) => {
|
||||
devtools::handle_get_layout(&*documents, id, node_id, reply)
|
||||
},
|
||||
DevtoolScriptControlMsg::GetCachedMessages(id, message_types, reply) => {
|
||||
devtools::handle_get_cached_messages(id, message_types, reply)
|
||||
},
|
||||
DevtoolScriptControlMsg::ModifyAttribute(id, node_id, modifications) => {
|
||||
devtools::handle_modify_attribute(&*documents, id, node_id, modifications)
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue