mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
DevTools: Fix console in Firefox 131 (#33661)
* feat: remove deprecated resource-available-form Signed-off-by: eri <epazos@igalia.com> * chore: update targeted firefox version Signed-off-by: eri <epazos@igalia.com> --------- Signed-off-by: eri <epazos@igalia.com>
This commit is contained in:
parent
a6da1daa12
commit
af61b1a107
4 changed files with 48 additions and 98 deletions
|
@ -9,11 +9,10 @@
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
|
||||||
|
|
||||||
use base::id::{BrowsingContextId, PipelineId};
|
use base::id::{BrowsingContextId, PipelineId};
|
||||||
use devtools_traits::DevtoolScriptControlMsg::{self, GetCssDatabase, WantsLiveNotifications};
|
use devtools_traits::DevtoolScriptControlMsg::{self, GetCssDatabase, WantsLiveNotifications};
|
||||||
use devtools_traits::{ConsoleLog, DevtoolsPageInfo, NavigationState, PageError};
|
use devtools_traits::{DevtoolsPageInfo, NavigationState};
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::{Map, Value};
|
use serde_json::{Map, Value};
|
||||||
|
@ -48,55 +47,11 @@ struct FrameUpdateMsg {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct ResourceAvailableReply {
|
struct ResourceAvailableReply<T: Serialize> {
|
||||||
from: String,
|
from: String,
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
type_: String,
|
type_: String,
|
||||||
resources: Vec<ResourceAvailableMsg>,
|
array: Vec<(String, Vec<T>)>,
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
struct ResourceAvailableMsg {
|
|
||||||
#[serde(rename = "hasNativeConsoleAPI")]
|
|
||||||
has_native_console_api: Option<bool>,
|
|
||||||
name: String,
|
|
||||||
#[serde(rename = "newURI")]
|
|
||||||
new_uri: Option<String>,
|
|
||||||
resource_type: String,
|
|
||||||
time: u64,
|
|
||||||
title: Option<String>,
|
|
||||||
url: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
struct ConsoleMsg {
|
|
||||||
from: String,
|
|
||||||
#[serde(rename = "type")]
|
|
||||||
type_: String,
|
|
||||||
resources: Vec<ConsoleMessageResource>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
struct ConsoleMessageResource {
|
|
||||||
message: ConsoleLog,
|
|
||||||
resource_type: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
struct PageErrorMsg {
|
|
||||||
from: String,
|
|
||||||
#[serde(rename = "type")]
|
|
||||||
type_: String,
|
|
||||||
resources: Vec<PageErrorResource>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
struct PageErrorResource {
|
|
||||||
page_error: PageError,
|
|
||||||
resource_type: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
@ -369,52 +324,11 @@ impl BrowsingContextActor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn document_event(&self, stream: &mut TcpStream) {
|
pub(crate) fn resource_available<T: Serialize>(&self, message: T, resource_type: String) {
|
||||||
// TODO: This is a hacky way of sending the 3 messages
|
let msg = ResourceAvailableReply::<T> {
|
||||||
// Figure out if there needs work to be done here, ensure the page is loaded
|
|
||||||
for &name in ["dom-loading", "dom-interactive", "dom-complete"].iter() {
|
|
||||||
let _ = stream.write_json_packet(&ResourceAvailableReply {
|
|
||||||
from: self.name(),
|
|
||||||
type_: "resource-available-form".into(),
|
|
||||||
resources: vec![ResourceAvailableMsg {
|
|
||||||
has_native_console_api: Some(true),
|
|
||||||
name: name.into(),
|
|
||||||
new_uri: None,
|
|
||||||
resource_type: "document-event".into(),
|
|
||||||
time: SystemTime::now()
|
|
||||||
.duration_since(UNIX_EPOCH)
|
|
||||||
.unwrap_or_default()
|
|
||||||
.as_millis() as u64,
|
|
||||||
title: Some(self.title.borrow().clone()),
|
|
||||||
url: Some(self.url.borrow().clone()),
|
|
||||||
}],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn console_message(&self, message: ConsoleLog) {
|
|
||||||
let msg = ConsoleMsg {
|
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
type_: "resource-available-form".into(),
|
type_: "resources-available-array".into(),
|
||||||
resources: vec![ConsoleMessageResource {
|
array: vec![(resource_type, vec![message])],
|
||||||
message,
|
|
||||||
resource_type: "console-message".into(),
|
|
||||||
}],
|
|
||||||
};
|
|
||||||
|
|
||||||
for stream in self.streams.borrow_mut().values_mut() {
|
|
||||||
let _ = stream.write_json_packet(&msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn page_error(&self, page_error: PageError) {
|
|
||||||
let msg = PageErrorMsg {
|
|
||||||
from: self.name(),
|
|
||||||
type_: "resource-available-form".into(),
|
|
||||||
resources: vec![PageErrorResource {
|
|
||||||
page_error,
|
|
||||||
resource_type: "error-message".into(),
|
|
||||||
}],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for stream in self.streams.borrow_mut().values_mut() {
|
for stream in self.streams.borrow_mut().values_mut() {
|
||||||
|
|
|
@ -119,6 +119,12 @@ struct SetPreferencesReply {
|
||||||
updated: Vec<String>,
|
updated: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
struct PageErrorWrapper {
|
||||||
|
page_error: PageError,
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) enum Root {
|
pub(crate) enum Root {
|
||||||
BrowsingContext(String),
|
BrowsingContext(String),
|
||||||
DedicatedWorker(String),
|
DedicatedWorker(String),
|
||||||
|
@ -255,7 +261,7 @@ impl ConsoleActor {
|
||||||
if let Root::BrowsingContext(bc) = &self.root {
|
if let Root::BrowsingContext(bc) = &self.root {
|
||||||
registry
|
registry
|
||||||
.find::<BrowsingContextActor>(bc)
|
.find::<BrowsingContextActor>(bc)
|
||||||
.page_error(page_error)
|
.resource_available(PageErrorWrapper { page_error }, "error-message".into())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,7 +303,7 @@ impl ConsoleActor {
|
||||||
if let Root::BrowsingContext(bc) = &self.root {
|
if let Root::BrowsingContext(bc) = &self.root {
|
||||||
registry
|
registry
|
||||||
.find::<BrowsingContextActor>(bc)
|
.find::<BrowsingContextActor>(bc)
|
||||||
.console_message(console_api)
|
.resource_available(console_api, "console-message".into())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ impl Actor for DeviceActor {
|
||||||
apptype: "servo".to_string(),
|
apptype: "servo".to_string(),
|
||||||
version: env!("CARGO_PKG_VERSION").to_string(),
|
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||||
appbuildid: BUILD_ID.to_string(),
|
appbuildid: BUILD_ID.to_string(),
|
||||||
platformversion: "125.0".to_string(),
|
platformversion: "130.0".to_string(),
|
||||||
brand_name: "Servo".to_string(),
|
brand_name: "Servo".to_string(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
@ -132,6 +133,19 @@ struct GetThreadConfigurationActorReply {
|
||||||
configuration: ThreadConfigurationActorMsg,
|
configuration: ThreadConfigurationActorMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
struct DocumentEvent {
|
||||||
|
#[serde(rename = "hasNativeConsoleAPI")]
|
||||||
|
has_native_console_api: Option<bool>,
|
||||||
|
name: String,
|
||||||
|
#[serde(rename = "newURI")]
|
||||||
|
new_uri: Option<String>,
|
||||||
|
time: u64,
|
||||||
|
title: Option<String>,
|
||||||
|
url: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct WatcherTraits {
|
struct WatcherTraits {
|
||||||
resources: HashMap<&'static str, bool>,
|
resources: HashMap<&'static str, bool>,
|
||||||
|
@ -166,7 +180,7 @@ impl Actor for WatcherActor {
|
||||||
/// `target-available-form` event.
|
/// `target-available-form` event.
|
||||||
///
|
///
|
||||||
/// - `watchResources`: Start watching certain resource types. This sends
|
/// - `watchResources`: Start watching certain resource types. This sends
|
||||||
/// `resource-available-form` events.
|
/// `resources-available-array` events.
|
||||||
///
|
///
|
||||||
/// - `getNetworkParentActor`: Returns the network parent actor. It doesn't seem to do much at
|
/// - `getNetworkParentActor`: Returns the network parent actor. It doesn't seem to do much at
|
||||||
/// the moment.
|
/// the moment.
|
||||||
|
@ -217,7 +231,23 @@ impl Actor for WatcherActor {
|
||||||
};
|
};
|
||||||
match resource {
|
match resource {
|
||||||
"document-event" => {
|
"document-event" => {
|
||||||
target.document_event(stream);
|
// TODO: This is a hacky way of sending the 3 messages
|
||||||
|
// Figure out if there needs work to be done here, ensure the page is loaded
|
||||||
|
for &name in ["dom-loading", "dom-interactive", "dom-complete"].iter() {
|
||||||
|
let event = DocumentEvent {
|
||||||
|
has_native_console_api: Some(true),
|
||||||
|
name: name.into(),
|
||||||
|
new_uri: None,
|
||||||
|
time: SystemTime::now()
|
||||||
|
.duration_since(UNIX_EPOCH)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.as_millis()
|
||||||
|
as u64,
|
||||||
|
title: Some(target.title.borrow().clone()),
|
||||||
|
url: Some(target.url.borrow().clone()),
|
||||||
|
};
|
||||||
|
target.resource_available(event, "document-event".into());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"console-message" | "error-message" => {},
|
"console-message" | "error-message" => {},
|
||||||
_ => warn!("resource {} not handled yet", resource),
|
_ => warn!("resource {} not handled yet", resource),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue