Send WillNavigate earlier during navigation startup (#37778)

The will-navigate message tells the devtools client to expect a
navigation for a browsing context. This makes the network monitor clear
any previous entries and show the requests for the new page that is
loaded. In order to support this correctly, we need to send the
navigation notification from the constellation instead of the script
thread, otherwise we silently ignore navigations triggered by the
browser URL bar.




Testing: Ran servo in devtools mode , now the requests appear for new
loaded page
Fixes: https://github.com/servo/servo/issues/37334

---------

Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
This commit is contained in:
Usman Yahaya Baba 2025-07-05 12:35:37 +01:00 committed by GitHub
parent 864c877be5
commit 2ad5b24225
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 197 additions and 112 deletions

View file

@ -9,8 +9,8 @@ use devtools_traits::NetworkEvent;
use serde::Serialize;
use crate::actor::ActorRegistry;
use crate::actors::browsing_context::BrowsingContextActor;
use crate::actors::network_event::NetworkEventActor;
use crate::actors::watcher::WatcherActor;
use crate::resource::{ResourceArrayType, ResourceAvailable};
#[derive(Clone, Serialize)]
@ -26,22 +26,20 @@ pub(crate) fn handle_network_event(
netevent_actor_name: String,
mut connections: Vec<TcpStream>,
network_event: NetworkEvent,
browsing_context_actor_name: String,
) {
let mut actors = actors.lock().unwrap();
let actor = actors.find_mut::<NetworkEventActor>(&netevent_actor_name);
let watcher_name = actor.watcher_name.clone();
match network_event {
NetworkEvent::HttpRequest(httprequest) => {
let (event_actor, resource_updates) = {
let actor = actors.find_mut::<NetworkEventActor>(&netevent_actor_name);
actor.add_request(httprequest);
(actor.event_actor(), actor.resource_updates())
};
actor.add_request(httprequest);
let event_actor = actor.event_actor();
let resource_updates = actor.resource_updates();
let watcher_actor = actors.find::<WatcherActor>(&watcher_name);
let browsing_context_actor =
actors.find::<BrowsingContextActor>(&browsing_context_actor_name);
for stream in &mut connections {
// Notify that a new network event has started
browsing_context_actor.resource_array(
watcher_actor.resource_array(
event_actor.clone(),
"network-event".to_string(),
ResourceArrayType::Available,
@ -49,7 +47,7 @@ pub(crate) fn handle_network_event(
);
// Also push initial resource update (request headers, cookies)
browsing_context_actor.resource_array(
watcher_actor.resource_array(
resource_updates.clone(),
"network-event".to_string(),
ResourceArrayType::Updated,
@ -58,18 +56,13 @@ pub(crate) fn handle_network_event(
}
},
NetworkEvent::HttpResponse(httpresponse) => {
// Scope mutable borrow
let resource = {
let actor = actors.find_mut::<NetworkEventActor>(&netevent_actor_name);
// Store the response information in the actor
actor.add_response(httpresponse);
actor.resource_updates()
};
// Store the response information in the actor
actor.add_response(httpresponse);
let resource = actor.resource_updates();
let watcher_actor = actors.find::<WatcherActor>(&watcher_name);
let browsing_context_actor =
actors.find::<BrowsingContextActor>(&browsing_context_actor_name);
for stream in &mut connections {
browsing_context_actor.resource_array(
watcher_actor.resource_array(
resource.clone(),
"network-event".to_string(),
ResourceArrayType::Updated,