mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Make cached messages appear in FF's devtools.
This commit is contained in:
parent
f04779f398
commit
81c0d32a04
3 changed files with 66 additions and 42 deletions
|
@ -13,6 +13,7 @@ use protocol::JsonPacketStream;
|
|||
use devtools_traits::EvaluateJSReply::{NullValue, VoidValue, NumberValue};
|
||||
use devtools_traits::EvaluateJSReply::{StringValue, BooleanValue, ActorValue};
|
||||
use devtools_traits::{CachedConsoleMessageTypes, DevtoolScriptControlMsg, PAGE_ERROR, CONSOLE_API};
|
||||
use devtools_traits::CachedConsoleMessage;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
@ -21,6 +22,19 @@ use rustc_serialize::json::{self, Json, ToJson};
|
|||
use std::net::TcpStream;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
|
||||
trait EncodableConsoleMessage {
|
||||
fn encode(&self) -> json::EncodeResult<String>;
|
||||
}
|
||||
|
||||
impl EncodableConsoleMessage for CachedConsoleMessage {
|
||||
fn encode(&self) -> json::EncodeResult<String> {
|
||||
match *self {
|
||||
CachedConsoleMessage::PageError(ref a) => json::encode(a),
|
||||
CachedConsoleMessage::ConsoleAPI(ref a) => json::encode(a),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable)]
|
||||
struct StartedListenersTraits {
|
||||
customNetworkRequest: bool,
|
||||
|
@ -98,7 +112,9 @@ impl Actor for ConsoleActor {
|
|||
self.script_chan.send(DevtoolScriptControlMsg::GetCachedMessages(
|
||||
self.pipeline, message_types, chan)).unwrap();
|
||||
let messages = try!(port.recv().map_err(|_| ())).into_iter().map(|message| {
|
||||
json::encode(&message).unwrap().to_json().as_object().unwrap().to_owned()
|
||||
let json_string = message.encode().unwrap();
|
||||
let json = Json::from_str(&json_string).unwrap();
|
||||
json.as_object().unwrap().to_owned()
|
||||
}).collect();
|
||||
|
||||
let msg = GetCachedMessagesReply {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue