Auto merge of #26325 - jdm:devtools-nav, r=gterzian

Improve devtools experience when navigating

The primary motivation for this work was to fix #15425, and these changes make it possible to use the devtools to meaningfully inspect multiple pages when navigating between them. Navigating through session history is not yet supported.

These changes also include improvements to the dedicated worker support, which broke at some point. We now can observe console messages in workers.
This commit is contained in:
bors-servo 2020-04-28 16:56:11 -04:00 committed by GitHub
commit 1aab10f20a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 693 additions and 265 deletions

View file

@ -93,7 +93,7 @@ use canvas_traits::webgl::WebGLPipeline;
use crossbeam_channel::{unbounded, Receiver, Sender};
use devtools_traits::CSSError;
use devtools_traits::{DevtoolScriptControlMsg, DevtoolsPageInfo};
use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
use devtools_traits::{NavigationState, ScriptToDevtoolsControlMsg, WorkerId};
use embedder_traits::{EmbedderMsg, EventLoopWaker};
use euclid::default::{Point2D, Rect};
use euclid::Vector2D;
@ -947,6 +947,7 @@ impl ScriptThread {
/// Step 13 of https://html.spec.whatwg.org/multipage/#navigate
pub fn navigate(
browsing_context: BrowsingContextId,
pipeline_id: PipelineId,
mut load_data: LoadData,
replace: HistoryEntryReplacement,
@ -985,6 +986,12 @@ impl ScriptThread {
.queue(task, global.upcast())
.expect("Enqueing navigate js task on the DOM manipulation task source failed");
} else {
if let Some(ref sender) = script_thread.devtools_chan {
let _ = sender.send(ScriptToDevtoolsControlMsg::Navigate(
browsing_context, NavigationState::Start(load_data.url.clone())
));
}
script_thread
.script_sender
.send((pipeline_id, ScriptMsg::LoadUrl(load_data, replace)))
@ -3341,7 +3348,7 @@ impl ScriptThread {
self.notify_devtools(
document.Title(),
final_url.clone(),
(incomplete.pipeline_id, None),
(incomplete.browsing_context_id, incomplete.pipeline_id, None),
);
let parse_input = DOMString::new();
@ -3372,7 +3379,7 @@ impl ScriptThread {
&self,
title: DOMString,
url: ServoUrl,
ids: (PipelineId, Option<WorkerId>),
(bc, p, w): (BrowsingContextId, PipelineId, Option<WorkerId>),
) {
if let Some(ref chan) = self.devtools_chan {
let page_info = DevtoolsPageInfo {
@ -3380,11 +3387,14 @@ impl ScriptThread {
url: url,
};
chan.send(ScriptToDevtoolsControlMsg::NewGlobal(
ids,
(bc, p, w),
self.devtools_sender.clone(),
page_info,
page_info.clone(),
))
.unwrap();
let state = NavigationState::Stop(p, page_info);
let _ = chan.send(ScriptToDevtoolsControlMsg::Navigate(bc, state));
}
}