devtools: Implement getBlackboxingActor (#44142)

Adds `BlackboxingActor` boilerplate and implements `getBlackboxingActor`

Testing: Added a geckordp test for `getBlackboxingActor`
Fixes: Part of https://github.com/servo/servo/issues/36027

Signed-off-by: Freya Arbjerg <git@arbjerg.dev>
This commit is contained in:
Freya Arbjerg
2026-04-12 17:34:13 +02:00
committed by GitHub
parent 1908220198
commit b427fea6f8
4 changed files with 60 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
/* 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 malloc_size_of_derive::MallocSizeOf;
use crate::ActorMsg;
use crate::actor::{Actor, ActorEncode, ActorRegistry};
#[derive(MallocSizeOf)]
pub(crate) struct BlackboxingActor {
name: String,
}
impl Actor for BlackboxingActor {
fn name(&self) -> String {
self.name.clone()
}
}
impl BlackboxingActor {
pub fn register(registry: &ActorRegistry) -> String {
let name = registry.new_name::<Self>();
let actor = Self { name: name.clone() };
registry.register::<Self>(actor);
name
}
}
impl ActorEncode<ActorMsg> for BlackboxingActor {
fn encode(&self, _: &ActorRegistry) -> ActorMsg {
ActorMsg { actor: self.name() }
}
}

View File

@@ -25,6 +25,7 @@ use super::breakpoint::BreakpointListActor;
use super::thread::ThreadActor;
use super::worker::WorkerTargetActorMsg;
use crate::actor::{Actor, ActorEncode, ActorError, ActorRegistry};
use crate::actors::blackboxing::BlackboxingActor;
use crate::actors::browsing_context::{BrowsingContextActor, BrowsingContextActorMsg};
use crate::actors::console::ConsoleActor;
use crate::actors::root::RootActor;
@@ -146,6 +147,13 @@ struct GetThreadConfigurationActorReply {
configuration: ActorMsg,
}
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct GetBlackboxingActorReply {
from: String,
blackboxing: ActorMsg,
}
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct GetBreakpointListActorReply {
@@ -187,6 +195,7 @@ pub(crate) struct WatcherActor {
target_configuration_name: String,
thread_configuration_name: String,
breakpoint_list_name: String,
blackboxing_name: String,
session_context: SessionContext,
}
@@ -426,6 +435,13 @@ impl Actor for WatcherActor {
};
request.reply_final(&msg)?
},
"getBlackboxingActor" => {
let msg = GetBlackboxingActorReply {
from: self.name(),
blackboxing: registry.encode::<BlackboxingActor, _>(&self.blackboxing_name),
};
request.reply_final(&msg)?
},
_ => return Err(ActorError::UnrecognizedPacketType),
};
Ok(())
@@ -449,6 +465,7 @@ impl WatcherActor {
let thread_configuration_name = ThreadConfigurationActor::register(registry);
let breakpoint_list_name =
BreakpointListActor::register(registry, browsing_context_name.clone());
let blackboxing_name = BlackboxingActor::register(registry);
let name = registry.new_name::<Self>();
let actor = Self {
@@ -458,6 +475,7 @@ impl WatcherActor {
target_configuration_name,
thread_configuration_name,
breakpoint_list_name,
blackboxing_name,
session_context,
};

View File

@@ -61,6 +61,7 @@ use crate::protocol::{DevtoolsConnection, JsonPacketStream};
mod actor;
/// <https://searchfox.org/mozilla-central/source/devtools/server/actors>
mod actors {
pub mod blackboxing;
pub mod breakpoint;
pub mod browsing_context;
pub mod console;

View File

@@ -234,6 +234,13 @@ class DevtoolsTests(unittest.IsolatedAsyncioTestCase):
response2 = devtools.watcher.get_breakpoint_list_actor()
self.assertEqual(response1["breakpointList"]["actor"], response2["breakpointList"]["actor"])
def test_watcher_returns_same_blackboxing_actor_every_time(self):
self.run_servoshell(url="data:text/html,")
with Devtools.connect() as devtools:
response1 = devtools.watcher.get_blackboxing_actor()
response2 = devtools.watcher.get_blackboxing_actor()
self.assertEqual(response1["blackboxing"]["actor"], response2["blackboxing"]["actor"])
def test_breakpoint_pause(self):
self.run_servoshell(url=f"{self.base_urls[0]}/debugger/loop.html")
with Devtools.connect() as devtools: