test: reconcile main regression tests after WPT rebase

This commit is contained in:
ldm0
2026-11-22 02:01:55 +08:00
parent 38093cef60
commit 4e0fc2c68e
+58 -58
View File
@@ -466,6 +466,64 @@ fn input_type_change_sanitizes_without_dirtying_default_value() {
assert!(input.input_value_dirty());
}
#[test]
fn range_input_value_uses_live_min_max_and_step_attributes() {
let attribute = |name: &str, value: &str| {
Attribute::new(name.to_owned(), String::new(), None, value.to_owned())
};
let mut input = Element::new(
"input".to_owned(),
"http://www.w3.org/1999/xhtml".to_owned(),
None,
vec![
attribute("type", "range"),
attribute("min", "0"),
attribute("max", "100"),
attribute("step", "20"),
attribute("value", "40"),
],
);
assert_eq!(input.input_value(), "40");
assert!(input.set_input_value(""));
assert_eq!(input.input_value(), "60");
assert!(input.input_value_dirty());
assert!(input.set_input_value("80"));
assert!(input.set_attribute("max".to_owned(), String::new(), None, "50".to_owned()));
assert_eq!(input.input_value(), "40");
assert!(input.input_value_dirty());
let defaulted = Element::new(
"input".to_owned(),
"http://www.w3.org/1999/xhtml".to_owned(),
None,
vec![
attribute("type", "range"),
attribute("min", "2"),
attribute("max", "6"),
],
);
assert_eq!(defaulted.input_value(), "4");
assert!(!defaulted.input_value_dirty());
}
#[test]
fn email_multiple_attribute_resanitizes_dirty_value() {
let mut input = Element::new_html("input");
assert!(input.set_attribute("type".to_owned(), String::new(), None, "email".to_owned()));
assert!(input.set_input_value(" first@example.com , second@example.test "));
assert_eq!(
input.input_value(),
"first@example.com , second@example.test"
);
assert!(input.input_value_dirty());
assert!(input.set_attribute("multiple".to_owned(), String::new(), None, String::new()));
assert_eq!(input.input_value(), "first@example.com,second@example.test");
assert!(input.input_value_dirty());
}
#[test]
fn heading_reflections_parse_range_and_modal_state() {
let mut heading = Element::new_html("h1");
@@ -581,64 +639,6 @@ fn parser_created_link_processing_state_is_consumed_at_children_finish() {
assert!(!parser_created.finish_parsing_link_children());
}
#[test]
fn email_multiple_attribute_resanitizes_dirty_value() {
let mut input = Element::new_html("input");
assert!(input.set_attribute("type".to_owned(), String::new(), None, "email".to_owned()));
assert!(input.set_input_value(" first@example.com , second@example.test "));
assert_eq!(
input.input_value(),
"first@example.com , second@example.test"
);
assert!(input.input_value_dirty());
assert!(input.set_attribute("multiple".to_owned(), String::new(), None, String::new()));
assert_eq!(input.input_value(), "first@example.com,second@example.test");
assert!(input.input_value_dirty());
}
#[test]
fn range_input_value_uses_live_min_max_and_step_attributes() {
let attribute = |name: &str, value: &str| {
Attribute::new(name.to_owned(), String::new(), None, value.to_owned())
};
let mut input = Element::new(
"input".to_owned(),
"http://www.w3.org/1999/xhtml".to_owned(),
None,
vec![
attribute("type", "range"),
attribute("min", "0"),
attribute("max", "100"),
attribute("step", "20"),
attribute("value", "40"),
],
);
assert_eq!(input.input_value(), "40");
assert!(input.set_input_value(""));
assert_eq!(input.input_value(), "60");
assert!(input.input_value_dirty());
assert!(input.set_input_value("80"));
assert!(input.set_attribute("max".to_owned(), String::new(), None, "50".to_owned()));
assert_eq!(input.input_value(), "40");
assert!(input.input_value_dirty());
let defaulted = Element::new(
"input".to_owned(),
"http://www.w3.org/1999/xhtml".to_owned(),
None,
vec![
attribute("type", "range"),
attribute("min", "2"),
attribute("max", "6"),
],
);
assert_eq!(defaulted.input_value(), "4");
assert!(!defaulted.input_value_dirty());
}
#[test]
fn range_value_setters_use_element_bounds_and_step_authority() {
let mut input = Element::new_html("input");