mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
webdriver: consider boolean attribute when get element attribute (#38401)
The function handle_get_attribute should act differently when the attribute is a boolean attribute. The full list of attributes can be found in [1]. All attributes marked as "Boolean attribute" in the "Value" column are boolean attributes. Note that "hidden" is effectively treated as a boolean attribute, according to WPT test "test_global_boolean_attributes" in webdriver/tests/classic/get_element_attribute/get.py [1] https://html.spec.whatwg.org/multipage/#attributes-3 Testing: Updated WPT test expectation Fixes: #38353 --------- Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This commit is contained in:
parent
05ad9026f5
commit
5e8754bb1d
3 changed files with 57 additions and 60 deletions
|
@ -289,3 +289,47 @@ pub(crate) fn is_relevant_attribute(namespace: &Namespace, local_name: &LocalNam
|
|||
// <https://svgwg.org/svg2-draft/linking.html#XLinkHrefAttribute>
|
||||
namespace == &ns!() || (namespace == &ns!(xlink) && local_name == &local_name!("href"))
|
||||
}
|
||||
|
||||
/// A help function to check if an attribute is a boolean attribute.
|
||||
pub(crate) fn is_boolean_attribute(name: &str) -> bool {
|
||||
// The full list of attributes can be found in [1]. All attributes marked as "Boolean
|
||||
// attribute" in the "Value" column are boolean attributes. Note that "hidden" is effectively
|
||||
// treated as a boolean attribute, according to WPT test "test_global_boolean_attributes" in
|
||||
// webdriver/tests/classic/get_element_attribute/get.py
|
||||
//
|
||||
// [1] <https://html.spec.whatwg.org/multipage/#attributes-3>
|
||||
[
|
||||
"allowfullscreen",
|
||||
"alpha",
|
||||
"async",
|
||||
"autofocus",
|
||||
"autoplay",
|
||||
"checked",
|
||||
"controls",
|
||||
"default",
|
||||
"defer",
|
||||
"disabled",
|
||||
"formnovalidate",
|
||||
"hidden",
|
||||
"inert",
|
||||
"ismap",
|
||||
"itemscope",
|
||||
"loop",
|
||||
"multiple",
|
||||
"muted",
|
||||
"nomodule",
|
||||
"novalidate",
|
||||
"open",
|
||||
"playsinline",
|
||||
"readonly",
|
||||
"required",
|
||||
"reversed",
|
||||
"selected",
|
||||
"shadowrootclonable",
|
||||
"shadowrootcustomelementregistry",
|
||||
"shadowrootdelegatesfocus",
|
||||
"shadowrootserializable",
|
||||
]
|
||||
.iter()
|
||||
.any(|&boolean_attr| boolean_attr.eq_ignore_ascii_case(name))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue