mirror of
https://github.com/servo/servo.git
synced 2025-08-15 02:15:33 +01:00
devtools: Fix getBreakpointListActor
handler in watcher actor (#38624)
the Firefox devtools client often sends multiple `getBreakpointListActor` requests to the watcher actor when connecting, and the Firefox devtools server returns the same breakpoint list actor every time, but Servo returns a new breakpoint list actor each time. this patch aligns Servo’s behaviour with Firefox. Testing: this patch adds a devtools test Signed-off-by: Delan Azabani <dazabani@igalia.com> Co-authored-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
parent
b3978439ad
commit
319f4f0e38
3 changed files with 22 additions and 15 deletions
|
@ -52,4 +52,8 @@ impl BreakpointListActor {
|
||||||
pub fn new(name: String) -> Self {
|
pub fn new(name: String) -> Self {
|
||||||
Self { name }
|
Self { name }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn encodable(&self) -> BreakpointListActorMsg {
|
||||||
|
BreakpointListActorMsg { actor: self.name() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ use super::breakpoint::BreakpointListActor;
|
||||||
use super::thread::ThreadActor;
|
use super::thread::ThreadActor;
|
||||||
use super::worker::WorkerMsg;
|
use super::worker::WorkerMsg;
|
||||||
use crate::actor::{Actor, ActorError, ActorRegistry};
|
use crate::actor::{Actor, ActorError, ActorRegistry};
|
||||||
|
use crate::actors::breakpoint::BreakpointListActorMsg;
|
||||||
use crate::actors::browsing_context::{BrowsingContextActor, BrowsingContextActorMsg};
|
use crate::actors::browsing_context::{BrowsingContextActor, BrowsingContextActorMsg};
|
||||||
use crate::actors::root::RootActor;
|
use crate::actors::root::RootActor;
|
||||||
use crate::actors::watcher::target_configuration::{
|
use crate::actors::watcher::target_configuration::{
|
||||||
|
@ -151,12 +152,7 @@ struct GetThreadConfigurationActorReply {
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
struct GetBreakpointListActorReply {
|
struct GetBreakpointListActorReply {
|
||||||
from: String,
|
from: String,
|
||||||
breakpoint_list: GetBreakpointListActorReplyInner,
|
breakpoint_list: BreakpointListActorMsg,
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
struct GetBreakpointListActorReplyInner {
|
|
||||||
actor: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
@ -191,6 +187,7 @@ pub struct WatcherActor {
|
||||||
network_parent: String,
|
network_parent: String,
|
||||||
target_configuration: String,
|
target_configuration: String,
|
||||||
thread_configuration: String,
|
thread_configuration: String,
|
||||||
|
breakpoint_list: String,
|
||||||
session_context: SessionContext,
|
session_context: SessionContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,15 +373,10 @@ impl Actor for WatcherActor {
|
||||||
request.reply_final(&msg)?
|
request.reply_final(&msg)?
|
||||||
},
|
},
|
||||||
"getBreakpointListActor" => {
|
"getBreakpointListActor" => {
|
||||||
let breakpoint_list_name = registry.new_name("breakpoint-list");
|
let breakpoint_list = registry.find::<BreakpointListActor>(&self.breakpoint_list);
|
||||||
let breakpoint_list = BreakpointListActor::new(breakpoint_list_name.clone());
|
|
||||||
registry.register_later(Box::new(breakpoint_list));
|
|
||||||
|
|
||||||
request.reply_final(&GetBreakpointListActorReply {
|
request.reply_final(&GetBreakpointListActorReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
breakpoint_list: GetBreakpointListActorReplyInner {
|
breakpoint_list: breakpoint_list.encodable(),
|
||||||
actor: breakpoint_list_name,
|
|
||||||
},
|
|
||||||
})?
|
})?
|
||||||
},
|
},
|
||||||
_ => return Err(ActorError::UnrecognizedPacketType),
|
_ => return Err(ActorError::UnrecognizedPacketType),
|
||||||
|
@ -410,6 +402,7 @@ impl WatcherActor {
|
||||||
TargetConfigurationActor::new(actors.new_name("target-configuration"));
|
TargetConfigurationActor::new(actors.new_name("target-configuration"));
|
||||||
let thread_configuration =
|
let thread_configuration =
|
||||||
ThreadConfigurationActor::new(actors.new_name("thread-configuration"));
|
ThreadConfigurationActor::new(actors.new_name("thread-configuration"));
|
||||||
|
let breakpoint_list = BreakpointListActor::new(actors.new_name("breakpoint-list"));
|
||||||
|
|
||||||
let watcher = Self {
|
let watcher = Self {
|
||||||
name: actors.new_name("watcher"),
|
name: actors.new_name("watcher"),
|
||||||
|
@ -417,12 +410,14 @@ impl WatcherActor {
|
||||||
network_parent: network_parent.name(),
|
network_parent: network_parent.name(),
|
||||||
target_configuration: target_configuration.name(),
|
target_configuration: target_configuration.name(),
|
||||||
thread_configuration: thread_configuration.name(),
|
thread_configuration: thread_configuration.name(),
|
||||||
|
breakpoint_list: breakpoint_list.name(),
|
||||||
session_context,
|
session_context,
|
||||||
};
|
};
|
||||||
|
|
||||||
actors.register(Box::new(network_parent));
|
actors.register(Box::new(network_parent));
|
||||||
actors.register(Box::new(target_configuration));
|
actors.register(Box::new(target_configuration));
|
||||||
actors.register(Box::new(thread_configuration));
|
actors.register(Box::new(thread_configuration));
|
||||||
|
actors.register(Box::new(breakpoint_list));
|
||||||
|
|
||||||
watcher
|
watcher
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,16 @@ class DevtoolsTests(unittest.IsolatedAsyncioTestCase):
|
||||||
self.web_servers = None
|
self.web_servers = None
|
||||||
self.web_server_threads = None
|
self.web_server_threads = None
|
||||||
|
|
||||||
|
# Watcher tests
|
||||||
|
|
||||||
|
def test_watcher_returns_same_breakpoint_list_actor_every_time(self):
|
||||||
|
self.run_servoshell(url="data:text/html,")
|
||||||
|
devtools = self._setup_devtools_client()
|
||||||
|
response1 = devtools.watcher.get_breakpoint_list_actor()
|
||||||
|
response2 = devtools.watcher.get_breakpoint_list_actor()
|
||||||
|
self.assertEqual(response1["breakpointList"]["actor"], response2["breakpointList"]["actor"])
|
||||||
|
|
||||||
|
# Sources list
|
||||||
# Classic script vs module script:
|
# Classic script vs module script:
|
||||||
# - <https://html.spec.whatwg.org/multipage/#classic-script>
|
# - <https://html.spec.whatwg.org/multipage/#classic-script>
|
||||||
# - <https://html.spec.whatwg.org/multipage/#module-script>
|
# - <https://html.spec.whatwg.org/multipage/#module-script>
|
||||||
|
@ -66,8 +76,6 @@ class DevtoolsTests(unittest.IsolatedAsyncioTestCase):
|
||||||
# Non-worker(?) script sources can be inline, external, or blob.
|
# Non-worker(?) script sources can be inline, external, or blob.
|
||||||
# Worker script sources can be external or blob.
|
# Worker script sources can be external or blob.
|
||||||
|
|
||||||
# Sources list
|
|
||||||
|
|
||||||
def test_sources_list(self):
|
def test_sources_list(self):
|
||||||
self.start_web_server(test_dir=os.path.join(DevtoolsTests.script_path, "devtools_tests/sources"))
|
self.start_web_server(test_dir=os.path.join(DevtoolsTests.script_path, "devtools_tests/sources"))
|
||||||
self.run_servoshell()
|
self.run_servoshell()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue