Allow running testharness/testdriver/reftests in servodriver (#34550)

* Make servodriver a thin wrapper over the base webdriver browser/executor classes.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Make ServoWebDriverRefTestExecutor a thin shell over the webdriver reftest executor.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Wait for the initial load to complete when opening a new tab via webdriver.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Remove assumption of a single tab from the webdriver server.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Serialize all keys of JS objects when converting to webdriver values.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Cleanup, docs, etc.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Use webview terminology more consistently.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix flake8 errors.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2024-12-11 14:18:44 -05:00 committed by GitHub
parent 25f242b652
commit 7b160700d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 336 additions and 407 deletions

View file

@ -1461,7 +1461,11 @@ where
// Create a new top level browsing context. Will use response_chan to return
// the browsing context id.
FromCompositorMsg::NewWebView(url, top_level_browsing_context_id) => {
self.handle_new_top_level_browsing_context(url, top_level_browsing_context_id);
self.handle_new_top_level_browsing_context(
url,
top_level_browsing_context_id,
None,
);
},
// A top level browsing context is created and opened in both constellation and
// compositor.
@ -1485,14 +1489,7 @@ where
self.handle_panic(top_level_browsing_context_id, error, None);
},
FromCompositorMsg::FocusWebView(top_level_browsing_context_id) => {
if self.webviews.get(top_level_browsing_context_id).is_none() {
return warn!("{top_level_browsing_context_id}: FocusWebView on unknown top-level browsing context");
}
self.webviews.focus(top_level_browsing_context_id);
self.embedder_proxy.send((
Some(top_level_browsing_context_id),
EmbedderMsg::WebViewFocused(top_level_browsing_context_id),
));
self.handle_focus_web_view(top_level_browsing_context_id);
},
FromCompositorMsg::BlurWebView => {
self.webviews.unfocus();
@ -2957,6 +2954,21 @@ where
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true), level = "trace")
)]
fn handle_focus_web_view(&mut self, top_level_browsing_context_id: TopLevelBrowsingContextId) {
if self.webviews.get(top_level_browsing_context_id).is_none() {
return warn!("{top_level_browsing_context_id}: FocusWebView on unknown top-level browsing context");
}
self.webviews.focus(top_level_browsing_context_id);
self.embedder_proxy.send((
Some(top_level_browsing_context_id),
EmbedderMsg::WebViewFocused(top_level_browsing_context_id),
));
}
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn handle_log_entry(
&mut self,
top_level_browsing_context_id: Option<TopLevelBrowsingContextId>,
@ -3044,6 +3056,7 @@ where
&mut self,
url: ServoUrl,
top_level_browsing_context_id: TopLevelBrowsingContextId,
response_sender: Option<IpcSender<webdriver_msg::LoadStatus>>,
) {
let window_size = self.window_size.initial_viewport;
let pipeline_id = PipelineId::new();
@ -3104,6 +3117,10 @@ where
}),
window_size,
});
if let Some(response_sender) = response_sender {
self.webdriver.load_channel = Some((pipeline_id, response_sender));
}
}
#[cfg_attr(
@ -3759,7 +3776,7 @@ where
) {
let mut webdriver_reset = false;
if let Some((expected_pipeline_id, ref reply_chan)) = self.webdriver.load_channel {
debug!("Sending load to WebDriver");
debug!("Sending load for {:?} to WebDriver", expected_pipeline_id);
if expected_pipeline_id == pipeline_id {
let _ = reply_chan.send(webdriver_msg::LoadStatus::LoadComplete);
webdriver_reset = true;
@ -4606,6 +4623,21 @@ where
// Find the script channel for the given parent pipeline,
// and pass the event to that script thread.
match msg {
WebDriverCommandMsg::CloseWebView(top_level_browsing_context_id) => {
self.handle_close_top_level_browsing_context(top_level_browsing_context_id);
},
WebDriverCommandMsg::NewWebView(sender, load_sender) => {
let top_level_browsing_context_id = TopLevelBrowsingContextId::new();
self.handle_new_top_level_browsing_context(
ServoUrl::parse_with_base(None, "about:blank").expect("Infallible parse"),
top_level_browsing_context_id,
Some(load_sender),
);
let _ = sender.send(top_level_browsing_context_id);
},
WebDriverCommandMsg::FocusWebView(top_level_browsing_context_id) => {
self.handle_focus_web_view(top_level_browsing_context_id);
},
WebDriverCommandMsg::GetWindowSize(_, response_sender) => {
let _ = response_sender.send(self.window_size);
},
@ -4888,13 +4920,20 @@ where
);
},
};
if let Some(new_pipeline_id) = self.load_url(
top_level_browsing_context_id,
pipeline_id,
load_data,
replace,
) {
debug!(
"Setting up webdriver load notification for {:?}",
new_pipeline_id
);
self.webdriver.load_channel = Some((new_pipeline_id, response_sender));
} else {
let _ = response_sender.send(webdriver_msg::LoadStatus::LoadCanceled);
}
}