diff options
Diffstat (limited to 'components')
-rw-r--r-- | components/devtools/Cargo.toml | 1 | ||||
-rw-r--r-- | components/devtools/actor.rs | 8 | ||||
-rw-r--r-- | components/devtools/actors/console.rs | 2 | ||||
-rw-r--r-- | components/devtools/lib.rs | 10 | ||||
-rw-r--r-- | components/devtools/protocol.rs | 4 | ||||
-rw-r--r-- | components/script/devtools.rs | 4 | ||||
-rw-r--r-- | components/servo/Cargo.lock | 1 |
7 files changed, 18 insertions, 12 deletions
diff --git a/components/devtools/Cargo.toml b/components/devtools/Cargo.toml index 808fcfa5646..099b71edd3e 100644 --- a/components/devtools/Cargo.toml +++ b/components/devtools/Cargo.toml @@ -19,3 +19,4 @@ serde = "0.7" serde_json = "0.7" serde_macros = "0.7" time = "0.1" +log = "0.3.5" diff --git a/components/devtools/actor.rs b/components/devtools/actor.rs index 6ddb45335ee..c439ad0e028 100644 --- a/components/devtools/actor.rs +++ b/components/devtools/actor.rs @@ -92,7 +92,7 @@ impl ActorRegistry { } pub fn register_script_actor(&self, script_id: String, actor: String) { - println!("registering {} ({})", actor, script_id); + debug!("registering {} ({})", actor, script_id); let mut script_actors = self.script_actors.borrow_mut(); script_actors.insert(script_id, actor); } @@ -110,7 +110,7 @@ impl ActorRegistry { pub fn actor_to_script(&self, actor: String) -> String { for (key, value) in &*self.script_actors.borrow() { - println!("checking {}", value); + debug!("checking {}", value); if *value == actor { return key.to_owned(); } @@ -156,12 +156,12 @@ impl ActorRegistry { let to = msg.get("to").unwrap().as_string().unwrap(); match self.actors.get(to) { - None => println!("message received for unknown actor \"{}\"", to), + None => debug!("message received for unknown actor \"{}\"", to), Some(actor) => { let msg_type = msg.get("type").unwrap().as_string().unwrap(); if try!(actor.handle_message(self, msg_type, msg, stream)) != ActorMessageStatus::Processed { - println!("unexpected message type \"{}\" found for actor \"{}\"", + debug!("unexpected message type \"{}\" found for actor \"{}\"", msg_type, to); } } diff --git a/components/devtools/actors/console.rs b/components/devtools/actors/console.rs index 48c38d1cd47..d6cfbe10f51 100644 --- a/components/devtools/actors/console.rs +++ b/components/devtools/actors/console.rs @@ -110,7 +110,7 @@ impl Actor for ConsoleActor { match str_type { "PageError" => message_types.insert(PAGE_ERROR), "ConsoleAPI" => message_types.insert(CONSOLE_API), - s => println!("unrecognized message type requested: \"{}\"", s), + s => debug!("unrecognized message type requested: \"{}\"", s), }; }; let (chan, port) = ipc::channel().unwrap(); diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index 3aad044b485..d8e54ddad62 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -23,6 +23,8 @@ extern crate devtools_traits; extern crate hyper; extern crate ipc_channel; +#[macro_use] +extern crate log; extern crate msg; extern crate serde; extern crate serde_json; @@ -204,7 +206,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>, /// Process the input from a single devtools client until EOF. fn handle_client(actors: Arc<Mutex<ActorRegistry>>, mut stream: TcpStream) { - println!("connection established to {}", stream.peer_addr().unwrap()); + debug!("connection established to {}", stream.peer_addr().unwrap()); { let actors = actors.lock().unwrap(); let msg = actors.find::<RootActor>("root").encodable(); @@ -218,18 +220,18 @@ fn run_server(sender: Sender<DevtoolsControlMsg>, &mut stream) { Ok(()) => {}, Err(()) => { - println!("error: devtools actor stopped responding"); + debug!("error: devtools actor stopped responding"); let _ = stream.shutdown(Shutdown::Both); break 'outer } } } Ok(None) => { - println!("error: EOF"); + debug!("error: EOF"); break 'outer } Err(err_msg) => { - println!("error: {}", err_msg); + debug!("error: {}", err_msg); break 'outer } } diff --git a/components/devtools/protocol.rs b/components/devtools/protocol.rs index 53975bc3501..cb75572f3b8 100644 --- a/components/devtools/protocol.rs +++ b/components/devtools/protocol.rs @@ -20,7 +20,7 @@ pub trait JsonPacketStream { impl JsonPacketStream for TcpStream { fn write_json_packet<T: Serialize>(&mut self, obj: &T) { let s = serde_json::to_string(obj).unwrap(); - println!("<- {}", s); + debug!("<- {}", s); write!(self, "{}:{}", s.len(), s).unwrap(); } @@ -48,7 +48,7 @@ impl JsonPacketStream for TcpStream { }; let mut packet = String::new(); self.take(packet_len).read_to_string(&mut packet).unwrap(); - println!("{}", packet); + debug!("{}", packet); return match serde_json::from_str(&packet) { Ok(json) => Ok(Some(json)), Err(err) => match err { diff --git a/components/script/devtools.rs b/components/script/devtools.rs index e818b0c0ca0..8f783126a62 100644 --- a/components/script/devtools.rs +++ b/components/script/devtools.rs @@ -21,7 +21,7 @@ use dom::element::Element; use dom::node::Node; use dom::window::Window; use ipc_channel::ipc::IpcSender; -use js::jsapi::{ObjectClassName, RootedObject, RootedValue}; +use js::jsapi::{JSAutoCompartment, ObjectClassName, RootedObject, RootedValue}; use js::jsval::UndefinedValue; use msg::constellation_msg::PipelineId; use script_thread::get_browsing_context; @@ -35,6 +35,8 @@ pub fn handle_evaluate_js(global: &GlobalRef, eval: String, reply: IpcSender<Eva // global.get_cx() returns a valid `JSContext` pointer, so this is safe. let result = unsafe { let cx = global.get_cx(); + let globalhandle = global.reflector().get_jsobject(); + let _ac = JSAutoCompartment::new(cx, globalhandle.get()); let mut rval = RootedValue::new(cx, UndefinedValue()); global.evaluate_js_on_global_with_result(&eval, rval.handle_mut()); diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 238d0fb03f6..8f2d799739a 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -479,6 +479,7 @@ dependencies = [ "devtools_traits 0.0.1", "hyper 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.2.2 (git+https://github.com/servo/ipc-channel)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "plugins 0.0.1", "serde 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", |