webdriver: Add ScrollBehavior::Instant for scroll_into_view (#39265)

There is a recent spec change which adds instant as default scroll
behaviour: https://github.com/w3c/webdriver/pull/1924. This PR reflects
the change.

Testing: No behaviour change as `ScrollBehavior` is ignored right now.

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
Euclid Ye 2025-09-12 23:49:40 +08:00 committed by GitHub
parent a4c6108cbe
commit 1f63116bdd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -49,7 +49,9 @@ use crate::dom::bindings::codegen::Bindings::HTMLOrSVGElementBinding::FocusOptio
use crate::dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods;
use crate::dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::{
ScrollBehavior, ScrollOptions, WindowMethods,
};
use crate::dom::bindings::codegen::Bindings::XMLSerializerBinding::XMLSerializerMethods; use crate::dom::bindings::codegen::Bindings::XMLSerializerBinding::XMLSerializerMethods;
use crate::dom::bindings::codegen::Bindings::XPathResultBinding::{ use crate::dom::bindings::codegen::Bindings::XPathResultBinding::{
XPathResultConstants, XPathResultMethods, XPathResultConstants, XPathResultMethods,
@ -1933,7 +1935,8 @@ pub(crate) fn handle_element_click(
.send( .send(
// Step 3 // Step 3
get_known_element(documents, pipeline, element_id).and_then(|element| { get_known_element(documents, pipeline, element_id).and_then(|element| {
// Step 4 // Step 4. If the element is an input element in the file upload state
// return error with error code invalid argument.
if let Some(input_element) = element.downcast::<HTMLInputElement>() { if let Some(input_element) = element.downcast::<HTMLInputElement>() {
if input_element.input_type() == InputType::File { if input_element.input_type() == InputType::File {
return Err(ErrorStatus::InvalidArgument); return Err(ErrorStatus::InvalidArgument);
@ -1944,7 +1947,7 @@ pub(crate) fn handle_element_click(
return Err(ErrorStatus::UnknownError); return Err(ErrorStatus::UnknownError);
}; };
// Step 5 // Step 5. Scroll into view the element's container.
scroll_into_view(&container, documents, &pipeline, can_gc); scroll_into_view(&container, documents, &pipeline, can_gc);
// Step 6. If element's container is still not in view // Step 6. If element's container is still not in view
@ -2169,10 +2172,13 @@ fn scroll_into_view(
} }
// Step 1. Let options be the following ScrollIntoViewOptions: // Step 1. Let options be the following ScrollIntoViewOptions:
// - "behavior": instant
// - Logical scroll position "block": end // - Logical scroll position "block": end
// - Logical scroll position "inline": nearest // - Logical scroll position "inline": nearest
let options = BooleanOrScrollIntoViewOptions::ScrollIntoViewOptions(ScrollIntoViewOptions { let options = BooleanOrScrollIntoViewOptions::ScrollIntoViewOptions(ScrollIntoViewOptions {
parent: Default::default(), parent: ScrollOptions {
behavior: ScrollBehavior::Instant,
},
block: ScrollLogicalPosition::End, block: ScrollLogicalPosition::End,
inline: ScrollLogicalPosition::Nearest, inline: ScrollLogicalPosition::Nearest,
container: Default::default(), container: Default::default(),