Truly independent web browser
LibWeb: Implement ARIAMixin on ElementInternals
Andreas Kling4586f20830a3
diff --git a/Libraries/LibWeb/ARIA/ARIAMixin.cpp b/Libraries/LibWeb/ARIA/ARIAMixin.cppindex eb09761ebe1..2f973c3502b 100644--- a/Libraries/LibWeb/ARIA/ARIAMixin.cpp+++ b/Libraries/LibWeb/ARIA/ARIAMixin.cpp@@ -18,6 +18,16 @@ namespace Web::ARIA {ARIAMixin::ARIAMixin() = default;ARIAMixin::~ARIAMixin() = default;+#define __ENUMERATE_ARIA_ATTRIBUTE(name, attribute) \+ Optional<Utf16String> ARIAMixin::name##_or_default_semantics() const \+ { \+ if (auto value = name(); value.has_value()) \+ return value; \+ return default_aria_state_or_property_value(AttributeNames::name); \+ }+ENUMERATE_ARIA_ATTRIBUTES+#undef __ENUMERATE_ARIA_ATTRIBUTE+static void for_each_ascii_whitespace_separated_token(Utf16View input, Function<IterationDecision(Utf16View)> const& callback){size_t start = 0;@@ -35,7 +45,11 @@ static void for_each_ascii_whitespace_separated_token(Utf16View input, Function<Optional<Role> ARIAMixin::role_from_role_attribute_value() const{// 1. Use the rules of the host language to detect that an element has a role attribute and to identify the attribute value string for it.- auto maybe_role_string = role();+ return role_from_role_value(role(), RoleSource::RoleAttribute);+}++Optional<Role> ARIAMixin::role_from_role_value(Optional<Utf16String> const& maybe_role_string, RoleSource source) const+{if (!maybe_role_string.has_value())return OptionalNone {};@@ -176,7 +190,9 @@ Optional<Role> ARIAMixin::role_from_role_attribute_value() const// these landmarks, it is considered an authoring error. The user agent MUST treat such elements as if no role// had been provided. If a valid fallback role had been specified, or if the element had an implicit ARIA role,// then user agents would continue to expose that role, instead.- if ((role == ARIA::Role::form || role == ARIA::Role::region)+ // NB: A role from the default ARIA role semantics is an implicit role, so this only applies to the role+ // attribute. Computing the accessible name here would also loop, as that computes the default role.+ if (source == RoleSource::RoleAttribute && (role == ARIA::Role::form || role == ARIA::Role::region)&& to_element().accessible_name(to_element().document(), DOM::ShouldComputeRole::No).value().is_empty())return IterationDecision::Continue;if (role == ARIA::Role::none || role == ARIA::Role::presentation) {diff --git a/Libraries/LibWeb/ARIA/ARIAMixin.h b/Libraries/LibWeb/ARIA/ARIAMixin.hindex fff0c043ba3..7deb0505df2 100644--- a/Libraries/LibWeb/ARIA/ARIAMixin.h+++ b/Libraries/LibWeb/ARIA/ARIAMixin.h@@ -45,10 +45,25 @@ public:// https://www.w3.org/TR/html-aria/#docconformancevirtual Optional<Role> default_role() const { return {}; }+ // The value of the default ARIA state or property semantics for the given state or property, if the host language+ // defines one.+ virtual Optional<Utf16String> default_aria_state_or_property_value(Utf16FlyString const&) const { return {}; }++ // The value of the given ARIA attribute, falling back to the default ARIA state and property semantics.+#define __ENUMERATE_ARIA_ATTRIBUTE(name, attribute) \+ Optional<Utf16String> name##_or_default_semantics() const;+ ENUMERATE_ARIA_ATTRIBUTES+#undef __ENUMERATE_ARIA_ATTRIBUTE+virtual DOM::Element& to_element() = 0;virtual DOM::Element const& to_element() const = 0;Optional<Role> role_from_role_attribute_value() const;+ enum class RoleSource : u8 {+ RoleAttribute,+ DefaultSemantics,+ };+ Optional<Role> role_from_role_value(Optional<Utf16String> const&, RoleSource) const;Optional<Role> role_or_default() const;// https://www.w3.org/TR/wai-aria-1.2/#tree_exclusiondiff --git a/Libraries/LibWeb/ARIA/AriaData.cpp b/Libraries/LibWeb/ARIA/AriaData.cppindex 34dd99ee50b..226264f16f7 100644--- a/Libraries/LibWeb/ARIA/AriaData.cpp+++ b/Libraries/LibWeb/ARIA/AriaData.cpp@@ -12,59 +12,59 @@ namespace Web::ARIA {AriaData::AriaData(Web::ARIA::ARIAMixin const& source){- m_aria_active_descendant = source.aria_active_descendant();- m_aria_atomic = AriaData::parse_optional_true_false(source.aria_atomic());- m_aria_auto_complete = AriaData::parse_aria_autocomplete(source.aria_auto_complete());- m_aria_braille_label = source.aria_braille_label().value_or(Utf16String {});- m_aria_braille_role_description = source.aria_braille_role_description().value_or(Utf16String {});- m_aria_busy = AriaData::parse_true_false(source.aria_busy());- m_aria_checked = AriaData::parse_tristate(source.aria_checked());- m_aria_col_count = AriaData::parse_integer(source.aria_col_count());- m_aria_col_index = AriaData::parse_integer(source.aria_col_index());- m_aria_col_index_text = source.aria_col_index_text().value_or(Utf16String {});- m_aria_col_span = AriaData::parse_integer(source.aria_col_span());- m_aria_controls = source.parse_id_reference_list(source.aria_controls());- m_aria_current = AriaData::parse_aria_current(source.aria_current());- m_aria_described_by = source.parse_id_reference_list(source.aria_described_by());- m_aria_description = source.aria_description().value_or(Utf16String {});- m_aria_details = source.parse_id_reference(source.aria_details());- m_aria_disabled = AriaData::parse_true_false(source.aria_disabled());- m_aria_drop_effect = AriaData::parse_aria_drop_effect(source.aria_drop_effect());- m_aria_error_message = source.parse_id_reference(source.aria_error_message());- m_aria_expanded = AriaData::parse_true_false_undefined(source.aria_expanded());- m_aria_flow_to = source.parse_id_reference_list(source.aria_flow_to());- m_aria_grabbed = AriaData::parse_true_false_undefined(source.aria_grabbed());- m_aria_has_popup = AriaData::parse_aria_has_popup(source.aria_has_popup());- m_aria_hidden = AriaData::parse_true_false_undefined(source.aria_hidden());- m_aria_invalid = AriaData::parse_aria_invalid(source.aria_invalid());- m_aria_key_shortcuts = source.aria_key_shortcuts().value_or(Utf16String {});- m_aria_label = source.aria_label().value_or(Utf16String {});- m_aria_labelled_by = source.parse_id_reference_list(source.aria_labelled_by());- m_aria_level = AriaData::parse_integer(source.aria_level());- m_aria_live = AriaData::parse_aria_live(source.aria_live());- m_aria_modal = AriaData::parse_true_false(source.aria_modal());- m_aria_multi_line = AriaData::parse_true_false(source.aria_multi_line());- m_aria_multi_selectable = AriaData::parse_true_false(source.aria_multi_selectable());- m_aria_orientation = AriaData::parse_aria_orientation(source.aria_orientation());- m_aria_owns = source.parse_id_reference_list(source.aria_owns());- m_aria_placeholder = source.aria_placeholder().value_or(Utf16String {});- m_aria_pos_in_set = AriaData::parse_integer(source.aria_pos_in_set());- m_aria_pressed = AriaData::parse_tristate(source.aria_pressed());- m_aria_read_only = AriaData::parse_true_false(source.aria_read_only());- m_aria_relevant = AriaData::parse_aria_relevant(source.aria_relevant());- m_aria_required = AriaData::parse_true_false(source.aria_required());- m_aria_role_description = source.aria_role_description().value_or(Utf16String {});- m_aria_row_count = AriaData::parse_integer(source.aria_row_count());- m_aria_row_index = AriaData::parse_integer(source.aria_row_index());- m_aria_row_index_text = source.aria_row_index_text().value_or(Utf16String {});- m_aria_row_span = AriaData::parse_integer(source.aria_row_span());- m_aria_selected = AriaData::parse_true_false_undefined(source.aria_selected());- m_aria_set_size = AriaData::parse_integer(source.aria_set_size());- m_aria_sort = AriaData::parse_aria_sort(source.aria_sort());- m_aria_value_max = AriaData::parse_number(source.aria_value_max());- m_aria_value_min = AriaData::parse_number(source.aria_value_min());- m_aria_value_now = AriaData::parse_number(source.aria_value_now());- m_aria_value_text = source.aria_value_text().value_or(Utf16String {});+ m_aria_active_descendant = source.aria_active_descendant_or_default_semantics();+ m_aria_atomic = AriaData::parse_optional_true_false(source.aria_atomic_or_default_semantics());+ m_aria_auto_complete = AriaData::parse_aria_autocomplete(source.aria_auto_complete_or_default_semantics());+ m_aria_braille_label = source.aria_braille_label_or_default_semantics().value_or(Utf16String {});+ m_aria_braille_role_description = source.aria_braille_role_description_or_default_semantics().value_or(Utf16String {});+ m_aria_busy = AriaData::parse_true_false(source.aria_busy_or_default_semantics());+ m_aria_checked = AriaData::parse_tristate(source.aria_checked_or_default_semantics());+ m_aria_col_count = AriaData::parse_integer(source.aria_col_count_or_default_semantics());+ m_aria_col_index = AriaData::parse_integer(source.aria_col_index_or_default_semantics());+ m_aria_col_index_text = source.aria_col_index_text_or_default_semantics().value_or(Utf16String {});+ m_aria_col_span = AriaData::parse_integer(source.aria_col_span_or_default_semantics());+ m_aria_controls = source.parse_id_reference_list(source.aria_controls_or_default_semantics());+ m_aria_current = AriaData::parse_aria_current(source.aria_current_or_default_semantics());+ m_aria_described_by = source.parse_id_reference_list(source.aria_described_by_or_default_semantics());+ m_aria_description = source.aria_description_or_default_semantics().value_or(Utf16String {});+ m_aria_details = source.parse_id_reference(source.aria_details_or_default_semantics());+ m_aria_disabled = AriaData::parse_true_false(source.aria_disabled_or_default_semantics());+ m_aria_drop_effect = AriaData::parse_aria_drop_effect(source.aria_drop_effect_or_default_semantics());+ m_aria_error_message = source.parse_id_reference(source.aria_error_message_or_default_semantics());+ m_aria_expanded = AriaData::parse_true_false_undefined(source.aria_expanded_or_default_semantics());+ m_aria_flow_to = source.parse_id_reference_list(source.aria_flow_to_or_default_semantics());+ m_aria_grabbed = AriaData::parse_true_false_undefined(source.aria_grabbed_or_default_semantics());+ m_aria_has_popup = AriaData::parse_aria_has_popup(source.aria_has_popup_or_default_semantics());+ m_aria_hidden = AriaData::parse_true_false_undefined(source.aria_hidden_or_default_semantics());+ m_aria_invalid = AriaData::parse_aria_invalid(source.aria_invalid_or_default_semantics());+ m_aria_key_shortcuts = source.aria_key_shortcuts_or_default_semantics().value_or(Utf16String {});+ m_aria_label = source.aria_label_or_default_semantics().value_or(Utf16String {});+ m_aria_labelled_by = source.parse_id_reference_list(source.aria_labelled_by_or_default_semantics());+ m_aria_level = AriaData::parse_integer(source.aria_level_or_default_semantics());+ m_aria_live = AriaData::parse_aria_live(source.aria_live_or_default_semantics());+ m_aria_modal = AriaData::parse_true_false(source.aria_modal_or_default_semantics());+ m_aria_multi_line = AriaData::parse_true_false(source.aria_multi_line_or_default_semantics());+ m_aria_multi_selectable = AriaData::parse_true_false(source.aria_multi_selectable_or_default_semantics());+ m_aria_orientation = AriaData::parse_aria_orientation(source.aria_orientation_or_default_semantics());+ m_aria_owns = source.parse_id_reference_list(source.aria_owns_or_default_semantics());+ m_aria_placeholder = source.aria_placeholder_or_default_semantics().value_or(Utf16String {});+ m_aria_pos_in_set = AriaData::parse_integer(source.aria_pos_in_set_or_default_semantics());+ m_aria_pressed = AriaData::parse_tristate(source.aria_pressed_or_default_semantics());+ m_aria_read_only = AriaData::parse_true_false(source.aria_read_only_or_default_semantics());+ m_aria_relevant = AriaData::parse_aria_relevant(source.aria_relevant_or_default_semantics());+ m_aria_required = AriaData::parse_true_false(source.aria_required_or_default_semantics());+ m_aria_role_description = source.aria_role_description_or_default_semantics().value_or(Utf16String {});+ m_aria_row_count = AriaData::parse_integer(source.aria_row_count_or_default_semantics());+ m_aria_row_index = AriaData::parse_integer(source.aria_row_index_or_default_semantics());+ m_aria_row_index_text = source.aria_row_index_text_or_default_semantics().value_or(Utf16String {});+ m_aria_row_span = AriaData::parse_integer(source.aria_row_span_or_default_semantics());+ m_aria_selected = AriaData::parse_true_false_undefined(source.aria_selected_or_default_semantics());+ m_aria_set_size = AriaData::parse_integer(source.aria_set_size_or_default_semantics());+ m_aria_sort = AriaData::parse_aria_sort(source.aria_sort_or_default_semantics());+ m_aria_value_max = AriaData::parse_number(source.aria_value_max_or_default_semantics());+ m_aria_value_min = AriaData::parse_number(source.aria_value_min_or_default_semantics());+ m_aria_value_now = AriaData::parse_number(source.aria_value_now_or_default_semantics());+ m_aria_value_text = source.aria_value_text_or_default_semantics().value_or(Utf16String {});}static bool value_equals(Optional<Utf16String> const& value, Utf16View expected)diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cppindex 80ef5a620ab..a1fc48285ef 100644--- a/Libraries/LibWeb/DOM/Node.cpp+++ b/Libraries/LibWeb/DOM/Node.cpp@@ -64,6 +64,7 @@#include <LibWeb/HTML/CustomElements/CustomElementRegistry.h>#include <LibWeb/HTML/FormAssociatedElement.h>#include <LibWeb/HTML/HTMLDocument.h>+#include <LibWeb/HTML/HTMLElement.h>#include <LibWeb/HTML/HTMLFieldSetElement.h>#include <LibWeb/HTML/HTMLHtmlElement.h>#include <LibWeb/HTML/HTMLImageElement.h>@@ -4387,6 +4388,17 @@ static void for_each_ascii_whitespace_separated_token(Utf16View input, Function<}}+// The elements that the given element's aria-labelledby or aria-describedby refers to: its attr-associated elements if+// it has the attribute, and otherwise those given by its default ARIA state and property semantics.+static Optional<GC::RootVector<GC::Ref<Element>>> elements_referenced_for_name_or_description(Element const& element, Utf16FlyString const& attribute, Optional<Vector<GC::Weak<Element>> const&> explicitly_set_elements)+{+ if (element.has_attribute(attribute))+ return element.get_the_attribute_associated_elements(attribute, explicitly_set_elements);+ if (auto const* html_element = as_if<HTML::HTMLElement>(element))+ return html_element->default_aria_state_or_property_elements(attribute);+ return {};+}+ErrorOr<Utf16String> Node::name_or_description(Layout::BegunRead const& read, NameOrDescription target, Document const& document, HashTable<UniqueNodeID>& visited_nodes, IsDescendant is_descendant, ShouldComputeRole should_compute_role) const{// The text alternative for a given element is computed as follows:@@ -4445,40 +4457,26 @@ ErrorOr<Utf16String> Node::name_or_description(Layout::BegunRead const& read, Na// - or, if computing a description, and the current node has an aria-describedby attribute that contains at least// one valid IDREF, and the current node is not already part of an aria-describedby traversal, process its IDREFs// in the order they occur:- auto aria_labelled_by = element->aria_labelled_by();- auto aria_described_by = element->aria_described_by();+ // NB: We take the elements an IDREF refers to as the attr-associated elements of the attribute, so that the+ // elements set through ariaLabelledByElements, ariaDescribedByElements and ElementInternals count too.+ auto referenced_elements = target == NameOrDescription::Name+ ? elements_referenced_for_name_or_description(*element, ARIA::AttributeNames::aria_labelled_by, element->aria_labelled_by_elements())+ : elements_referenced_for_name_or_description(*element, ARIA::AttributeNames::aria_described_by, element->aria_described_by_elements());- if ((target == NameOrDescription::Name && aria_labelled_by.has_value() && Node::first_valid_id(*aria_labelled_by, document).has_value())- || (target == NameOrDescription::Description && aria_described_by.has_value() && Node::first_valid_id(*aria_described_by, document).has_value())) {+ if (referenced_elements.has_value() && !referenced_elements->is_empty()) {// i. Set the accumulated text to the empty string.total_accumulated_text.clear();- Vector<Utf16View> id_list;- if (target == NameOrDescription::Name) {- for_each_ascii_whitespace_separated_token(aria_labelled_by->utf16_view(), [&](auto id) {- id_list.append(id);- return IterationDecision::Continue;- });- } else {- for_each_ascii_whitespace_separated_token(aria_described_by->utf16_view(), [&](auto id) {- id_list.append(id);- return IterationDecision::Continue;- });- }-// ii. For each IDREF:- for (auto const& id_ref : id_list) {- auto node = document.get_element_by_id(id_ref);- if (!node)- continue;+ for (auto node : *referenced_elements) {// AD-HOC: The “For each IDREF” substep in the spec doesn’t seem to explicitly require the following// check for an aria-label value; but the “div group explicitly labelledby self and heading” subtest at// https://wpt.fyi/results/accname/name/comp_labelledby.html won’t pass unless we do this check.// https://github.com/w3c/aria/issues/2388- if (target == NameOrDescription::Name && node->aria_label().has_value() && !node->aria_label()->is_empty() && !node->aria_label()->is_ascii_whitespace()) {+ if (target == NameOrDescription::Name && node->aria_label_or_default_semantics().has_value() && !node->aria_label_or_default_semantics()->is_empty() && !node->aria_label_or_default_semantics()->is_ascii_whitespace()) {total_accumulated_text.append_ascii(' ');- total_accumulated_text.append(node->aria_label().value());+ total_accumulated_text.append(node->aria_label_or_default_semantics().value());}if (visited_nodes.contains(node->unique_id()))continue;@@ -4503,8 +4501,8 @@ ErrorOr<Utf16String> Node::name_or_description(Layout::BegunRead const& read, Na// falls back to aria-label” subtest at https://wpt.fyi/results/accname/name/comp_labelledby.html won’t pass// unless we do this check.// https://github.com/w3c/aria/issues/2388- if (total_accumulated_text.view().is_ascii_whitespace() && target == NameOrDescription::Name && element->aria_label().has_value() && !element->aria_label()->is_empty() && !element->aria_label()->is_ascii_whitespace())- return element->aria_label().release_value();+ if (total_accumulated_text.view().is_ascii_whitespace() && target == NameOrDescription::Name && element->aria_label_or_default_semantics().has_value() && !element->aria_label_or_default_semantics()->is_empty() && !element->aria_label_or_default_semantics()->is_ascii_whitespace())+ return element->aria_label_or_default_semantics().release_value();return total_accumulated_text.to_string();}@@ -4516,11 +4514,11 @@ ErrorOr<Utf16String> Node::name_or_description(Layout::BegunRead const& read, Na// necessitate doing so, and the “input with label for association is superceded by aria-label” subtest at// https://wpt.fyi/results/accname/name/comp_label.html won’t pass unless we do this reordering.// Spec PR: https://github.com/w3c/aria/pull/2377- if (target == NameOrDescription::Name && element->aria_label().has_value() && !element->aria_label()->is_empty() && !element->aria_label()->is_ascii_whitespace()) {+ if (target == NameOrDescription::Name && element->aria_label_or_default_semantics().has_value() && !element->aria_label_or_default_semantics()->is_empty() && !element->aria_label_or_default_semantics()->is_ascii_whitespace()) {// TODO: - If traversal of the current node is due to recursion and the current node is an embedded control as defined in step 2E, ignore aria-label and skip to rule 2E.// https://github.com/w3c/aria/pull/2385 and https://github.com/w3c/accname/issues/173if (!element->is_html_slot_element())- return element->aria_label().value();+ return element->aria_label_or_default_semantics().value();}// C. Embedded Control: Otherwise, if the current node is a control embedded within the label (e.g. any element@@ -4583,14 +4581,14 @@ ErrorOr<Utf16String> Node::name_or_description(Layout::BegunRead const& read, Naif (child->is_element()) {auto const& element = static_cast<DOM::Element const&>(*child);auto role = element.role_or_default();- auto aria_selected = element.aria_selected();+ auto aria_selected = element.aria_selected_or_default_semantics();if (role == ARIA::Role::option && aria_selected.has_value() && aria_selected->utf16_view() == u"true"sv)builder.append(element.text_content().value());}}} else if (role == ARIA::Role::spinbutton || role == ARIA::Role::slider) {- auto aria_valuenow = element.aria_value_now();- auto aria_valuetext = element.aria_value_text();+ auto aria_valuenow = element.aria_value_now_or_default_semantics();+ auto aria_valuetext = element.aria_value_text_or_default_semantics();// iii. Range: If the embedded control has role range (e.g., a spinbutton or slider):// a. If the aria-valuetext property is present, return its value,@@ -4859,33 +4857,26 @@ ErrorOr<Utf16String> Node::accessible_description(Document const& document) consreturn Utf16String {};auto const* element = static_cast<Element const*>(this);- auto described_by = element->aria_described_by();- if (!described_by.has_value())+ auto described_by_elements = elements_referenced_for_name_or_description(*element, ARIA::AttributeNames::aria_described_by, element->aria_described_by_elements());+ if (!described_by_elements.has_value())return Utf16String {};HashTable<UniqueNodeID> visited_nodes;Utf16StringBuilder builder;- Vector<Utf16View> id_list;- for_each_ascii_whitespace_separated_token(described_by->utf16_view(), [&](auto id) {- id_list.append(id);- return IterationDecision::Continue;- });- for (auto id : id_list) {- if (auto description_element = document.get_element_by_id(id)) {- // Compute the text alternative (name) of the referenced element — not its description. The spec says to use- // the "text alternative computation" for referenced elements. IsDescendant::Yes marks this as an- // aria-describedby traversal, so step 2F takes the referenced element's content whatever its role — see the- // notes at step 2B and step 2F in name_or_description().- auto description = TRY(- description_element->name_or_description(read, NameOrDescription::Name, document,- visited_nodes, IsDescendant::Yes));- if (!description.is_empty()) {- if (builder.is_empty()) {- builder.append(description);- } else {- builder.append_ascii(" "sv);- builder.append(description);- }+ for (auto description_element : *described_by_elements) {+ // Compute the text alternative (name) of the referenced element — not its description. The spec says to use+ // the "text alternative computation" for referenced elements. IsDescendant::Yes marks this as an+ // aria-describedby traversal, so step 2F takes the referenced element's content whatever its role — see the+ // notes at step 2B and step 2F in name_or_description().+ auto description = TRY(+ description_element->name_or_description(read, NameOrDescription::Name, document,+ visited_nodes, IsDescendant::Yes));+ if (!description.is_empty()) {+ if (builder.is_empty()) {+ builder.append(description);+ } else {+ builder.append_ascii(" "sv);+ builder.append(description);}}}diff --git a/Libraries/LibWeb/HTML/ElementInternals.cpp b/Libraries/LibWeb/HTML/ElementInternals.cppindex e80df114d33..0975f7ac858 100644--- a/Libraries/LibWeb/HTML/ElementInternals.cpp+++ b/Libraries/LibWeb/HTML/ElementInternals.cpp@@ -5,13 +5,20 @@*/#include <LibGC/Heap.h>+#include <LibGC/WeakHashMap.h>+#include <LibGC/WeakInlines.h>+#include <LibJS/Runtime/Array.h>#include <LibWeb/Bindings/ElementInternals.h>#include <LibWeb/Bindings/Intrinsics.h>+#include <LibWeb/Bindings/WrapperWorld.h>#include <LibWeb/CSS/Invalidation/FormControlInvalidator.h>+#include <LibWeb/DOM/Document.h>+#include <LibWeb/DOM/Element.h>#include <LibWeb/DOM/ShadowRoot.h>#include <LibWeb/FileAPI/File.h>#include <LibWeb/HTML/ElementInternals.h>#include <LibWeb/HTML/HTMLElement.h>+#include <LibWeb/Page/Page.h>#include <LibWeb/XHR/FormData.h>namespace Web::HTML {@@ -265,6 +272,109 @@ GC::Ptr<CustomStateSet> ElementInternals::states()return m_target_element->ensure_custom_state_set();}+// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#get-the-content-attribute+Optional<Utf16String> ElementInternals::get_attribute(Utf16FlyString const& content_attribute) const+{+ // 1. If elementInternals's target element's internal content attribute map[the reflected content attribute name]+ // does not exist, then return null.+ // 2. Return elementInternals's target element's internal content attribute map[the reflected content attribute+ // name].+ return m_target_element->internal_content_attribute(content_attribute);+}++// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#set-the-content-attribute+void ElementInternals::set_attribute_value(Utf16FlyString const& content_attribute, Utf16String const& value)+{+ // Set elementInternals's target element's internal content attribute map[the reflected content attribute name]+ // to value.+ m_target_element->internal_content_attribute_map().set(content_attribute, value);+ did_change_default_aria_semantics();+}++// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#delete-the-content-attribute+void ElementInternals::remove_attribute(Utf16FlyString const& content_attribute)+{+ // Remove elementInternals's target element's internal content attribute map[the reflected content attribute+ // name].+ m_target_element->internal_content_attribute_map().remove(content_attribute);+ did_change_default_aria_semantics();+}++// AD-HOC: A change to the internal content attribute map changes the default ARIA semantics of the target element, so+// ask the client to rebuild the accessibility tree, as a DOM mutation does in Node::queue_mutation_record().+void ElementInternals::did_change_default_aria_semantics()+{+ auto& page = m_target_element->document().page();+ if (page.accessibility_interested())+ page.client().page_did_change_accessibility_tree();+}++#define __ENUMERATE_ARIA_ATTRIBUTE(name, attribute) \+ Optional<Utf16String> ElementInternals::name() const \+ { \+ return get_attribute(ARIA::AttributeNames::name); \+ } \+ \+ void ElementInternals::set_##name(Optional<Utf16String> const& value) \+ { \+ if (value.has_value()) \+ set_attribute_value(ARIA::AttributeNames::name, *value); \+ else \+ remove_attribute(ARIA::AttributeNames::name); \+ }+ENUMERATE_ARIA_ATTRIBUTES+#undef __ENUMERATE_ARIA_ATTRIBUTE++#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \+ GC::Ptr<DOM::Element> ElementInternals::attribute() const \+ { \+ return m_##attribute.ptr(); \+ } \+ \+ void ElementInternals::set_##attribute(GC::Ptr<DOM::Element> value) \+ { \+ m_##attribute = value; \+ }+ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES+#undef __ENUMERATE_ARIA_ATTRIBUTE++#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \+ Optional<Vector<GC::Weak<DOM::Element>> const&> ElementInternals::attribute() const \+ { \+ if (!m_##attribute.has_value()) \+ return {}; \+ return *m_##attribute; \+ } \+ \+ void ElementInternals::set_##attribute(Optional<Vector<GC::Weak<DOM::Element>>> value) \+ { \+ m_##attribute = move(value); \+ }+ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES+#undef __ENUMERATE_ARIA_ATTRIBUTE++// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#attr-associated-element+GC::Ptr<DOM::Element> ElementInternals::get_the_attribute_associated_element(Utf16FlyString const& content_attribute, GC::Ptr<DOM::Element> explicitly_set_attribute_element) const+{+ // 1. Let element be the result of running reflectedTarget's get the element.+ auto const& element = get_the_element();++ // 2. Let contentAttributeValue be the result of running reflectedTarget's get the content attribute.+ auto content_attribute_value = get_attribute(content_attribute);++ return DOM::get_the_attribute_associated_element(element, content_attribute_value, explicitly_set_attribute_element);+}++// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#attr-associated-elements+Optional<GC::RootVector<GC::Ref<DOM::Element>>> ElementInternals::get_the_attribute_associated_elements(Utf16FlyString const& content_attribute, Optional<Vector<GC::Weak<DOM::Element>> const&> explicitly_set_attribute_elements) const+{+ // 2. Let element be the result of running reflectedTarget's get the element.+ auto const& element = get_the_element();++ return DOM::get_the_attribute_associated_elements(+ element, [&] { return get_attribute(content_attribute); }, explicitly_set_attribute_elements);+}+void ElementInternals::visit_edges(GC::Cell::Visitor& visitor){Base::visit_edges(visitor);@@ -272,3 +382,33 @@ void ElementInternals::visit_edges(GC::Cell::Visitor& visitor)}}++namespace Web::Bindings {++struct PerElementInternalsReflectedArrayCache {+ HashMap<Utf16FlyString, WrapperWorldWeakValueCache<JS::Array>> arrays_by_attribute;+};++static GC::WeakHashMap<HTML::ElementInternals, PerElementInternalsReflectedArrayCache>& reflected_element_array_caches()+{+ static NeverDestroyed<GC::WeakHashMap<HTML::ElementInternals, PerElementInternalsReflectedArrayCache>> caches;+ return *caches;+}++static WrapperWorldWeakValueCache<JS::Array>& reflected_element_array_cache_for(HTML::ElementInternals& element_internals, Utf16FlyString const& reflected_attribute)+{+ auto& per_element_internals = reflected_element_array_caches().ensure(element_internals);+ return per_element_internals.arrays_by_attribute.ensure(reflected_attribute);+}++GC::Ptr<JS::Array> cached_reflected_element_array(HTML::ElementInternals& element_internals, WrapperWorld const& wrapper_world, Utf16FlyString const& reflected_attribute)+{+ return reflected_element_array_cache_for(element_internals, reflected_attribute).get(wrapper_world);+}++void set_cached_reflected_element_array(HTML::ElementInternals& element_internals, WrapperWorld const& wrapper_world, Utf16FlyString const& reflected_attribute, GC::Ptr<JS::Array> array)+{+ reflected_element_array_cache_for(element_internals, reflected_attribute).set(wrapper_world, array);+}++}diff --git a/Libraries/LibWeb/HTML/ElementInternals.h b/Libraries/LibWeb/HTML/ElementInternals.hindex bd304940bb0..73b63d6e1cf 100644--- a/Libraries/LibWeb/HTML/ElementInternals.h+++ b/Libraries/LibWeb/HTML/ElementInternals.h@@ -9,6 +9,9 @@#include <AK/Utf16String.h>#include <AK/WeakPtr.h>#include <LibGC/Ptr.h>+#include <LibGC/Weak.h>+#include <LibWeb/ARIA/ARIAMixin.h>+#include <LibWeb/ARIA/AttributeNames.h>#include <LibWeb/Bindings/Wrappable.h>#include <LibWeb/DOM/NodeList.h>#include <LibWeb/Forward.h>@@ -17,6 +20,13 @@#include <LibWeb/HTML/HTMLFormElement.h>#include <LibWeb/HTML/ValidityState.h>+namespace Web::Bindings {++WEB_API GC::Ptr<JS::Array> cached_reflected_element_array(HTML::ElementInternals&, WrapperWorld const&, Utf16FlyString const&);+WEB_API void set_cached_reflected_element_array(HTML::ElementInternals&, WrapperWorld const&, Utf16FlyString const&, GC::Ptr<JS::Array>);++}+namespace Web::HTML {// https://html.spec.whatwg.org/multipage/custom-elements.html#elementinternals@@ -44,13 +54,59 @@ public:WebIDL::ExceptionOr<GC::Ptr<DOM::NodeList>> labels();GC::Ptr<CustomStateSet> states();+ // https://html.spec.whatwg.org/multipage/custom-elements.html#accessibility-semantics+#define __ENUMERATE_ARIA_ATTRIBUTE(name, attribute) \+ Optional<Utf16String> name() const; \+ void set_##name(Optional<Utf16String> const&);+ ENUMERATE_ARIA_ATTRIBUTES+#undef __ENUMERATE_ARIA_ATTRIBUTE++ // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#explicitly-set-attr-element+#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \+ GC::Ptr<DOM::Element> attribute() const; \+ void set_##attribute(GC::Ptr<DOM::Element> value);+ ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES+#undef __ENUMERATE_ARIA_ATTRIBUTE++ // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#explicitly-set-attr-elements+#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \+ Optional<Vector<GC::Weak<DOM::Element>> const&> attribute() const; \+ void set_##attribute(Optional<Vector<GC::Weak<DOM::Element>>> value);+ ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES+#undef __ENUMERATE_ARIA_ATTRIBUTE++ // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflected-target+ // NB: The reflection algorithms for an ElementInternals reflected target, as used by the generated bindings.+ HTMLElement& get_the_element() const { return m_target_element; }+ Optional<Utf16String> get_attribute(Utf16FlyString const& content_attribute) const;+ void set_attribute_value(Utf16FlyString const& content_attribute, Utf16String const& value);+ void remove_attribute(Utf16FlyString const& content_attribute);++ // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#attr-associated-element+ GC::Ptr<DOM::Element> get_the_attribute_associated_element(Utf16FlyString const& content_attribute, GC::Ptr<DOM::Element> explicitly_set_attribute_element) const;++ // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#attr-associated-elements+ Optional<GC::RootVector<GC::Ref<DOM::Element>>> get_the_attribute_associated_elements(Utf16FlyString const& content_attribute, Optional<Vector<GC::Weak<DOM::Element>> const&> explicitly_set_attribute_elements) const;+private:explicit ElementInternals(HTMLElement& target_element);virtual void visit_edges(GC::Cell::Visitor& visitor) override;+ void did_change_default_aria_semantics();+// https://html.spec.whatwg.org/multipage/custom-elements.html#internals-targetGC::Ref<HTMLElement> m_target_element;++#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \+ GC::Weak<DOM::Element> m_##attribute;+ ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES+#undef __ENUMERATE_ARIA_ATTRIBUTE++#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \+ Optional<Vector<GC::Weak<DOM::Element>>> m_##attribute;+ ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES+#undef __ENUMERATE_ARIA_ATTRIBUTE};}diff --git a/Libraries/LibWeb/HTML/ElementInternals.idl b/Libraries/LibWeb/HTML/ElementInternals.idlindex 0f4cafad5ff..4c20c0b88b7 100644--- a/Libraries/LibWeb/HTML/ElementInternals.idl+++ b/Libraries/LibWeb/HTML/ElementInternals.idl@@ -26,7 +26,7 @@ interface ElementInternals {};// Accessibility semantics-// ElementInternals includes ARIAMixin;+ElementInternals includes ARIAMixin;dictionary ValidityStateFlags {boolean valueMissing = false;diff --git a/Libraries/LibWeb/HTML/HTMLElement.cpp b/Libraries/LibWeb/HTML/HTMLElement.cppindex 203ace5518a..3a39b2c83fd 100644--- a/Libraries/LibWeb/HTML/HTMLElement.cpp+++ b/Libraries/LibWeb/HTML/HTMLElement.cpp@@ -76,6 +76,9 @@ struct HTMLElement::RareData final// https://html.spec.whatwg.org/multipage/custom-elements.html#attached-internalsGC::Ptr<ElementInternals> attached_internals;+ // https://html.spec.whatwg.org/multipage/custom-elements.html#internal-content-attribute-map+ OrderedHashMap<Utf16FlyString, Utf16String> internal_content_attribute_map;+// https://html.spec.whatwg.org/multipage/popover.html#popover-triggerGC::Ptr<HTMLElement> popover_trigger;@@ -1323,8 +1326,102 @@ bool HTMLElement::is_form_associated_custom_element() constreturn custom_element_definition() && custom_element_definition()->form_associated();}+OrderedHashMap<Utf16FlyString, Utf16String>& HTMLElement::internal_content_attribute_map()+{+ return ensure_html_element_rare_data().internal_content_attribute_map;+}++Optional<Utf16String> HTMLElement::internal_content_attribute(Utf16FlyString const& name) const+{+ auto const* rare_data = html_element_rare_data();+ if (!rare_data)+ return {};+ return rare_data->internal_content_attribute_map.get(name).copy();+}++// https://html.spec.whatwg.org/multipage/dom.html#wai-aria+Optional<Utf16String> HTMLElement::default_aria_state_or_property_value(Utf16FlyString const& state_or_property) const+{+ // Similarly, for a custom element element, the default ARIA state and property semantics, for a state or property+ // named stateOrProperty, are determined as follows:+ if (!is_custom())+ return {};++ // 1. If element's attached internals is non-null:+ // 1. If element's attached internals's get the stateOrProperty-associated element exists, then return the+ // result of running it.+ // 2. If element's attached internals's get the stateOrProperty-associated elements exists, then return the+ // result of running it.+ // NB: The associated elements are given by default_aria_state_or_property_elements(). They are also stored with an+ // empty string value in the internal content attribute map, so we return no value for them here.+ if (auto const* rare_data = html_element_rare_data(); rare_data && rare_data->attached_internals) {+#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \+ if (state_or_property == ARIA::AttributeNames::referencing_attribute) \+ return {};+ ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES+ ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES+#undef __ENUMERATE_ARIA_ATTRIBUTE+ }++ // 2. If element's internal content attribute map[stateOrProperty] exists, then return it.+ // 3. Return the default value for stateOrProperty.+ // NB: The caller falls back to the default value when we return no value.+ return internal_content_attribute(state_or_property);+}++// https://html.spec.whatwg.org/multipage/dom.html#wai-aria+Optional<GC::RootVector<GC::Ref<DOM::Element>>> HTMLElement::default_aria_state_or_property_elements(Utf16FlyString const& state_or_property) const+{+ // NB: This is step 1 of the default ARIA state and property semantics of a custom element, for the states and+ // properties that refer to elements.+ if (!is_custom())+ return {};++ // 1. If element's attached internals is non-null:+ auto const* rare_data = html_element_rare_data();+ if (!rare_data || !rare_data->attached_internals)+ return {};+ auto const& internals = *rare_data->attached_internals;++ // 1. If element's attached internals's get the stateOrProperty-associated element exists, then return the+ // result of running it.+#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \+ if (state_or_property == ARIA::AttributeNames::referencing_attribute) { \+ GC::RootVector<GC::Ref<DOM::Element>> elements; \+ if (auto element = internals.get_the_attribute_associated_element(state_or_property, internals.attribute())) \+ elements.append(*element); \+ return elements; \+ }+ ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES+#undef __ENUMERATE_ARIA_ATTRIBUTE++ // 2. If element's attached internals's get the stateOrProperty-associated elements exists, then return the+ // result of running it.+#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \+ if (state_or_property == ARIA::AttributeNames::referencing_attribute) \+ return internals.get_the_attribute_associated_elements(state_or_property, internals.attribute());+ ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES+#undef __ENUMERATE_ARIA_ATTRIBUTE++ return {};+}+Optional<ARIA::Role> HTMLElement::default_role() const{+ // https://html.spec.whatwg.org/multipage/dom.html#wai-aria+ // In addition to the rules there, for a custom element element, the default ARIA role semantics are determined as+ // follows:+ if (is_custom()) {+ // 1. Let map be element's internal content attribute map.+ // 2. If map["role"] exists, then return it.+ if (auto role = internal_content_attribute(ARIA::AttributeNames::role); role.has_value())+ return role_from_role_value(role, RoleSource::DefaultSemantics);++ // 3. Return no role.+ // AD-HOC: A customized built-in element keeps the default role of the element it extends, so we fall+ // through to the rules below, which give no role to an autonomous custom element.+ }+// https://www.w3.org/TR/html-aria/#el-addressif (local_name() == TagNames::address)return ARIA::Role::group;diff --git a/Libraries/LibWeb/HTML/HTMLElement.h b/Libraries/LibWeb/HTML/HTMLElement.hindex 99a08e51365..c84c4ffee8f 100644--- a/Libraries/LibWeb/HTML/HTMLElement.h+++ b/Libraries/LibWeb/HTML/HTMLElement.h@@ -6,6 +6,7 @@#pragma once+#include <AK/HashMap.h>#include <AK/Optional.h>#include <AK/Utf16FlyString.h>#include <AK/Utf16View.h>@@ -144,6 +145,12 @@ public:GC::Ptr<DOM::NodeList> labels();virtual Optional<ARIA::Role> default_role() const override;+ virtual Optional<Utf16String> default_aria_state_or_property_value(Utf16FlyString const&) const override;+ Optional<GC::RootVector<GC::Ref<DOM::Element>>> default_aria_state_or_property_elements(Utf16FlyString const&) const;++ // https://html.spec.whatwg.org/multipage/custom-elements.html#internal-content-attribute-map+ OrderedHashMap<Utf16FlyString, Utf16String>& internal_content_attribute_map();+ Optional<Utf16String> internal_content_attribute(Utf16FlyString const&) const;WebIDL::ExceptionOr<GC::Ref<ElementInternals>> attach_internals();diff --git a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/ElementInternals-accessibility-values.txt b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/ElementInternals-accessibility-values.txtindex 6c9ac17f3c2..8acea54ead3 100644--- a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/ElementInternals-accessibility-values.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/ElementInternals-accessibility-values.txt@@ -2,53 +2,53 @@ Harness status: OKFound 49 tests-49 Fail-Fail role-Fail ariaActiveDescendantElement-Fail ariaAtomic-Fail ariaAutoComplete-Fail ariaBrailleLabel-Fail ariaBrailleRoleDescription-Fail ariaBusy-Fail ariaChecked-Fail ariaColCount-Fail ariaColIndex-Fail ariaColSpan-Fail ariaControlsElements-Fail ariaCurrent-Fail ariaDescribedByElements-Fail ariaDetailsElements-Fail ariaDisabled-Fail ariaErrorMessageElements-Fail ariaExpanded-Fail ariaFlowToElements-Fail ariaHasPopup-Fail ariaHidden-Fail ariaInvalid-Fail ariaKeyShortcuts-Fail ariaLabel-Fail ariaLabelledByElements-Fail ariaLevel-Fail ariaLive-Fail ariaModal-Fail ariaMultiLine-Fail ariaMultiSelectable-Fail ariaOrientation-Fail ariaOwnsElements-Fail ariaPlaceholder-Fail ariaPosInSet-Fail ariaPressed-Fail ariaReadOnly-Fail ariaRelevant-Fail ariaRequired-Fail ariaRoleDescription-Fail ariaRowCount-Fail ariaRowIndex-Fail ariaRowSpan-Fail ariaSelected-Fail ariaSetSize-Fail ariaSort-Fail ariaValueMax-Fail ariaValueMin-Fail ariaValueNow-Fail ariaValueText\ No newline at end of file+49 Pass+Pass role+Pass ariaActiveDescendantElement+Pass ariaAtomic+Pass ariaAutoComplete+Pass ariaBrailleLabel+Pass ariaBrailleRoleDescription+Pass ariaBusy+Pass ariaChecked+Pass ariaColCount+Pass ariaColIndex+Pass ariaColSpan+Pass ariaControlsElements+Pass ariaCurrent+Pass ariaDescribedByElements+Pass ariaDetailsElements+Pass ariaDisabled+Pass ariaErrorMessageElements+Pass ariaExpanded+Pass ariaFlowToElements+Pass ariaHasPopup+Pass ariaHidden+Pass ariaInvalid+Pass ariaKeyShortcuts+Pass ariaLabel+Pass ariaLabelledByElements+Pass ariaLevel+Pass ariaLive+Pass ariaModal+Pass ariaMultiLine+Pass ariaMultiSelectable+Pass ariaOrientation+Pass ariaOwnsElements+Pass ariaPlaceholder+Pass ariaPosInSet+Pass ariaPressed+Pass ariaReadOnly+Pass ariaRelevant+Pass ariaRequired+Pass ariaRoleDescription+Pass ariaRowCount+Pass ariaRowIndex+Pass ariaRowSpan+Pass ariaSelected+Pass ariaSetSize+Pass ariaSort+Pass ariaValueMax+Pass ariaValueMin+Pass ariaValueNow+Pass ariaValueText\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/ElementInternals-accessibility.txt b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/ElementInternals-accessibility.txtindex 02b842fe6e7..64f95c0348e 100644--- a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/ElementInternals-accessibility.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/ElementInternals-accessibility.txt@@ -2,55 +2,54 @@ Harness status: OKFound 50 tests-1 Pass-49 Fail-Fail role is defined in ElementInternals-Fail ariaActiveDescendantElement is defined in ElementInternals-Fail ariaAtomic is defined in ElementInternals-Fail ariaAutoComplete is defined in ElementInternals-Fail ariaBrailleLabel is defined in ElementInternals-Fail ariaBrailleRoleDescription is defined in ElementInternals-Fail ariaBusy is defined in ElementInternals-Fail ariaChecked is defined in ElementInternals-Fail ariaColCount is defined in ElementInternals-Fail ariaColIndex is defined in ElementInternals-Fail ariaColSpan is defined in ElementInternals-Fail ariaControlsElements is defined in ElementInternals-Fail ariaCurrent is defined in ElementInternals-Fail ariaDescribedByElements is defined in ElementInternals-Fail ariaDetailsElements is defined in ElementInternals-Fail ariaDisabled is defined in ElementInternals-Fail ariaErrorMessageElements is defined in ElementInternals-Fail ariaExpanded is defined in ElementInternals-Fail ariaFlowToElements is defined in ElementInternals-Fail ariaHasPopup is defined in ElementInternals-Fail ariaHidden is defined in ElementInternals-Fail ariaInvalid is defined in ElementInternals-Fail ariaKeyShortcuts is defined in ElementInternals-Fail ariaLabel is defined in ElementInternals-Fail ariaLabelledByElements is defined in ElementInternals-Fail ariaLevel is defined in ElementInternals-Fail ariaLive is defined in ElementInternals-Fail ariaModal is defined in ElementInternals-Fail ariaMultiLine is defined in ElementInternals-Fail ariaMultiSelectable is defined in ElementInternals-Fail ariaOrientation is defined in ElementInternals-Fail ariaOwnsElements is defined in ElementInternals-Fail ariaPlaceholder is defined in ElementInternals-Fail ariaPosInSet is defined in ElementInternals-Fail ariaPressed is defined in ElementInternals-Fail ariaReadOnly is defined in ElementInternals-Fail ariaRelevant is defined in ElementInternals-Fail ariaRequired is defined in ElementInternals-Fail ariaRoleDescription is defined in ElementInternals-Fail ariaRowCount is defined in ElementInternals-Fail ariaRowIndex is defined in ElementInternals-Fail ariaRowSpan is defined in ElementInternals-Fail ariaSelected is defined in ElementInternals-Fail ariaSetSize is defined in ElementInternals-Fail ariaSort is defined in ElementInternals-Fail ariaValueMax is defined in ElementInternals-Fail ariaValueMin is defined in ElementInternals-Fail ariaValueNow is defined in ElementInternals-Fail ariaValueText is defined in ElementInternals+50 Pass+Pass role is defined in ElementInternals+Pass ariaActiveDescendantElement is defined in ElementInternals+Pass ariaAtomic is defined in ElementInternals+Pass ariaAutoComplete is defined in ElementInternals+Pass ariaBrailleLabel is defined in ElementInternals+Pass ariaBrailleRoleDescription is defined in ElementInternals+Pass ariaBusy is defined in ElementInternals+Pass ariaChecked is defined in ElementInternals+Pass ariaColCount is defined in ElementInternals+Pass ariaColIndex is defined in ElementInternals+Pass ariaColSpan is defined in ElementInternals+Pass ariaControlsElements is defined in ElementInternals+Pass ariaCurrent is defined in ElementInternals+Pass ariaDescribedByElements is defined in ElementInternals+Pass ariaDetailsElements is defined in ElementInternals+Pass ariaDisabled is defined in ElementInternals+Pass ariaErrorMessageElements is defined in ElementInternals+Pass ariaExpanded is defined in ElementInternals+Pass ariaFlowToElements is defined in ElementInternals+Pass ariaHasPopup is defined in ElementInternals+Pass ariaHidden is defined in ElementInternals+Pass ariaInvalid is defined in ElementInternals+Pass ariaKeyShortcuts is defined in ElementInternals+Pass ariaLabel is defined in ElementInternals+Pass ariaLabelledByElements is defined in ElementInternals+Pass ariaLevel is defined in ElementInternals+Pass ariaLive is defined in ElementInternals+Pass ariaModal is defined in ElementInternals+Pass ariaMultiLine is defined in ElementInternals+Pass ariaMultiSelectable is defined in ElementInternals+Pass ariaOrientation is defined in ElementInternals+Pass ariaOwnsElements is defined in ElementInternals+Pass ariaPlaceholder is defined in ElementInternals+Pass ariaPosInSet is defined in ElementInternals+Pass ariaPressed is defined in ElementInternals+Pass ariaReadOnly is defined in ElementInternals+Pass ariaRelevant is defined in ElementInternals+Pass ariaRequired is defined in ElementInternals+Pass ariaRoleDescription is defined in ElementInternals+Pass ariaRowCount is defined in ElementInternals+Pass ariaRowIndex is defined in ElementInternals+Pass ariaRowSpan is defined in ElementInternals+Pass ariaSelected is defined in ElementInternals+Pass ariaSetSize is defined in ElementInternals+Pass ariaSort is defined in ElementInternals+Pass ariaValueMax is defined in ElementInternals+Pass ariaValueMin is defined in ElementInternals+Pass ariaValueNow is defined in ElementInternals+Pass ariaValueText is defined in ElementInternalsPass ariaErrorMessageElement is not defined in ElementInternals\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/ElementInternals-role.txt b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/ElementInternals-role.txtindex ae486756be9..8e1b0f1a645 100644--- a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/ElementInternals-role.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/ElementInternals-role.txt@@ -2,72 +2,72 @@ Harness status: OKFound 68 tests-68 Fail-Fail Applies "alert" via Element Internals-Fail Applies "alertdialog" via Element Internals-Fail Applies "application" via Element Internals-Fail Applies "article" via Element Internals-Fail Applies "banner" via Element Internals-Fail Applies "button" via Element Internals-Fail Applies "cell" via Element Internals-Fail Applies "checkbox" via Element Internals-Fail Applies "combobox" via Element Internals-Fail Applies "complementary" via Element Internals-Fail Applies "contentinfo" via Element Internals-Fail Applies "definition" via Element Internals-Fail Applies "dialog" via Element Internals-Fail Applies "directory" via Element Internals-Fail Applies "document" via Element Internals-Fail Applies "figure" via Element Internals-Fail Applies "form" via Element Internals-Fail Applies "grid" via Element Internals-Fail Applies "group" via Element Internals-Fail Applies "heading" via Element Internals-Fail Applies "img" via Element Internals-Fail Applies "feed" via Element Internals-Fail Applies "link" via Element Internals-Fail Applies "list" via Element Internals-Fail Applies "listbox" via Element Internals-Fail Applies "log" via Element Internals-Fail Applies "main" via Element Internals-Fail Applies "marquee" via Element Internals-Fail Applies "math" via Element Internals-Fail Applies "menu" via Element Internals-Fail Applies "menubar" via Element Internals-Fail Applies "meter" via Element Internals-Fail Applies "navigation" via Element Internals-Fail Applies "note" via Element Internals-Fail Applies "progressbar" via Element Internals-Fail Applies "radio" via Element Internals-Fail Applies "radiogroup" via Element Internals-Fail Applies "region" via Element Internals-Fail Applies "scrollbar" via Element Internals-Fail Applies "search" via Element Internals-Fail Applies "searchbox" via Element Internals-Fail Applies "separator" via Element Internals-Fail Applies "slider" via Element Internals-Fail Applies "spinbutton" via Element Internals-Fail Applies "status" via Element Internals-Fail Applies "switch" via Element Internals-Fail Applies "table" via Element Internals-Fail Applies "tablist" via Element Internals-Fail Applies "tabpanel" via Element Internals-Fail Applies "term" via Element Internals-Fail Applies "textbox" via Element Internals-Fail Applies "timer" via Element Internals-Fail Applies "toolbar" via Element Internals-Fail Applies "tooltip" via Element Internals-Fail Applies "tree" via Element Internals-Fail Applies "treegrid" via Element Internals-Fail Applies parent/child relationship of "table"/"row"/"columnheader" via Element Internals-Fail Applies parent/child relationship of "grid"/"row"/"gridcell" via Element Internals-Fail Applies parent/child relationship of "list"/"listitem" via Element Internals-Fail Applies parent/child relationship of "menu"/"menuitem" via Element Internals-Fail Applies parent/child relationship of "menu"/"menuitemcheckbox" via Element Internals-Fail Applies parent/child relationship of "menu"/"menuitemradio" via Element Internals-Fail Applies parent/child relationship of "listbox"/"option" via Element Internals-Fail Applies parent/child relationship of "table"/"row" via Element Internals-Fail Applies parent/child relationship of "table"/"rowgroup" via Element Internals-Fail Applies parent/child relationship of "table"/"row"/"rowheader" via Element Internals-Fail Applies parent/child relationship of "tablist"/"tab" via Element Internals-Fail Applies parent/child relationship of "tree"/"treeitem" via Element Internals\ No newline at end of file+68 Pass+Pass Applies "alert" via Element Internals+Pass Applies "alertdialog" via Element Internals+Pass Applies "application" via Element Internals+Pass Applies "article" via Element Internals+Pass Applies "banner" via Element Internals+Pass Applies "button" via Element Internals+Pass Applies "cell" via Element Internals+Pass Applies "checkbox" via Element Internals+Pass Applies "combobox" via Element Internals+Pass Applies "complementary" via Element Internals+Pass Applies "contentinfo" via Element Internals+Pass Applies "definition" via Element Internals+Pass Applies "dialog" via Element Internals+Pass Applies "directory" via Element Internals+Pass Applies "document" via Element Internals+Pass Applies "figure" via Element Internals+Pass Applies "form" via Element Internals+Pass Applies "grid" via Element Internals+Pass Applies "group" via Element Internals+Pass Applies "heading" via Element Internals+Pass Applies "img" via Element Internals+Pass Applies "feed" via Element Internals+Pass Applies "link" via Element Internals+Pass Applies "list" via Element Internals+Pass Applies "listbox" via Element Internals+Pass Applies "log" via Element Internals+Pass Applies "main" via Element Internals+Pass Applies "marquee" via Element Internals+Pass Applies "math" via Element Internals+Pass Applies "menu" via Element Internals+Pass Applies "menubar" via Element Internals+Pass Applies "meter" via Element Internals+Pass Applies "navigation" via Element Internals+Pass Applies "note" via Element Internals+Pass Applies "progressbar" via Element Internals+Pass Applies "radio" via Element Internals+Pass Applies "radiogroup" via Element Internals+Pass Applies "region" via Element Internals+Pass Applies "scrollbar" via Element Internals+Pass Applies "search" via Element Internals+Pass Applies "searchbox" via Element Internals+Pass Applies "separator" via Element Internals+Pass Applies "slider" via Element Internals+Pass Applies "spinbutton" via Element Internals+Pass Applies "status" via Element Internals+Pass Applies "switch" via Element Internals+Pass Applies "table" via Element Internals+Pass Applies "tablist" via Element Internals+Pass Applies "tabpanel" via Element Internals+Pass Applies "term" via Element Internals+Pass Applies "textbox" via Element Internals+Pass Applies "timer" via Element Internals+Pass Applies "toolbar" via Element Internals+Pass Applies "tooltip" via Element Internals+Pass Applies "tree" via Element Internals+Pass Applies "treegrid" via Element Internals+Pass Applies parent/child relationship of "table"/"row"/"columnheader" via Element Internals+Pass Applies parent/child relationship of "grid"/"row"/"gridcell" via Element Internals+Pass Applies parent/child relationship of "list"/"listitem" via Element Internals+Pass Applies parent/child relationship of "menu"/"menuitem" via Element Internals+Pass Applies parent/child relationship of "menu"/"menuitemcheckbox" via Element Internals+Pass Applies parent/child relationship of "menu"/"menuitemradio" via Element Internals+Pass Applies parent/child relationship of "listbox"/"option" via Element Internals+Pass Applies parent/child relationship of "table"/"row" via Element Internals+Pass Applies parent/child relationship of "table"/"rowgroup" via Element Internals+Pass Applies parent/child relationship of "table"/"row"/"rowheader" via Element Internals+Pass Applies parent/child relationship of "tablist"/"tab" via Element Internals+Pass Applies parent/child relationship of "tree"/"treeitem" via Element Internals\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/element-internals-aria-element-reflection.txt b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/element-internals-aria-element-reflection.txtindex 0a3cdb12935..ce5fb8185d4 100644--- a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/element-internals-aria-element-reflection.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/element-internals-aria-element-reflection.txt@@ -2,14 +2,13 @@ Harness status: OKFound 9 tests-6 Pass-3 Fail-Fail Getting previously-unset ARIA element reflection properties on ElementInternals should return null.+9 Pass+Pass Getting previously-unset ARIA element reflection properties on ElementInternals should return null.Pass Getting ARIA element reflection properties on ElementInternals should return the value that was set.Pass Setting ARIA element reflection properties to an empty array should work as expected.Pass Reading an ARIA element reflection array property that was set to an empty array, on an ElementInternals with no previously cached value, should return an empty array.Pass Setting ARIA element reflection properties on ElementInternals to null should delete any previous value, and not crash-Fail Setting ariaLabelledByElements on ElementInternals should change the accessible name of the custom element-Fail Setting aria-labelledby or ariaLabelledByElements on the custom element should supersede the value of ariaLabelledByElements on ElementInternals+Pass Setting ariaLabelledByElements on ElementInternals should change the accessible name of the custom element+Pass Setting aria-labelledby or ariaLabelledByElements on the custom element should supersede the value of ariaLabelledByElements on ElementInternalsPass Caching invariant different attributes.Pass Caching invariant different elements.\ No newline at end of file