From 0a2aa8710745c4c89de972cb33d09d9723a8b576 Mon Sep 17 00:00:00 2001 From: sideshowbarker Date: Mon, 9 Dec 2024 16:31:18 +0900 Subject: [PATCH] =?UTF-8?q?LibWeb:=20Assign=20ARIA=20role=20=E2=80=9Cswitc?= =?UTF-8?q?h=E2=80=9D=20to=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Libraries/LibWeb/HTML/HTMLInputElement.cpp | 6 +- .../wpt-import/html-aam/roles.tentative.txt | 9 +++ .../wpt-import/html-aam/roles.tentative.html | 59 +++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/html-aam/roles.tentative.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/html-aam/roles.tentative.html diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp index d3696c8cb21..bec7f08eeb1 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -2355,8 +2355,12 @@ Optional HTMLInputElement::default_role() const if (type_state() == TypeAttributeState::Button) return ARIA::Role::button; // https://www.w3.org/TR/html-aria/#el-input-checkbox - if (type_state() == TypeAttributeState::Checkbox) + if (type_state() == TypeAttributeState::Checkbox) { + // https://github.com/w3c/html-aam/issues/496 + if (has_attribute("switch"_string)) + return ARIA::Role::switch_; return ARIA::Role::checkbox; + } // https://www.w3.org/TR/html-aria/#el-input-email if (type_state() == TypeAttributeState::Email && !has_attribute(AttributeNames::list)) return ARIA::Role::textbox; diff --git a/Tests/LibWeb/Text/expected/wpt-import/html-aam/roles.tentative.txt b/Tests/LibWeb/Text/expected/wpt-import/html-aam/roles.tentative.txt new file mode 100644 index 00000000000..85354c236f8 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html-aam/roles.tentative.txt @@ -0,0 +1,9 @@ +Harness status: OK + +Found 4 tests + +4 Pass +Pass el-input-checkbox-switch +Pass el-thead +Pass el-tbody +Pass el-tfoot \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/html-aam/roles.tentative.html b/Tests/LibWeb/Text/input/wpt-import/html-aam/roles.tentative.html new file mode 100644 index 00000000000..812c72991ea --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/html-aam/roles.tentative.html @@ -0,0 +1,59 @@ + + + + HTML-AAM Role Verification Tests + + + + + + + + + + +

Tests the computedrole mappings defined in HTML-AAM. Most test names correspond to a unique ID defined in the spec.

+ +

These should remain in alphabetical order, and include all HTML tagnames. If a tag is not tested here, include a pointer to the file where it is tested, such as: <!-- caption -> ./table-roles.html -->

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
abc
123
456
xyz
+ + + + +