mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
DevTools: Replace camel case variable names (#32726)
* refactor: rename to snake case * refactor: more renaming * chore: format * chore: clean
This commit is contained in:
parent
b243457ccc
commit
2888193cfe
22 changed files with 363 additions and 323 deletions
|
@ -194,7 +194,7 @@ impl BrowsingContextActor {
|
|||
let inspector = InspectorActor {
|
||||
name: actors.new_name("inspector"),
|
||||
walker: RefCell::new(None),
|
||||
pageStyle: RefCell::new(None),
|
||||
page_style: RefCell::new(None),
|
||||
highlighter: RefCell::new(None),
|
||||
script_chan: script_sender.clone(),
|
||||
browsing_context: name.clone(),
|
||||
|
|
|
@ -49,10 +49,11 @@ impl EncodableConsoleMessage for CachedConsoleMessage {
|
|||
struct StartedListenersTraits;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct StartedListenersReply {
|
||||
from: String,
|
||||
nativeConsoleAPI: bool,
|
||||
startedListeners: Vec<String>,
|
||||
native_console_api: bool,
|
||||
started_listeners: Vec<String>,
|
||||
traits: StartedListenersTraits,
|
||||
}
|
||||
|
||||
|
@ -63,46 +64,53 @@ struct GetCachedMessagesReply {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct StopListenersReply {
|
||||
from: String,
|
||||
stoppedListeners: Vec<String>,
|
||||
stopped_listeners: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct AutocompleteReply {
|
||||
from: String,
|
||||
matches: Vec<String>,
|
||||
matchProp: String,
|
||||
match_prop: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct EvaluateJSReply {
|
||||
from: String,
|
||||
input: String,
|
||||
result: Value,
|
||||
timestamp: u64,
|
||||
exception: Value,
|
||||
exceptionMessage: Value,
|
||||
helperResult: Value,
|
||||
exception_message: Value,
|
||||
helper_result: Value,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct EvaluateJSEvent {
|
||||
from: String,
|
||||
r#type: String,
|
||||
#[serde(rename = "type")]
|
||||
type_: String,
|
||||
input: String,
|
||||
result: Value,
|
||||
timestamp: u64,
|
||||
resultID: String,
|
||||
#[serde(rename = "resultID")]
|
||||
result_id: String,
|
||||
exception: Value,
|
||||
exceptionMessage: Value,
|
||||
helperResult: Value,
|
||||
exception_message: Value,
|
||||
helper_result: Value,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct EvaluateJSAsyncReply {
|
||||
from: String,
|
||||
resultID: String,
|
||||
#[serde(rename = "resultID")]
|
||||
result_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -162,7 +170,7 @@ impl ConsoleActor {
|
|||
}
|
||||
}
|
||||
|
||||
fn evaluateJS(
|
||||
fn evaluate_js(
|
||||
&self,
|
||||
registry: &ActorRegistry,
|
||||
msg: &Map<String, Value>,
|
||||
|
@ -240,8 +248,8 @@ impl ConsoleActor {
|
|||
result,
|
||||
timestamp: 0,
|
||||
exception: Value::Null,
|
||||
exceptionMessage: Value::Null,
|
||||
helperResult: Value::Null,
|
||||
exception_message: Value::Null,
|
||||
helper_result: Value::Null,
|
||||
};
|
||||
std::result::Result::Ok(reply)
|
||||
}
|
||||
|
@ -261,7 +269,7 @@ impl ConsoleActor {
|
|||
let msg = PageErrorMsg {
|
||||
from: self.name(),
|
||||
type_: "pageError".to_owned(),
|
||||
pageError: page_error,
|
||||
page_error,
|
||||
};
|
||||
self.streams_mut(registry, |stream| {
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
|
@ -275,7 +283,7 @@ impl ConsoleActor {
|
|||
id: UniqueId,
|
||||
registry: &ActorRegistry,
|
||||
) {
|
||||
let level = match console_message.logLevel {
|
||||
let level = match console_message.log_level {
|
||||
LogLevel::Debug => "debug",
|
||||
LogLevel::Info => "info",
|
||||
LogLevel::Warn => "warn",
|
||||
|
@ -292,9 +300,9 @@ impl ConsoleActor {
|
|||
type_: "ConsoleAPI".to_owned(),
|
||||
level: level.clone(),
|
||||
filename: console_message.filename.clone(),
|
||||
lineNumber: console_message.lineNumber as u32,
|
||||
functionName: "".to_string(), //TODO
|
||||
timeStamp: SystemTime::now()
|
||||
line_number: console_message.line_number as u32,
|
||||
function_name: "".to_string(), //TODO
|
||||
time_stamp: SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_nanos() as u64,
|
||||
|
@ -307,14 +315,14 @@ impl ConsoleActor {
|
|||
type_: "consoleAPICall".to_owned(),
|
||||
message: ConsoleMsg {
|
||||
level,
|
||||
timeStamp: SystemTime::now()
|
||||
timestamp: SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_nanos() as u64,
|
||||
arguments: vec![console_message.message],
|
||||
filename: console_message.filename,
|
||||
lineNumber: console_message.lineNumber,
|
||||
columnNumber: console_message.columnNumber,
|
||||
line_number: console_message.line_number,
|
||||
column_number: console_message.column_number,
|
||||
},
|
||||
};
|
||||
self.streams_mut(registry, |stream| {
|
||||
|
@ -404,8 +412,8 @@ impl Actor for ConsoleActor {
|
|||
let listeners = msg.get("listeners").unwrap().as_array().unwrap().to_owned();
|
||||
let msg = StartedListenersReply {
|
||||
from: self.name(),
|
||||
nativeConsoleAPI: true,
|
||||
startedListeners: listeners
|
||||
native_console_api: true,
|
||||
started_listeners: listeners
|
||||
.into_iter()
|
||||
.map(|s| s.as_str().unwrap().to_owned())
|
||||
.collect(),
|
||||
|
@ -419,7 +427,7 @@ impl Actor for ConsoleActor {
|
|||
//TODO: actually implement listener filters that support starting/stopping
|
||||
let msg = StopListenersReply {
|
||||
from: self.name(),
|
||||
stoppedListeners: msg
|
||||
stopped_listeners: msg
|
||||
.get("listeners")
|
||||
.unwrap()
|
||||
.as_array()
|
||||
|
@ -438,23 +446,23 @@ impl Actor for ConsoleActor {
|
|||
let msg = AutocompleteReply {
|
||||
from: self.name(),
|
||||
matches: vec![],
|
||||
matchProp: "".to_owned(),
|
||||
match_prop: "".to_owned(),
|
||||
};
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
|
||||
"evaluateJS" => {
|
||||
let msg = self.evaluateJS(registry, msg);
|
||||
let msg = self.evaluate_js(registry, msg);
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
|
||||
"evaluateJSAsync" => {
|
||||
let resultID = Uuid::new_v4().to_string();
|
||||
let result_id = Uuid::new_v4().to_string();
|
||||
let early_reply = EvaluateJSAsyncReply {
|
||||
from: self.name(),
|
||||
resultID: resultID.clone(),
|
||||
result_id: result_id.clone(),
|
||||
};
|
||||
// Emit an eager reply so that the client starts listening
|
||||
// for an async event with the resultID
|
||||
|
@ -468,17 +476,17 @@ impl Actor for ConsoleActor {
|
|||
return Ok(ActorMessageStatus::Processed);
|
||||
}
|
||||
|
||||
let reply = self.evaluateJS(registry, msg).unwrap();
|
||||
let reply = self.evaluate_js(registry, msg).unwrap();
|
||||
let msg = EvaluateJSEvent {
|
||||
from: self.name(),
|
||||
r#type: "evaluationResult".to_owned(),
|
||||
type_: "evaluationResult".to_owned(),
|
||||
input: reply.input,
|
||||
result: reply.result,
|
||||
timestamp: reply.timestamp,
|
||||
resultID,
|
||||
result_id,
|
||||
exception: reply.exception,
|
||||
exceptionMessage: reply.exceptionMessage,
|
||||
helperResult: reply.helperResult,
|
||||
exception_message: reply.exception_message,
|
||||
helper_result: reply.helper_result,
|
||||
};
|
||||
// Send the data from evaluateJS along with a resultID
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
|
@ -508,19 +516,21 @@ struct ConsoleAPICall {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ConsoleMsg {
|
||||
level: String,
|
||||
timeStamp: u64,
|
||||
timestamp: u64,
|
||||
arguments: Vec<String>,
|
||||
filename: String,
|
||||
lineNumber: usize,
|
||||
columnNumber: usize,
|
||||
line_number: usize,
|
||||
column_number: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct PageErrorMsg {
|
||||
from: String,
|
||||
#[serde(rename = "type")]
|
||||
type_: String,
|
||||
pageError: PageError,
|
||||
page_error: PageError,
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ struct GetDescriptionReply {
|
|||
// This is only a minimal subset of the properties exposed/expected by Firefox
|
||||
// (see https://searchfox.org/mozilla-central/source/devtools/shared/system.js#45)
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct SystemInfo {
|
||||
apptype: String,
|
||||
// Display version
|
||||
|
@ -30,7 +31,7 @@ struct SystemInfo {
|
|||
// Firefox major.minor version number, use for compatibility checks
|
||||
platformversion: String,
|
||||
// Display name
|
||||
brandName: String,
|
||||
brand_name: String,
|
||||
}
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/build_id.rs"));
|
||||
|
@ -60,7 +61,7 @@ impl Actor for DeviceActor {
|
|||
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
appbuildid: BUILD_ID.to_string(),
|
||||
platformversion: "125.0".to_string(),
|
||||
brandName: "Servo".to_string(),
|
||||
brand_name: "Servo".to_string(),
|
||||
},
|
||||
};
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
|
@ -80,7 +81,7 @@ impl DeviceActor {
|
|||
pub fn description() -> ActorDescription {
|
||||
ActorDescription {
|
||||
category: "actor",
|
||||
typeName: "device",
|
||||
type_name: "device",
|
||||
methods: vec.
|
||||
|
||||
#![allow(non_snake_case)] // NOTE: To be removed on the inspector specific pr
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::net::TcpStream;
|
||||
|
||||
|
@ -24,7 +26,7 @@ use crate::StreamId;
|
|||
pub struct InspectorActor {
|
||||
pub name: String,
|
||||
pub walker: RefCell<Option<String>>,
|
||||
pub pageStyle: RefCell<Option<String>>,
|
||||
pub page_style: RefCell<Option<String>>,
|
||||
pub highlighter: RefCell<Option<String>>,
|
||||
pub script_chan: IpcSender<DevtoolScriptControlMsg>,
|
||||
pub browsing_context: String,
|
||||
|
@ -203,32 +205,32 @@ impl NodeInfoToProtocol for NodeInfo {
|
|||
script_chan: IpcSender<DevtoolScriptControlMsg>,
|
||||
pipeline: PipelineId,
|
||||
) -> NodeActorMsg {
|
||||
let actor_name = if !actors.script_actor_registered(self.uniqueId.clone()) {
|
||||
let actor_name = if !actors.script_actor_registered(self.unique_id.clone()) {
|
||||
let name = actors.new_name("node");
|
||||
let node_actor = NodeActor {
|
||||
name: name.clone(),
|
||||
script_chan,
|
||||
pipeline,
|
||||
};
|
||||
actors.register_script_actor(self.uniqueId, name.clone());
|
||||
actors.register_script_actor(self.unique_id, name.clone());
|
||||
actors.register_later(Box::new(node_actor));
|
||||
name
|
||||
} else {
|
||||
actors.script_to_actor(self.uniqueId)
|
||||
actors.script_to_actor(self.unique_id)
|
||||
};
|
||||
|
||||
NodeActorMsg {
|
||||
actor: actor_name,
|
||||
baseURI: self.baseURI,
|
||||
baseURI: self.base_uri,
|
||||
parent: actors.script_to_actor(self.parent.clone()),
|
||||
nodeType: self.nodeType,
|
||||
namespaceURI: self.namespaceURI,
|
||||
nodeName: self.nodeName,
|
||||
numChildren: self.numChildren,
|
||||
nodeType: self.node_type,
|
||||
namespaceURI: self.namespace_uri,
|
||||
nodeName: self.node_name,
|
||||
numChildren: self.num_children,
|
||||
|
||||
name: self.name,
|
||||
publicId: self.publicId,
|
||||
systemId: self.systemId,
|
||||
publicId: self.public_id,
|
||||
systemId: self.system_id,
|
||||
|
||||
attrs: self
|
||||
.attrs
|
||||
|
@ -246,10 +248,10 @@ impl NodeInfoToProtocol for NodeInfo {
|
|||
|
||||
hasEventListeners: false, //TODO get this data from script
|
||||
|
||||
isDocumentElement: self.isDocumentElement,
|
||||
isDocumentElement: self.is_document_element,
|
||||
|
||||
shortValue: self.shortValue,
|
||||
incompleteValue: self.incompleteValue,
|
||||
shortValue: self.short_value,
|
||||
incompleteValue: self.incomplete_value,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -517,21 +519,21 @@ impl Actor for PageStyleActor {
|
|||
let ComputedNodeLayout {
|
||||
display,
|
||||
position,
|
||||
zIndex,
|
||||
boxSizing,
|
||||
autoMargins,
|
||||
marginTop,
|
||||
marginRight,
|
||||
marginBottom,
|
||||
marginLeft,
|
||||
borderTopWidth,
|
||||
borderRightWidth,
|
||||
borderBottomWidth,
|
||||
borderLeftWidth,
|
||||
paddingTop,
|
||||
paddingRight,
|
||||
paddingBottom,
|
||||
paddingLeft,
|
||||
z_index: zIndex,
|
||||
box_sizing: boxSizing,
|
||||
auto_margins: autoMargins,
|
||||
margin_top: marginTop,
|
||||
margin_right: marginRight,
|
||||
margin_bottom: marginBottom,
|
||||
margin_left: marginLeft,
|
||||
border_top_width: borderTopWidth,
|
||||
border_right_width: borderRightWidth,
|
||||
border_bottom_width: borderBottomWidth,
|
||||
border_left_width: borderLeftWidth,
|
||||
padding_top: paddingTop,
|
||||
padding_right: paddingRight,
|
||||
padding_bottom: paddingBottom,
|
||||
padding_left: paddingLeft,
|
||||
width,
|
||||
height,
|
||||
} = rx.recv().unwrap().ok_or(())?;
|
||||
|
@ -639,13 +641,13 @@ impl Actor for InspectorActor {
|
|||
},
|
||||
|
||||
"getPageStyle" => {
|
||||
if self.pageStyle.borrow().is_none() {
|
||||
if self.page_style.borrow().is_none() {
|
||||
let style = PageStyleActor {
|
||||
name: registry.new_name("pageStyle"),
|
||||
script_chan: self.script_chan.clone(),
|
||||
pipeline,
|
||||
};
|
||||
let mut pageStyle = self.pageStyle.borrow_mut();
|
||||
let mut pageStyle = self.page_style.borrow_mut();
|
||||
*pageStyle = Some(style.name());
|
||||
registry.register_later(Box::new(style));
|
||||
}
|
||||
|
@ -653,7 +655,7 @@ impl Actor for InspectorActor {
|
|||
let msg = GetPageStyleReply {
|
||||
from: self.name(),
|
||||
pageStyle: PageStyleMsg {
|
||||
actor: self.pageStyle.borrow().clone().unwrap(),
|
||||
actor: self.page_style.borrow().clone().unwrap(),
|
||||
},
|
||||
};
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
|
|
|
@ -11,16 +11,18 @@ use crate::actor::{Actor, ActorMessageStatus, ActorRegistry};
|
|||
use crate::StreamId;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TimelineMemoryReply {
|
||||
jsObjectSize: u64,
|
||||
jsStringSize: u64,
|
||||
jsOtherSize: u64,
|
||||
domSize: u64,
|
||||
styleSize: u64,
|
||||
otherSize: u64,
|
||||
totalSize: u64,
|
||||
jsMilliseconds: f64,
|
||||
nonJSMilliseconds: f64,
|
||||
js_object_size: u64,
|
||||
js_string_size: u64,
|
||||
js_other_size: u64,
|
||||
dom_size: u64,
|
||||
style_size: u64,
|
||||
other_size: u64,
|
||||
total_size: u64,
|
||||
js_milliseconds: f64,
|
||||
#[serde(rename = "nonJSMilliseconds")]
|
||||
non_js_milliseconds: f64,
|
||||
}
|
||||
|
||||
pub struct MemoryActor {
|
||||
|
@ -57,17 +59,16 @@ impl MemoryActor {
|
|||
}
|
||||
|
||||
pub fn measure(&self) -> TimelineMemoryReply {
|
||||
//TODO:
|
||||
TimelineMemoryReply {
|
||||
jsObjectSize: 1,
|
||||
jsStringSize: 1,
|
||||
jsOtherSize: 1,
|
||||
domSize: 1,
|
||||
styleSize: 1,
|
||||
otherSize: 1,
|
||||
totalSize: 1,
|
||||
jsMilliseconds: 1.1,
|
||||
nonJSMilliseconds: 1.1,
|
||||
js_object_size: 1,
|
||||
js_string_size: 1,
|
||||
js_other_size: 1,
|
||||
dom_size: 1,
|
||||
style_size: 1,
|
||||
other_size: 1,
|
||||
total_size: 1,
|
||||
js_milliseconds: 1.1,
|
||||
non_js_milliseconds: 1.1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ struct HttpRequest {
|
|||
method: Method,
|
||||
headers: HeaderMap,
|
||||
body: Option<Vec<u8>>,
|
||||
startedDateTime: SystemTime,
|
||||
timeStamp: i64,
|
||||
started_date_time: SystemTime,
|
||||
time_stamp: i64,
|
||||
connect_time: u64,
|
||||
send_time: u64,
|
||||
}
|
||||
|
@ -44,13 +44,15 @@ pub struct NetworkEventActor {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EventActor {
|
||||
pub actor: String,
|
||||
pub url: String,
|
||||
pub method: String,
|
||||
pub startedDateTime: String,
|
||||
pub timeStamp: i64,
|
||||
pub isXHR: bool,
|
||||
pub started_date_time: String,
|
||||
pub time_stamp: i64,
|
||||
#[serde(rename = "isXHR")]
|
||||
pub is_xhr: bool,
|
||||
pub private: bool,
|
||||
}
|
||||
|
||||
|
@ -60,28 +62,31 @@ pub struct ResponseCookiesMsg {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ResponseStartMsg {
|
||||
pub httpVersion: String,
|
||||
pub remoteAddress: String,
|
||||
pub remotePort: u32,
|
||||
pub http_version: String,
|
||||
pub remote_address: String,
|
||||
pub remote_port: u32,
|
||||
pub status: String,
|
||||
pub statusText: String,
|
||||
pub headersSize: usize,
|
||||
pub discardResponseBody: bool,
|
||||
pub status_text: String,
|
||||
pub headers_size: usize,
|
||||
pub discard_response_body: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ResponseContentMsg {
|
||||
pub mimeType: String,
|
||||
pub contentSize: u32,
|
||||
pub transferredSize: u32,
|
||||
pub discardResponseBody: bool,
|
||||
pub mime_type: String,
|
||||
pub content_size: u32,
|
||||
pub transferred_size: u32,
|
||||
pub discard_response_body: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ResponseHeadersMsg {
|
||||
pub headers: usize,
|
||||
pub headersSize: usize,
|
||||
pub headers_size: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -90,17 +95,19 @@ pub struct RequestCookiesMsg {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RequestHeadersMsg {
|
||||
headers: usize,
|
||||
headersSize: usize,
|
||||
headers_size: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct GetRequestHeadersReply {
|
||||
from: String,
|
||||
headers: Vec<Header>,
|
||||
headerSize: usize,
|
||||
rawHeaders: String,
|
||||
header_size: usize,
|
||||
raw_headers: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -110,25 +117,28 @@ struct Header {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct GetResponseHeadersReply {
|
||||
from: String,
|
||||
headers: Vec<Header>,
|
||||
headerSize: usize,
|
||||
rawHeaders: String,
|
||||
header_size: usize,
|
||||
raw_headers: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct GetResponseContentReply {
|
||||
from: String,
|
||||
content: Option<Vec<u8>>,
|
||||
contentDiscarded: bool,
|
||||
content_discarded: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct GetRequestPostDataReply {
|
||||
from: String,
|
||||
postData: Option<Vec<u8>>,
|
||||
postDataDiscarded: bool,
|
||||
post_data: Option<Vec<u8>>,
|
||||
post_data_discarded: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -154,10 +164,11 @@ struct Timings {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct GetEventTimingsReply {
|
||||
from: String,
|
||||
timings: Timings,
|
||||
totalTime: u64,
|
||||
total_time: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -166,9 +177,10 @@ struct SecurityInfo {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct GetSecurityInfoReply {
|
||||
from: String,
|
||||
securityInfo: SecurityInfo,
|
||||
security_info: SecurityInfo,
|
||||
}
|
||||
|
||||
impl Actor for NetworkEventActor {
|
||||
|
@ -187,12 +199,12 @@ impl Actor for NetworkEventActor {
|
|||
Ok(match msg_type {
|
||||
"getRequestHeaders" => {
|
||||
let mut headers = Vec::new();
|
||||
let mut rawHeadersString = "".to_owned();
|
||||
let mut headersSize = 0;
|
||||
let mut raw_headers_string = "".to_owned();
|
||||
let mut headers_size = 0;
|
||||
for (name, value) in self.request.headers.iter() {
|
||||
let value = &value.to_str().unwrap().to_string();
|
||||
rawHeadersString = rawHeadersString + name.as_str() + ":" + value + "\r\n";
|
||||
headersSize += name.as_str().len() + value.len();
|
||||
raw_headers_string = raw_headers_string + name.as_str() + ":" + value + "\r\n";
|
||||
headers_size += name.as_str().len() + value.len();
|
||||
headers.push(Header {
|
||||
name: name.as_str().to_owned(),
|
||||
value: value.to_owned(),
|
||||
|
@ -201,8 +213,8 @@ impl Actor for NetworkEventActor {
|
|||
let msg = GetRequestHeadersReply {
|
||||
from: self.name(),
|
||||
headers,
|
||||
headerSize: headersSize,
|
||||
rawHeaders: rawHeadersString,
|
||||
header_size: headers_size,
|
||||
raw_headers: raw_headers_string,
|
||||
};
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
ActorMessageStatus::Processed
|
||||
|
@ -226,8 +238,8 @@ impl Actor for NetworkEventActor {
|
|||
"getRequestPostData" => {
|
||||
let msg = GetRequestPostDataReply {
|
||||
from: self.name(),
|
||||
postData: self.request.body.clone(),
|
||||
postDataDiscarded: false,
|
||||
post_data: self.request.body.clone(),
|
||||
post_data_discarded: false,
|
||||
};
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
ActorMessageStatus::Processed
|
||||
|
@ -235,24 +247,24 @@ impl Actor for NetworkEventActor {
|
|||
"getResponseHeaders" => {
|
||||
if let Some(ref response_headers) = self.response.headers {
|
||||
let mut headers = vec![];
|
||||
let mut rawHeadersString = "".to_owned();
|
||||
let mut headersSize = 0;
|
||||
let mut raw_headers_string = "".to_owned();
|
||||
let mut headers_size = 0;
|
||||
for (name, value) in response_headers.iter() {
|
||||
headers.push(Header {
|
||||
name: name.as_str().to_owned(),
|
||||
value: value.to_str().unwrap().to_owned(),
|
||||
});
|
||||
headersSize += name.as_str().len() + value.len();
|
||||
rawHeadersString.push_str(name.as_str());
|
||||
rawHeadersString.push(':');
|
||||
rawHeadersString.push_str(value.to_str().unwrap());
|
||||
rawHeadersString.push_str("\r\n");
|
||||
headers_size += name.as_str().len() + value.len();
|
||||
raw_headers_string.push_str(name.as_str());
|
||||
raw_headers_string.push(':');
|
||||
raw_headers_string.push_str(value.to_str().unwrap());
|
||||
raw_headers_string.push_str("\r\n");
|
||||
}
|
||||
let msg = GetResponseHeadersReply {
|
||||
from: self.name(),
|
||||
headers,
|
||||
headerSize: headersSize,
|
||||
rawHeaders: rawHeadersString,
|
||||
header_size: headers_size,
|
||||
raw_headers: raw_headers_string,
|
||||
};
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
}
|
||||
|
@ -278,14 +290,14 @@ impl Actor for NetworkEventActor {
|
|||
let msg = GetResponseContentReply {
|
||||
from: self.name(),
|
||||
content: self.response.body.clone(),
|
||||
contentDiscarded: self.response.body.is_none(),
|
||||
content_discarded: self.response.body.is_none(),
|
||||
};
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
"getEventTimings" => {
|
||||
// TODO: This is a fake timings msg
|
||||
let timingsObj = Timings {
|
||||
let timings_obj = Timings {
|
||||
blocked: 0,
|
||||
dns: 0,
|
||||
connect: self.request.connect_time,
|
||||
|
@ -293,12 +305,12 @@ impl Actor for NetworkEventActor {
|
|||
wait: 0,
|
||||
receive: 0,
|
||||
};
|
||||
let total = timingsObj.connect + timingsObj.send;
|
||||
let total = timings_obj.connect + timings_obj.send;
|
||||
// TODO: Send the correct values for all these fields.
|
||||
let msg = GetEventTimingsReply {
|
||||
from: self.name(),
|
||||
timings: timingsObj,
|
||||
totalTime: total,
|
||||
timings: timings_obj,
|
||||
total_time: total,
|
||||
};
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
ActorMessageStatus::Processed
|
||||
|
@ -307,7 +319,7 @@ impl Actor for NetworkEventActor {
|
|||
// TODO: Send the correct values for securityInfo.
|
||||
let msg = GetSecurityInfoReply {
|
||||
from: self.name(),
|
||||
securityInfo: SecurityInfo {
|
||||
security_info: SecurityInfo {
|
||||
state: "insecure".to_owned(),
|
||||
},
|
||||
};
|
||||
|
@ -328,8 +340,8 @@ impl NetworkEventActor {
|
|||
method: Method::GET,
|
||||
headers: HeaderMap::new(),
|
||||
body: None,
|
||||
startedDateTime: SystemTime::now(),
|
||||
timeStamp: SystemTime::now()
|
||||
started_date_time: SystemTime::now(),
|
||||
time_stamp: SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_secs() as i64,
|
||||
|
@ -351,8 +363,8 @@ impl NetworkEventActor {
|
|||
self.request.method = request.method.clone();
|
||||
self.request.headers = request.headers.clone();
|
||||
self.request.body = request.body;
|
||||
self.request.startedDateTime = request.startedDateTime;
|
||||
self.request.timeStamp = request.timeStamp;
|
||||
self.request.started_date_time = request.started_date_time;
|
||||
self.request.time_stamp = request.time_stamp;
|
||||
self.request.connect_time = request.connect_time;
|
||||
self.request.send_time = request.send_time;
|
||||
self.is_xhr = request.is_xhr;
|
||||
|
@ -372,31 +384,31 @@ impl NetworkEventActor {
|
|||
|
||||
let started_datetime_rfc3339 = match Local.timestamp_millis_opt(
|
||||
self.request
|
||||
.startedDateTime
|
||||
.started_date_time
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_millis() as i64,
|
||||
) {
|
||||
LocalResult::None => "".to_owned(),
|
||||
LocalResult::Single(dateTime) => dateTime.to_rfc3339().to_string(),
|
||||
LocalResult::Ambiguous(dateTime, _) => dateTime.to_rfc3339().to_string(),
|
||||
LocalResult::Single(date_time) => date_time.to_rfc3339().to_string(),
|
||||
LocalResult::Ambiguous(date_time, _) => date_time.to_rfc3339().to_string(),
|
||||
};
|
||||
|
||||
EventActor {
|
||||
actor: self.name(),
|
||||
url: self.request.url.clone(),
|
||||
method: format!("{}", self.request.method),
|
||||
startedDateTime: started_datetime_rfc3339,
|
||||
timeStamp: self.request.timeStamp,
|
||||
isXHR: self.is_xhr,
|
||||
started_date_time: started_datetime_rfc3339,
|
||||
time_stamp: self.request.time_stamp,
|
||||
is_xhr: self.is_xhr,
|
||||
private: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn response_start(&self) -> ResponseStartMsg {
|
||||
// TODO: Send the correct values for all these fields.
|
||||
let hSizeOption = self.response.headers.as_ref().map(|headers| headers.len());
|
||||
let hSize = hSizeOption.unwrap_or(0);
|
||||
let h_size_option = self.response.headers.as_ref().map(|headers| headers.len());
|
||||
let h_size = h_size_option.unwrap_or(0);
|
||||
let (status_code, status_message) = self
|
||||
.response
|
||||
.status
|
||||
|
@ -406,30 +418,30 @@ impl NetworkEventActor {
|
|||
});
|
||||
// TODO: Send the correct values for remoteAddress and remotePort and http_version.
|
||||
ResponseStartMsg {
|
||||
httpVersion: "HTTP/1.1".to_owned(),
|
||||
remoteAddress: "63.245.217.43".to_owned(),
|
||||
remotePort: 443,
|
||||
http_version: "HTTP/1.1".to_owned(),
|
||||
remote_address: "63.245.217.43".to_owned(),
|
||||
remote_port: 443,
|
||||
status: status_code.to_string(),
|
||||
statusText: status_message,
|
||||
headersSize: hSize,
|
||||
discardResponseBody: false,
|
||||
status_text: status_message,
|
||||
headers_size: h_size,
|
||||
discard_response_body: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn response_content(&self) -> ResponseContentMsg {
|
||||
let mut mString = "".to_owned();
|
||||
let mut m_string = "".to_owned();
|
||||
if let Some(ref headers) = self.response.headers {
|
||||
mString = match headers.typed_get::<ContentType>() {
|
||||
m_string = match headers.typed_get::<ContentType>() {
|
||||
Some(ct) => ct.to_string(),
|
||||
_ => "".to_owned(),
|
||||
};
|
||||
}
|
||||
// TODO: Set correct values when response's body is sent to the devtools in http_loader.
|
||||
ResponseContentMsg {
|
||||
mimeType: mString,
|
||||
contentSize: 0,
|
||||
transferredSize: 0,
|
||||
discardResponseBody: true,
|
||||
mime_type: m_string,
|
||||
content_size: 0,
|
||||
transferred_size: 0,
|
||||
discard_response_body: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,7 +469,7 @@ impl NetworkEventActor {
|
|||
}
|
||||
ResponseHeadersMsg {
|
||||
headers: headers_size,
|
||||
headersSize: headers_byte_count,
|
||||
headers_size: headers_byte_count,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -467,7 +479,7 @@ impl NetworkEventActor {
|
|||
});
|
||||
RequestHeadersMsg {
|
||||
headers: self.request.headers.len(),
|
||||
headersSize: size,
|
||||
headers_size: size,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,12 +16,14 @@ pub struct PerformanceActor {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct PerformanceFeatures {
|
||||
withMarkers: bool,
|
||||
withMemory: bool,
|
||||
withTicks: bool,
|
||||
withAllocations: bool,
|
||||
withJITOptimizations: bool,
|
||||
with_markers: bool,
|
||||
with_memory: bool,
|
||||
with_ticks: bool,
|
||||
with_allocations: bool,
|
||||
#[serde(rename = "withJITOptimizations")]
|
||||
with_jitoptimizations: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -69,11 +71,11 @@ impl Actor for PerformanceActor {
|
|||
from: self.name(),
|
||||
traits: PerformanceTraits {
|
||||
features: PerformanceFeatures {
|
||||
withMarkers: true,
|
||||
withMemory: true,
|
||||
withTicks: true,
|
||||
withAllocations: true,
|
||||
withJITOptimizations: true,
|
||||
with_markers: true,
|
||||
with_memory: true,
|
||||
with_ticks: true,
|
||||
with_allocations: true,
|
||||
with_jitoptimizations: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -104,7 +106,7 @@ impl PerformanceActor {
|
|||
pub fn description() -> ActorDescription {
|
||||
ActorDescription {
|
||||
category: "actor",
|
||||
typeName: "performance",
|
||||
type_name: "performance",
|
||||
methods: vec![Method {
|
||||
name: "canCurrentlyRecord",
|
||||
request: Value::Object(
|
||||
|
|
|
@ -12,9 +12,10 @@ use crate::protocol::JsonPacketStream;
|
|||
use crate::StreamId;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct GetStyleSheetsReply {
|
||||
from: String,
|
||||
styleSheets: Vec<u32>, // TODO: real JSON structure.
|
||||
style_sheets: Vec<u32>, // TODO: real JSON structure.
|
||||
}
|
||||
|
||||
pub struct StyleSheetsActor {
|
||||
|
@ -37,7 +38,7 @@ impl Actor for StyleSheetsActor {
|
|||
"getStyleSheets" => {
|
||||
let msg = GetStyleSheetsReply {
|
||||
from: self.name(),
|
||||
styleSheets: vec![],
|
||||
style_sheets: vec![],
|
||||
};
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
ActorMessageStatus::Processed
|
||||
|
|
|
@ -12,6 +12,7 @@ use crate::protocol::JsonPacketStream;
|
|||
use crate::StreamId;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ThreadAttached {
|
||||
from: String,
|
||||
#[serde(rename = "type")]
|
||||
|
@ -19,9 +20,9 @@ struct ThreadAttached {
|
|||
actor: String,
|
||||
frame: u32,
|
||||
error: u32,
|
||||
recordingEndpoint: u32,
|
||||
executionPoint: u32,
|
||||
poppedFrames: Vec<PoppedFrameMsg>,
|
||||
recording_endpoint: u32,
|
||||
execution_point: u32,
|
||||
popped_frames: Vec<PoppedFrameMsg>,
|
||||
why: WhyMsg,
|
||||
}
|
||||
|
||||
|
@ -98,9 +99,9 @@ impl Actor for ThreadActor {
|
|||
actor: registry.new_name("pause"),
|
||||
frame: 0,
|
||||
error: 0,
|
||||
recordingEndpoint: 0,
|
||||
executionPoint: 0,
|
||||
poppedFrames: vec![],
|
||||
recording_endpoint: 0,
|
||||
execution_point: 0,
|
||||
popped_frames: vec![],
|
||||
why: WhyMsg {
|
||||
type_: "attached".to_owned(),
|
||||
},
|
||||
|
|
|
@ -63,21 +63,23 @@ struct StopReply {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct TimelineMarkerReply {
|
||||
name: String,
|
||||
start: HighResolutionStamp,
|
||||
end: HighResolutionStamp,
|
||||
stack: Option<Vec<()>>,
|
||||
endStack: Option<Vec<()>>,
|
||||
end_stack: Option<Vec<()>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct MarkersEmitterReply {
|
||||
#[serde(rename = "type")]
|
||||
type_: String,
|
||||
markers: Vec<TimelineMarkerReply>,
|
||||
from: String,
|
||||
endTime: HighResolutionStamp,
|
||||
end_time: HighResolutionStamp,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -312,7 +314,7 @@ impl Emitter {
|
|||
start: HighResolutionStamp::new(self.start_stamp, payload.start_time),
|
||||
end: HighResolutionStamp::new(self.start_stamp, payload.end_time),
|
||||
stack: payload.start_stack,
|
||||
endStack: payload.end_stack,
|
||||
end_stack: payload.end_stack,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,7 +324,7 @@ impl Emitter {
|
|||
type_: "markers".to_owned(),
|
||||
markers,
|
||||
from: self.from.clone(),
|
||||
endTime: HighResolutionStamp::new(self.start_stamp, end_time),
|
||||
end_time: HighResolutionStamp::new(self.start_stamp, end_time),
|
||||
};
|
||||
self.stream.write_json_packet(&reply)?;
|
||||
|
||||
|
@ -330,25 +332,25 @@ impl Emitter {
|
|||
let mut lock = self.registry.lock();
|
||||
let registry = lock.as_mut().unwrap();
|
||||
let framerate_actor = registry.find_mut::<FramerateActor>(actor_name);
|
||||
let framerateReply = FramerateEmitterReply {
|
||||
let framerate_reply = FramerateEmitterReply {
|
||||
type_: "framerate".to_owned(),
|
||||
from: framerate_actor.name(),
|
||||
delta: HighResolutionStamp::new(self.start_stamp, end_time),
|
||||
timestamps: framerate_actor.take_pending_ticks(),
|
||||
};
|
||||
self.stream.write_json_packet(&framerateReply)?;
|
||||
self.stream.write_json_packet(&framerate_reply)?;
|
||||
}
|
||||
|
||||
if let Some(ref actor_name) = self.memory_actor {
|
||||
let registry = self.registry.lock().unwrap();
|
||||
let memory_actor = registry.find::<MemoryActor>(actor_name);
|
||||
let memoryReply = MemoryEmitterReply {
|
||||
let memory_reply = MemoryEmitterReply {
|
||||
type_: "memory".to_owned(),
|
||||
from: memory_actor.name(),
|
||||
delta: HighResolutionStamp::new(self.start_stamp, end_time),
|
||||
measurement: memory_actor.measure(),
|
||||
};
|
||||
self.stream.write_json_packet(&memoryReply)?;
|
||||
self.stream.write_json_packet(&memory_reply)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -41,12 +41,12 @@ impl WorkerActor {
|
|||
pub(crate) fn encodable(&self) -> WorkerMsg {
|
||||
WorkerMsg {
|
||||
actor: self.name.clone(),
|
||||
consoleActor: self.console.clone(),
|
||||
threadActor: self.thread.clone(),
|
||||
console_actor: self.console.clone(),
|
||||
thread_actor: self.thread.clone(),
|
||||
id: self.id.0.to_string(),
|
||||
url: self.url.to_string(),
|
||||
traits: WorkerTraits {
|
||||
isParentInterceptEnabled: false,
|
||||
is_parent_intercept_enabled: false,
|
||||
},
|
||||
type_: self.type_ as u32,
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ impl Actor for WorkerActor {
|
|||
let msg = ConnectReply {
|
||||
from: self.name(),
|
||||
type_: "connected".to_owned(),
|
||||
threadActor: self.thread.clone(),
|
||||
consoleActor: self.console.clone(),
|
||||
thread_actor: self.thread.clone(),
|
||||
console_actor: self.console.clone(),
|
||||
};
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
ActorMessageStatus::Processed
|
||||
|
@ -136,24 +136,27 @@ struct AttachedReply {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ConnectReply {
|
||||
from: String,
|
||||
#[serde(rename = "type")]
|
||||
type_: String,
|
||||
threadActor: String,
|
||||
consoleActor: String,
|
||||
thread_actor: String,
|
||||
console_actor: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct WorkerTraits {
|
||||
isParentInterceptEnabled: bool,
|
||||
is_parent_intercept_enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct WorkerMsg {
|
||||
actor: String,
|
||||
consoleActor: String,
|
||||
threadActor: String,
|
||||
console_actor: String,
|
||||
thread_actor: String,
|
||||
id: String,
|
||||
url: String,
|
||||
traits: WorkerTraits,
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#![crate_name = "devtools"]
|
||||
#![crate_type = "rlib"]
|
||||
#![allow(non_snake_case)]
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
|
@ -81,24 +80,27 @@ enum UniqueId {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct NetworkEventMsg {
|
||||
from: String,
|
||||
#[serde(rename = "type")]
|
||||
type_: String,
|
||||
eventActor: EventActor,
|
||||
event_actor: EventActor,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct NetworkEventUpdateMsg {
|
||||
from: String,
|
||||
#[serde(rename = "type")]
|
||||
type_: String,
|
||||
updateType: String,
|
||||
update_type: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct EventTimingsUpdateMsg {
|
||||
totalTime: u64,
|
||||
total_time: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -107,11 +109,12 @@ struct SecurityInfoUpdateMsg {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ResponseStartUpdateMsg {
|
||||
from: String,
|
||||
#[serde(rename = "type")]
|
||||
type_: String,
|
||||
updateType: String,
|
||||
update_type: String,
|
||||
response: ResponseStartMsg,
|
||||
}
|
||||
|
||||
|
@ -463,7 +466,7 @@ fn run_server(
|
|||
let msg = NetworkEventMsg {
|
||||
from: console_actor_name,
|
||||
type_: "networkEvent".to_owned(),
|
||||
eventActor: actor.event_actor(),
|
||||
event_actor: actor.event_actor(),
|
||||
};
|
||||
for stream in &mut connections {
|
||||
let _ = stream.write_json_packet(&msg);
|
||||
|
@ -476,7 +479,7 @@ fn run_server(
|
|||
let msg = NetworkEventUpdateMsg {
|
||||
from: netevent_actor_name.clone(),
|
||||
type_: "networkEventUpdate".to_owned(),
|
||||
updateType: "requestHeaders".to_owned(),
|
||||
update_type: "requestHeaders".to_owned(),
|
||||
};
|
||||
for stream in &mut connections {
|
||||
let _ = stream.write_merged_json_packet(&msg, &actor.request_headers());
|
||||
|
@ -485,7 +488,7 @@ fn run_server(
|
|||
let msg = NetworkEventUpdateMsg {
|
||||
from: netevent_actor_name.clone(),
|
||||
type_: "networkEventUpdate".to_owned(),
|
||||
updateType: "requestCookies".to_owned(),
|
||||
update_type: "requestCookies".to_owned(),
|
||||
};
|
||||
for stream in &mut connections {
|
||||
let _ = stream.write_merged_json_packet(&msg, &actor.request_cookies());
|
||||
|
@ -495,7 +498,7 @@ fn run_server(
|
|||
let msg = ResponseStartUpdateMsg {
|
||||
from: netevent_actor_name.clone(),
|
||||
type_: "networkEventUpdate".to_owned(),
|
||||
updateType: "responseStart".to_owned(),
|
||||
update_type: "responseStart".to_owned(),
|
||||
response: actor.response_start(),
|
||||
};
|
||||
|
||||
|
@ -505,10 +508,10 @@ fn run_server(
|
|||
let msg = NetworkEventUpdateMsg {
|
||||
from: netevent_actor_name.clone(),
|
||||
type_: "networkEventUpdate".to_owned(),
|
||||
updateType: "eventTimings".to_owned(),
|
||||
update_type: "eventTimings".to_owned(),
|
||||
};
|
||||
let extra = EventTimingsUpdateMsg {
|
||||
totalTime: actor.total_time(),
|
||||
total_time: actor.total_time(),
|
||||
};
|
||||
for stream in &mut connections {
|
||||
let _ = stream.write_merged_json_packet(&msg, &extra);
|
||||
|
@ -517,7 +520,7 @@ fn run_server(
|
|||
let msg = NetworkEventUpdateMsg {
|
||||
from: netevent_actor_name.clone(),
|
||||
type_: "networkEventUpdate".to_owned(),
|
||||
updateType: "securityInfo".to_owned(),
|
||||
update_type: "securityInfo".to_owned(),
|
||||
};
|
||||
let extra = SecurityInfoUpdateMsg {
|
||||
state: "insecure".to_owned(),
|
||||
|
@ -529,7 +532,7 @@ fn run_server(
|
|||
let msg = NetworkEventUpdateMsg {
|
||||
from: netevent_actor_name.clone(),
|
||||
type_: "networkEventUpdate".to_owned(),
|
||||
updateType: "responseContent".to_owned(),
|
||||
update_type: "responseContent".to_owned(),
|
||||
};
|
||||
for stream in &mut connections {
|
||||
let _ = stream.write_merged_json_packet(&msg, &actor.response_content());
|
||||
|
@ -538,7 +541,7 @@ fn run_server(
|
|||
let msg = NetworkEventUpdateMsg {
|
||||
from: netevent_actor_name.clone(),
|
||||
type_: "networkEventUpdate".to_owned(),
|
||||
updateType: "responseCookies".to_owned(),
|
||||
update_type: "responseCookies".to_owned(),
|
||||
};
|
||||
for stream in &mut connections {
|
||||
let _ = stream.write_merged_json_packet(&msg, &actor.response_cookies());
|
||||
|
@ -547,7 +550,7 @@ fn run_server(
|
|||
let msg = NetworkEventUpdateMsg {
|
||||
from: netevent_actor_name,
|
||||
type_: "networkEventUpdate".to_owned(),
|
||||
updateType: "responseHeaders".to_owned(),
|
||||
update_type: "responseHeaders".to_owned(),
|
||||
};
|
||||
for stream in &mut connections {
|
||||
let _ = stream.write_merged_json_packet(&msg, &actor.response_headers());
|
||||
|
@ -674,10 +677,10 @@ fn run_server(
|
|||
)) => {
|
||||
let console_message = ConsoleMessage {
|
||||
message: css_error.msg,
|
||||
logLevel: LogLevel::Warn,
|
||||
log_level: LogLevel::Warn,
|
||||
filename: css_error.filename,
|
||||
lineNumber: css_error.line as usize,
|
||||
columnNumber: css_error.column as usize,
|
||||
line_number: css_error.line as usize,
|
||||
column_number: css_error.column as usize,
|
||||
};
|
||||
handle_console_message(
|
||||
actors.clone(),
|
||||
|
|
|
@ -14,9 +14,10 @@ use serde::Serialize;
|
|||
use serde_json::{self, Value};
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ActorDescription {
|
||||
pub category: &'static str,
|
||||
pub typeName: &'static str,
|
||||
pub type_name: &'static str,
|
||||
pub methods: Vec<Method>,
|
||||
}
|
||||
|
||||
|
|
|
@ -364,8 +364,8 @@ fn prepare_devtools_request(
|
|||
headers,
|
||||
body,
|
||||
pipeline_id,
|
||||
startedDateTime: now,
|
||||
timeStamp: now.duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() as i64,
|
||||
started_date_time: now,
|
||||
time_stamp: now.duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() as i64,
|
||||
connect_time,
|
||||
send_time,
|
||||
is_xhr,
|
||||
|
|
|
@ -1370,8 +1370,8 @@ fn test_fetch_with_devtools() {
|
|||
headers: headers,
|
||||
body: Some(vec![]),
|
||||
pipeline_id: TEST_PIPELINE_ID,
|
||||
startedDateTime: devhttprequest.startedDateTime,
|
||||
timeStamp: devhttprequest.timeStamp,
|
||||
started_date_time: devhttprequest.started_date_time,
|
||||
time_stamp: devhttprequest.time_stamp,
|
||||
connect_time: devhttprequest.connect_time,
|
||||
send_time: devhttprequest.send_time,
|
||||
is_xhr: true,
|
||||
|
|
|
@ -289,8 +289,8 @@ fn test_request_and_response_data_with_network_messages() {
|
|||
headers: headers,
|
||||
body: Some(vec![]),
|
||||
pipeline_id: TEST_PIPELINE_ID,
|
||||
startedDateTime: devhttprequest.startedDateTime,
|
||||
timeStamp: devhttprequest.timeStamp,
|
||||
started_date_time: devhttprequest.started_date_time,
|
||||
time_stamp: devhttprequest.time_stamp,
|
||||
connect_time: devhttprequest.connect_time,
|
||||
send_time: devhttprequest.send_time,
|
||||
is_xhr: false,
|
||||
|
|
|
@ -160,21 +160,21 @@ pub fn handle_get_layout(
|
|||
.send(Some(ComputedNodeLayout {
|
||||
display: String::from(computed_style.Display()),
|
||||
position: String::from(computed_style.Position()),
|
||||
zIndex: String::from(computed_style.ZIndex()),
|
||||
boxSizing: String::from(computed_style.BoxSizing()),
|
||||
autoMargins: determine_auto_margins(&node),
|
||||
marginTop: String::from(computed_style.MarginTop()),
|
||||
marginRight: String::from(computed_style.MarginRight()),
|
||||
marginBottom: String::from(computed_style.MarginBottom()),
|
||||
marginLeft: String::from(computed_style.MarginLeft()),
|
||||
borderTopWidth: String::from(computed_style.BorderTopWidth()),
|
||||
borderRightWidth: String::from(computed_style.BorderRightWidth()),
|
||||
borderBottomWidth: String::from(computed_style.BorderBottomWidth()),
|
||||
borderLeftWidth: String::from(computed_style.BorderLeftWidth()),
|
||||
paddingTop: String::from(computed_style.PaddingTop()),
|
||||
paddingRight: String::from(computed_style.PaddingRight()),
|
||||
paddingBottom: String::from(computed_style.PaddingBottom()),
|
||||
paddingLeft: String::from(computed_style.PaddingLeft()),
|
||||
z_index: String::from(computed_style.ZIndex()),
|
||||
box_sizing: String::from(computed_style.BoxSizing()),
|
||||
auto_margins: determine_auto_margins(&node),
|
||||
margin_top: String::from(computed_style.MarginTop()),
|
||||
margin_right: String::from(computed_style.MarginRight()),
|
||||
margin_bottom: String::from(computed_style.MarginBottom()),
|
||||
margin_left: String::from(computed_style.MarginLeft()),
|
||||
border_top_width: String::from(computed_style.BorderTopWidth()),
|
||||
border_right_width: String::from(computed_style.BorderRightWidth()),
|
||||
border_bottom_width: String::from(computed_style.BorderBottomWidth()),
|
||||
border_left_width: String::from(computed_style.BorderLeftWidth()),
|
||||
padding_top: String::from(computed_style.PaddingTop()),
|
||||
padding_right: String::from(computed_style.PaddingRight()),
|
||||
padding_bottom: String::from(computed_style.PaddingBottom()),
|
||||
padding_left: String::from(computed_style.PaddingLeft()),
|
||||
width,
|
||||
height,
|
||||
}))
|
||||
|
@ -213,14 +213,14 @@ pub fn handle_modify_attribute(
|
|||
.expect("should be getting layout of element");
|
||||
|
||||
for modification in modifications {
|
||||
match modification.newValue {
|
||||
match modification.new_value {
|
||||
Some(string) => {
|
||||
let _ = elem.SetAttribute(
|
||||
DOMString::from(modification.attributeName),
|
||||
DOMString::from(modification.attribute_name),
|
||||
DOMString::from(string),
|
||||
);
|
||||
},
|
||||
None => elem.RemoveAttribute(DOMString::from(modification.attributeName)),
|
||||
None => elem.RemoveAttribute(DOMString::from(modification.attribute_name)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,10 +37,10 @@ impl Console {
|
|||
unsafe { describe_scripted_caller(*GlobalScope::get_cx()) }.unwrap_or_default();
|
||||
let console_message = ConsoleMessage {
|
||||
message,
|
||||
logLevel: level,
|
||||
log_level: level,
|
||||
filename: caller.filename,
|
||||
lineNumber: caller.line as usize,
|
||||
columnNumber: caller.col as usize,
|
||||
line_number: caller.line as usize,
|
||||
column_number: caller.col as usize,
|
||||
};
|
||||
let worker_id = global
|
||||
.downcast::<WorkerGlobalScope>()
|
||||
|
|
|
@ -2299,13 +2299,13 @@ impl GlobalScope {
|
|||
self.pipeline_id,
|
||||
PageError {
|
||||
type_: "PageError".to_string(),
|
||||
errorMessage: warning.to_string(),
|
||||
sourceName: self.get_url().to_string(),
|
||||
lineText: "".to_string(),
|
||||
lineNumber: 0,
|
||||
columnNumber: 0,
|
||||
error_message: warning.to_string(),
|
||||
source_name: self.get_url().to_string(),
|
||||
line_text: "".to_string(),
|
||||
line_number: 0,
|
||||
column_number: 0,
|
||||
category: "script".to_string(),
|
||||
timeStamp: 0, //TODO
|
||||
time_stamp: 0, //TODO
|
||||
error: false,
|
||||
warning: true,
|
||||
exception: true,
|
||||
|
@ -2487,13 +2487,13 @@ impl GlobalScope {
|
|||
self.pipeline_id,
|
||||
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,
|
||||
error_message: error_info.message.clone(),
|
||||
source_name: error_info.filename.clone(),
|
||||
line_text: "".to_string(), //TODO
|
||||
line_number: error_info.lineno,
|
||||
column_number: error_info.column,
|
||||
category: "script".to_string(),
|
||||
timeStamp: 0, //TODO
|
||||
time_stamp: 0, //TODO
|
||||
error: true,
|
||||
warning: false,
|
||||
exception: true,
|
||||
|
|
|
@ -1114,29 +1114,29 @@ impl Node {
|
|||
pub fn summarize(&self) -> NodeInfo {
|
||||
let USVString(base_uri) = self.BaseURI();
|
||||
NodeInfo {
|
||||
uniqueId: self.unique_id(),
|
||||
baseURI: base_uri,
|
||||
unique_id: self.unique_id(),
|
||||
base_uri,
|
||||
parent: self
|
||||
.GetParentNode()
|
||||
.map_or("".to_owned(), |node| node.unique_id()),
|
||||
nodeType: self.NodeType(),
|
||||
namespaceURI: String::new(), //FIXME
|
||||
nodeName: String::from(self.NodeName()),
|
||||
numChildren: self.ChildNodes().Length() as usize,
|
||||
node_type: self.NodeType(),
|
||||
namespace_uri: String::new(), //FIXME
|
||||
node_name: String::from(self.NodeName()),
|
||||
num_children: self.ChildNodes().Length() as usize,
|
||||
|
||||
//FIXME doctype nodes only
|
||||
name: String::new(),
|
||||
publicId: String::new(),
|
||||
systemId: String::new(),
|
||||
public_id: String::new(),
|
||||
system_id: String::new(),
|
||||
attrs: self.downcast().map(Element::summarize).unwrap_or(vec![]),
|
||||
|
||||
isDocumentElement: self
|
||||
is_document_element: self
|
||||
.owner_doc()
|
||||
.GetDocumentElement()
|
||||
.map_or(false, |elem| elem.upcast::<Node>() == self),
|
||||
|
||||
shortValue: self.GetNodeValue().map(String::from).unwrap_or_default(), //FIXME: truncate
|
||||
incompleteValue: false, //FIXME: reflect truncation
|
||||
short_value: self.GetNodeValue().map(String::from).unwrap_or_default(), //FIXME: truncate
|
||||
incomplete_value: false, //FIXME: reflect truncation
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#![crate_name = "devtools_traits"]
|
||||
#![crate_type = "rlib"]
|
||||
#![allow(non_snake_case)]
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
use std::net::TcpStream;
|
||||
|
@ -118,25 +117,24 @@ pub struct AttrInfo {
|
|||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct NodeInfo {
|
||||
pub uniqueId: String,
|
||||
pub baseURI: String,
|
||||
pub unique_id: String,
|
||||
#[serde(rename = "baseURI")]
|
||||
pub base_uri: String,
|
||||
pub parent: String,
|
||||
pub nodeType: u16,
|
||||
pub namespaceURI: String,
|
||||
pub nodeName: String,
|
||||
pub numChildren: usize,
|
||||
|
||||
pub node_type: u16,
|
||||
#[serde(rename = "namespaceURI")]
|
||||
pub namespace_uri: String,
|
||||
pub node_name: String,
|
||||
pub num_children: usize,
|
||||
pub name: String,
|
||||
pub publicId: String,
|
||||
pub systemId: String,
|
||||
|
||||
pub public_id: String,
|
||||
pub system_id: String,
|
||||
pub attrs: Vec<AttrInfo>,
|
||||
|
||||
pub isDocumentElement: bool,
|
||||
|
||||
pub shortValue: String,
|
||||
pub incompleteValue: bool,
|
||||
pub is_document_element: bool,
|
||||
pub short_value: String,
|
||||
pub incomplete_value: bool,
|
||||
}
|
||||
|
||||
pub struct StartedTimelineMarker {
|
||||
|
@ -162,27 +160,28 @@ pub enum TimelineMarkerType {
|
|||
|
||||
/// The properties of a DOM node as computed by layout.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ComputedNodeLayout {
|
||||
pub display: String,
|
||||
pub position: String,
|
||||
pub zIndex: String,
|
||||
pub boxSizing: String,
|
||||
pub z_index: String,
|
||||
pub box_sizing: String,
|
||||
|
||||
pub autoMargins: AutoMargins,
|
||||
pub marginTop: String,
|
||||
pub marginRight: String,
|
||||
pub marginBottom: String,
|
||||
pub marginLeft: String,
|
||||
pub auto_margins: AutoMargins,
|
||||
pub margin_top: String,
|
||||
pub margin_right: String,
|
||||
pub margin_bottom: String,
|
||||
pub margin_left: String,
|
||||
|
||||
pub borderTopWidth: String,
|
||||
pub borderRightWidth: String,
|
||||
pub borderBottomWidth: String,
|
||||
pub borderLeftWidth: String,
|
||||
pub border_top_width: String,
|
||||
pub border_right_width: String,
|
||||
pub border_bottom_width: String,
|
||||
pub border_left_width: String,
|
||||
|
||||
pub paddingTop: String,
|
||||
pub paddingRight: String,
|
||||
pub paddingBottom: String,
|
||||
pub paddingLeft: String,
|
||||
pub padding_top: String,
|
||||
pub padding_right: String,
|
||||
pub padding_bottom: String,
|
||||
pub padding_left: String,
|
||||
|
||||
pub width: f32,
|
||||
pub height: f32,
|
||||
|
@ -230,9 +229,10 @@ pub enum DevtoolScriptControlMsg {
|
|||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Modification {
|
||||
pub attributeName: String,
|
||||
pub newValue: Option<String>,
|
||||
pub attribute_name: String,
|
||||
pub new_value: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
|
@ -246,12 +246,13 @@ pub enum LogLevel {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ConsoleMessage {
|
||||
pub message: String,
|
||||
pub logLevel: LogLevel,
|
||||
pub log_level: LogLevel,
|
||||
pub filename: String,
|
||||
pub lineNumber: usize,
|
||||
pub columnNumber: usize,
|
||||
pub line_number: usize,
|
||||
pub column_number: usize,
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
|
@ -263,16 +264,17 @@ bitflags! {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PageError {
|
||||
#[serde(rename = "_type")]
|
||||
pub type_: String,
|
||||
pub errorMessage: String,
|
||||
pub sourceName: String,
|
||||
pub lineText: String,
|
||||
pub lineNumber: u32,
|
||||
pub columnNumber: u32,
|
||||
pub error_message: String,
|
||||
pub source_name: String,
|
||||
pub line_text: String,
|
||||
pub line_number: u32,
|
||||
pub column_number: u32,
|
||||
pub category: String,
|
||||
pub timeStamp: u64,
|
||||
pub time_stamp: u64,
|
||||
pub error: bool,
|
||||
pub warning: bool,
|
||||
pub exception: bool,
|
||||
|
@ -286,9 +288,9 @@ pub struct ConsoleAPI {
|
|||
pub type_: String,
|
||||
pub level: String,
|
||||
pub filename: String,
|
||||
pub lineNumber: u32,
|
||||
pub functionName: String,
|
||||
pub timeStamp: u64,
|
||||
pub line_number: u32,
|
||||
pub function_name: String,
|
||||
pub time_stamp: u64,
|
||||
pub private: bool,
|
||||
pub arguments: Vec<String>,
|
||||
}
|
||||
|
@ -306,8 +308,8 @@ pub struct HttpRequest {
|
|||
pub headers: HeaderMap,
|
||||
pub body: Option<Vec<u8>>,
|
||||
pub pipeline_id: PipelineId,
|
||||
pub startedDateTime: SystemTime,
|
||||
pub timeStamp: i64,
|
||||
pub started_date_time: SystemTime,
|
||||
pub time_stamp: i64,
|
||||
pub connect_time: u64,
|
||||
pub send_time: u64,
|
||||
pub is_xhr: bool,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue