mirror of
https://github.com/servo/servo
synced 2026-05-11 17:37:21 +02:00
Add an event listener for `pause` to `debugger.js` and the necessary glue to access it from the `devtools` crate. This returns important information to know where we are paused, such as the source location and frame state. Fix frame and object actor encoding into messages. Use information from `debugger.js` to correctly fill the fields. Add a new `frames` list to the thread actor and handle the `frames` message. Fix `getEnvironment` reply in the frame actor. It is out of form (has a `type` field but it doesn't require a followup empty message, it already counts as a reply), so we need to handle it specially. Note: For now we are focusing on the protocol side of the debugger, and this patch only shows where the pause would happen. Pausing Servo itself will happen in a followup.  Testing: `mach test-devtools` and manual testing. No errors (apart from #42006). Part of: #36027 --------- Signed-off-by: eri <eri@igalia.com> Co-authored-by: atbrakhi <atbrakhi@igalia.com> Co-authored-by: Josh Matthews <josh@joshmatthews.net>
91 lines
2.4 KiB
Rust
91 lines
2.4 KiB
Rust
/* 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 serde::Serialize;
|
|
|
|
use crate::actor::{Actor, ActorEncode, ActorRegistry};
|
|
|
|
#[derive(Serialize)]
|
|
pub(crate) struct ObjectPreview {
|
|
kind: String,
|
|
url: String,
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub(crate) struct ObjectActorMsg {
|
|
actor: String,
|
|
#[serde(rename = "type")]
|
|
type_: String,
|
|
class: String,
|
|
own_property_length: i32,
|
|
extensible: bool,
|
|
frozen: bool,
|
|
sealed: bool,
|
|
is_error: bool,
|
|
preview: ObjectPreview,
|
|
}
|
|
|
|
pub(crate) struct ObjectActor {
|
|
name: String,
|
|
_uuid: Option<String>,
|
|
}
|
|
|
|
impl Actor for ObjectActor {
|
|
fn name(&self) -> String {
|
|
self.name.clone()
|
|
}
|
|
|
|
// TODO: Handle messages
|
|
// https://searchfox.org/firefox-main/source/devtools/shared/specs/object.js
|
|
}
|
|
|
|
impl ObjectActor {
|
|
pub fn register(registry: &ActorRegistry, uuid: Option<String>) -> String {
|
|
let Some(uuid) = uuid else {
|
|
let name = registry.new_name::<Self>();
|
|
let actor = ObjectActor {
|
|
name: name.clone(),
|
|
_uuid: None,
|
|
};
|
|
registry.register(actor);
|
|
return name;
|
|
};
|
|
if !registry.script_actor_registered(uuid.clone()) {
|
|
let name = registry.new_name::<Self>();
|
|
let actor = ObjectActor {
|
|
name: name.clone(),
|
|
_uuid: Some(uuid.clone()),
|
|
};
|
|
|
|
registry.register_script_actor(uuid, name.clone());
|
|
registry.register(actor);
|
|
|
|
name
|
|
} else {
|
|
registry.script_to_actor(uuid)
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ActorEncode<ObjectActorMsg> for ObjectActor {
|
|
fn encode(&self, _: &ActorRegistry) -> ObjectActorMsg {
|
|
// TODO: Review hardcoded values here
|
|
ObjectActorMsg {
|
|
actor: self.name(),
|
|
type_: "object".into(),
|
|
class: "Window".into(),
|
|
own_property_length: 0,
|
|
extensible: true,
|
|
frozen: false,
|
|
sealed: false,
|
|
is_error: false,
|
|
preview: ObjectPreview {
|
|
kind: "ObjectWithURL".into(),
|
|
url: "".into(), // TODO: Use the correct url
|
|
},
|
|
}
|
|
}
|
|
}
|