diff options
author | eri <epazos@igalia.com> | 2024-10-09 13:09:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-09 12:09:06 +0000 |
commit | af61b1a1074037a36b803357fb03ea72ee01ae66 (patch) | |
tree | d47429416e4fd715016073320f6ed536931a50fb /components/devtools | |
parent | a6da1daa126705fcb7393d605e4844640e4fefe0 (diff) | |
download | servo-af61b1a1074037a36b803357fb03ea72ee01ae66.tar.gz servo-af61b1a1074037a36b803357fb03ea72ee01ae66.zip |
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>
Diffstat (limited to 'components/devtools')
-rw-r--r-- | components/devtools/actors/browsing_context.rs | 100 | ||||
-rw-r--r-- | components/devtools/actors/console.rs | 10 | ||||
-rw-r--r-- | components/devtools/actors/device.rs | 2 | ||||
-rw-r--r-- | components/devtools/actors/watcher.rs | 34 |
4 files changed, 48 insertions, 98 deletions
diff --git a/components/devtools/actors/browsing_context.rs b/components/devtools/actors/browsing_context.rs index 9a9173adb7b..3adf37aa4dc 100644 --- a/components/devtools/actors/browsing_context.rs +++ b/components/devtools/actors/browsing_context.rs @@ -9,11 +9,10 @@ use std::cell::{Cell, RefCell}; use std::collections::HashMap; use std::net::TcpStream; -use std::time::{SystemTime, UNIX_EPOCH}; use base::id::{BrowsingContextId, PipelineId}; 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 serde::Serialize; use serde_json::{Map, Value}; @@ -48,55 +47,11 @@ struct FrameUpdateMsg { } #[derive(Serialize)] -struct ResourceAvailableReply { +struct ResourceAvailableReply<T: Serialize> { from: String, #[serde(rename = "type")] type_: String, - resources: Vec<ResourceAvailableMsg>, -} - -#[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, + array: Vec<(String, Vec<T>)>, } #[derive(Serialize)] @@ -369,52 +324,11 @@ impl BrowsingContextActor { }); } - pub(crate) fn document_event(&self, stream: &mut TcpStream) { - // 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 _ = 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 { + pub(crate) fn resource_available<T: Serialize>(&self, message: T, resource_type: String) { + let msg = ResourceAvailableReply::<T> { from: self.name(), - type_: "resource-available-form".into(), - resources: vec![ConsoleMessageResource { - 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(), - }], + type_: "resources-available-array".into(), + array: vec![(resource_type, vec![message])], }; for stream in self.streams.borrow_mut().values_mut() { diff --git a/components/devtools/actors/console.rs b/components/devtools/actors/console.rs index 0a773c270d4..09666efc2f3 100644 --- a/components/devtools/actors/console.rs +++ b/components/devtools/actors/console.rs @@ -119,6 +119,12 @@ struct SetPreferencesReply { updated: Vec<String>, } +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +struct PageErrorWrapper { + page_error: PageError, +} + pub(crate) enum Root { BrowsingContext(String), DedicatedWorker(String), @@ -255,7 +261,7 @@ impl ConsoleActor { if let Root::BrowsingContext(bc) = &self.root { registry .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 { registry .find::<BrowsingContextActor>(bc) - .console_message(console_api) + .resource_available(console_api, "console-message".into()) }; } } diff --git a/components/devtools/actors/device.rs b/components/devtools/actors/device.rs index 9be322abd69..395825baedd 100644 --- a/components/devtools/actors/device.rs +++ b/components/devtools/actors/device.rs @@ -60,7 +60,7 @@ impl Actor for DeviceActor { apptype: "servo".to_string(), version: env!("CARGO_PKG_VERSION").to_string(), appbuildid: BUILD_ID.to_string(), - platformversion: "125.0".to_string(), + platformversion: "130.0".to_string(), brand_name: "Servo".to_string(), }, }; diff --git a/components/devtools/actors/watcher.rs b/components/devtools/actors/watcher.rs index 7454cc725f6..94a15b36e7a 100644 --- a/components/devtools/actors/watcher.rs +++ b/components/devtools/actors/watcher.rs @@ -12,6 +12,7 @@ use std::collections::HashMap; use std::net::TcpStream; +use std::time::{SystemTime, UNIX_EPOCH}; use log::warn; use serde::Serialize; @@ -133,6 +134,19 @@ struct GetThreadConfigurationActorReply { } #[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)] struct WatcherTraits { resources: HashMap<&'static str, bool>, #[serde(flatten)] @@ -166,7 +180,7 @@ impl Actor for WatcherActor { /// `target-available-form` event. /// /// - `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 /// the moment. @@ -217,7 +231,23 @@ impl Actor for WatcherActor { }; match resource { "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" => {}, _ => warn!("resource {} not handled yet", resource), |