Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update devtools server for Firefox 71. #25288

Merged
merged 1 commit into from Dec 14, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -15,7 +15,18 @@ use serde_json::{Map, Value};
use std::net::TcpStream;

#[derive(Serialize)]
struct BrowsingContextTraits;
struct BrowsingContextTraits {
isBrowsingContext: bool,
}

#[derive(Serialize)]
struct AttachedTraits {
reconfigure: bool,
frames: bool,
logInPage: bool,
canRewind: bool,
watchpoints: bool,
}

#[derive(Serialize)]
struct BrowsingContextAttachedReply {
@@ -25,7 +36,7 @@ struct BrowsingContextAttachedReply {
threadActor: String,
cacheDisabled: bool,
javascriptEnabled: bool,
traits: BrowsingContextTraits,
traits: AttachedTraits,
}

#[derive(Serialize)]
@@ -71,13 +82,28 @@ pub struct BrowsingContextActorMsg {
title: String,
url: String,
outerWindowID: u32,
browsingContextId: u32,
consoleActor: String,
emulationActor: String,
inspectorActor: String,
timelineActor: String,
profilerActor: String,
performanceActor: String,
styleSheetsActor: String,
traits: BrowsingContextTraits,
// Part of the official protocol, but not yet implemented.
/*storageActor: String,
memoryActor: String,
framerateActor: String,
reflowActor: String,
cssPropertiesActor: String,
animationsActor: String,
webExtensionInspectedWindowActor: String,
accessibilityActor: String,
screenshotActor: String,
changesActor: String,
webSocketActor: String,
manifestActor: String,*/
}

pub struct BrowsingContextActor {
@@ -127,11 +153,17 @@ impl Actor for BrowsingContextActor {
"attach" => {
let msg = BrowsingContextAttachedReply {
from: self.name(),
type_: "targetAttached".to_owned(),
type_: "tabAttached".to_owned(),
threadActor: self.thread.clone(),
cacheDisabled: false,
javascriptEnabled: true,
traits: BrowsingContextTraits,
traits: AttachedTraits {
reconfigure: false,
frames: false,
logInPage: false,
canRewind: false,
watchpoints: false,
},
};
let console_actor = registry.find::<ConsoleActor>(&self.console);
console_actor
@@ -166,7 +198,12 @@ impl Actor for BrowsingContextActor {
"listFrames" => {
let msg = ListFramesReply {
from: self.name(),
frames: vec![],
frames: vec![FrameMsg {
id: 0, //FIXME should match outerwindow id
parentID: 0,
url: self.url.clone(),
title: self.title.clone(),
}],
};
stream.write_json_packet(&msg);
ActorMessageStatus::Processed
@@ -190,9 +227,13 @@ impl BrowsingContextActor {
pub fn encodable(&self) -> BrowsingContextActorMsg {
BrowsingContextActorMsg {
actor: self.name(),
traits: BrowsingContextTraits {
isBrowsingContext: true,
},
title: self.title.clone(),
url: self.url.clone(),
outerWindowID: 0, //FIXME: this should probably be the pipeline id
browsingContextId: 0, //FIXME should come from constellation
outerWindowID: 0, //FIXME: this should probably be the pipeline id
consoleActor: self.console.clone(),
emulationActor: self.emulation.clone(),
inspectorActor: self.inspector.clone(),
@@ -39,9 +39,7 @@ impl EncodableConsoleMessage for CachedConsoleMessage {
}

#[derive(Serialize)]
struct StartedListenersTraits {
customNetworkRequest: bool,
}
struct StartedListenersTraits;

#[derive(Serialize)]
struct StartedListenersReply {
@@ -309,13 +307,15 @@ impl Actor for ConsoleActor {

"startListeners" => {
//TODO: actually implement listener filters that support starting/stopping
let listeners = msg.get("listeners").unwrap().as_array().unwrap().to_owned();
let msg = StartedListenersReply {
from: self.name(),
nativeConsoleAPI: true,
startedListeners: vec!["PageError".to_owned(), "ConsoleAPI".to_owned()],
traits: StartedListenersTraits {
customNetworkRequest: true,
},
startedListeners: listeners
.into_iter()
.map(|s| s.as_str().unwrap().to_owned())
.collect(),
traits: StartedListenersTraits,
};
stream.write_json_packet(&msg);
ActorMessageStatus::Processed
@@ -41,7 +41,7 @@ impl Actor for DeviceActor {
from: self.name(),
value: SystemInfo {
apptype: "servo".to_string(),
platformVersion: "63.0".to_string(),
platformVersion: "71.0".to_string(),
},
};
stream.write_json_packet(&msg);
@@ -0,0 +1,81 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::actor::{Actor, ActorMessageStatus, ActorRegistry};
use crate::protocol::JsonPacketStream;
use serde_json::{Map, Value};
use std::net::TcpStream;

pub struct PreferenceActor {
name: String,
}

impl PreferenceActor {
pub fn new(name: String) -> Self {
Self { name }
}
}

impl Actor for PreferenceActor {
fn name(&self) -> String {
self.name.clone()
}

fn handle_message(
&self,
_registry: &ActorRegistry,
msg_type: &str,
_msg: &Map<String, Value>,
stream: &mut TcpStream,
) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"getBoolPref" => {
let reply = BoolReply {
from: self.name(),
value: false,
};
stream.write_json_packet(&reply);
ActorMessageStatus::Processed
},

"getCharPref" => {
let reply = CharReply {
from: self.name(),
value: "".to_owned(),
};
stream.write_json_packet(&reply);
ActorMessageStatus::Processed
},

"getIntPref" => {
let reply = IntReply {
from: self.name(),
value: 0,
};
stream.write_json_packet(&reply);
ActorMessageStatus::Processed
},

_ => ActorMessageStatus::Ignored,
})
}
}

#[derive(Serialize)]
struct BoolReply {
from: String,
value: bool,
}

#[derive(Serialize)]
struct CharReply {
from: String,
value: String,
}

#[derive(Serialize)]
struct IntReply {
from: String,
value: i32,
}
@@ -0,0 +1,51 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::actor::{Actor, ActorMessageStatus, ActorRegistry};
use crate::protocol::JsonPacketStream;
use serde_json::{Map, Value};
use std::net::TcpStream;

#[derive(Serialize)]
struct ListWorkersReply {
from: String,
workers: Vec<u32>, // TODO: use proper JSON structure.
}

pub struct ProcessActor {
name: String,
}

impl ProcessActor {
pub fn new(name: String) -> Self {
Self { name }
}
}

impl Actor for ProcessActor {
fn name(&self) -> String {
self.name.clone()
}

fn handle_message(
&self,
_registry: &ActorRegistry,
msg_type: &str,
_msg: &Map<String, Value>,
stream: &mut TcpStream,
) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"listWorkers" => {
let reply = ListWorkersReply {
from: self.name(),
workers: vec![],
};
stream.write_json_packet(&reply);
ActorMessageStatus::Processed
},

_ => ActorMessageStatus::Ignored,
})
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.