Webdriver GoBack and GoForward commands wait for navigation complete (#37950)

After sending `GoBack` or `GoForward` command, webdriver wait for the
navigation complete.
It can be achieved by waiting for
`WebViewDelegate::notify_history_changed`

Testing: 
`tests/wpt/meta/webdriver/tests/classic/back/back.py`
`tests/wpt/meta/webdriver/tests/classic/forward/forward.py`

---------

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
batu_hoang 2025-07-15 18:41:50 +08:00 committed by GitHub
parent c817d7b9ce
commit 8e2d2bde6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 114 additions and 40 deletions

View file

@ -37,6 +37,7 @@ use strum_macros::IntoStaticStr;
use style::queries::values::PrefersColorScheme;
use style_traits::CSSPixel;
use url::Url;
use uuid::Uuid;
use webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel};
pub use crate::input_events::*;
@ -318,6 +319,17 @@ pub struct ScreenMetrics {
pub available_size: DeviceIndependentIntSize,
}
/// An opaque identifier for a single history traversal operation.
#[derive(Clone, Deserialize, PartialEq, Serialize)]
pub struct TraversalId(String);
impl TraversalId {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
Self(Uuid::new_v4().to_string())
}
}
#[derive(Deserialize, IntoStaticStr, Serialize)]
pub enum EmbedderMsg {
/// A status message to be displayed by the browser chrome.
@ -372,6 +384,8 @@ pub enum EmbedderMsg {
NewFavicon(WebViewId, ServoUrl),
/// The history state has changed.
HistoryChanged(WebViewId, Vec<ServoUrl>, usize),
/// A history traversal operation completed.
HistoryTraversalComplete(WebViewId, TraversalId),
/// Get the device independent window rectangle.
GetWindowRect(WebViewId, IpcSender<DeviceIndependentIntRect>),
/// Get the device independent screen size and available size.