diff --git a/Libraries/LibWeb/ARIA/RoleType.cpp b/Libraries/LibWeb/ARIA/RoleType.cpp index d1a39040492..ceba11dc0fc 100644 --- a/Libraries/LibWeb/ARIA/RoleType.cpp +++ b/Libraries/LibWeb/ARIA/RoleType.cpp @@ -210,6 +210,8 @@ ErrorOr> RoleType::build_role_object(Role role, bool foc return adopt_nonnull_own_or_enomem(new (nothrow) Group(data)); case Role::heading: return adopt_nonnull_own_or_enomem(new (nothrow) Heading(data)); + case Role::image: + return adopt_nonnull_own_or_enomem(new (nothrow) Img(data)); case Role::img: return adopt_nonnull_own_or_enomem(new (nothrow) Img(data)); case Role::input: diff --git a/Libraries/LibWeb/ARIA/Roles.h b/Libraries/LibWeb/ARIA/Roles.h index 96f5d49ecb4..1ce01d8cc87 100644 --- a/Libraries/LibWeb/ARIA/Roles.h +++ b/Libraries/LibWeb/ARIA/Roles.h @@ -43,6 +43,7 @@ namespace Web::ARIA { __ENUMERATE_ARIA_ROLE(gridcell) \ __ENUMERATE_ARIA_ROLE(group) \ __ENUMERATE_ARIA_ROLE(heading) \ + __ENUMERATE_ARIA_ROLE(image) \ __ENUMERATE_ARIA_ROLE(img) \ __ENUMERATE_ARIA_ROLE(input) \ __ENUMERATE_ARIA_ROLE(insertion) \ diff --git a/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Libraries/LibWeb/HTML/HTMLImageElement.cpp index cd6acf934cb..2d5207c1aff 100644 --- a/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -411,10 +411,15 @@ Optional HTMLImageElement::default_role() const { // https://www.w3.org/TR/html-aria/#el-img // https://www.w3.org/TR/html-aria/#el-img-no-alt + // https://w3c.github.io/aria/#image + // NOTE: The "image" role value is a synonym for the older "img" role value; however, the el-img test in + // https://wpt.fyi/results/html-aam/roles.html expects the value to be "image" (not "img"). if (!alt().is_empty()) - return ARIA::Role::img; + return ARIA::Role::image; // https://www.w3.org/TR/html-aria/#el-img-empty-alt - return ARIA::Role::presentation; + // NOTE: The "none" role value is a synonym for the older "presentation" role value; however, the el-img-alt-no-value + // test in https://wpt.fyi/results/html-aam/roles.html expects the value to be "none" (not "presentation"). + return ARIA::Role::none; } // https://html.spec.whatwg.org/multipage/images.html#use-srcset-or-picture diff --git a/Tests/LibWeb/Text/expected/wpt-import/html-aam/roles.txt b/Tests/LibWeb/Text/expected/wpt-import/html-aam/roles.txt new file mode 100644 index 00000000000..d62e2a2cf66 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html-aam/roles.txt @@ -0,0 +1,63 @@ +Harness status: OK + +Found 58 tests + +58 Pass +Pass el-address +Pass el-article +Pass el-blockquote +Pass el-button +Pass el-code +Pass el-dd +Pass el-del +Pass el-details +Pass el-dfn +Pass el-dt +Pass el-em +Pass el-fieldset +Pass el-figure +Pass el-form +Pass el-h1 +Pass el-h2 +Pass el-h3 +Pass el-h4 +Pass el-h5 +Pass el-h6 +Pass el-hgroup +Pass el-hr +Pass el-img +Pass el-input-button +Pass el-input-checkbox +Pass el-input-email +Pass el-input-radio +Pass el-input-range +Pass el-input-reset +Pass el-input-search +Pass el-input-submit +Pass el-input-tel +Pass el-input-text +Pass el-input-url +Pass el-ins +Pass el-li-in-ul +Pass el-li-in-ol +Pass el-main +Pass el-mark +Pass el-menu +Pass el-meter +Pass el-nav +Pass el-ol +Pass el-option +Pass el-output +Pass el-p +Pass el-progress +Pass el-s +Pass el-search +Pass el-select-listbox +Pass el-strong +Pass el-sub +Pass el-sup +Pass el-time +Pass el-textarea +Pass el-ul +Pass el-img-alt-no-value +Pass el-img-empty-alt \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/html-aam/roles.html b/Tests/LibWeb/Text/input/wpt-import/html-aam/roles.html new file mode 100644 index 00000000000..e6dcc1a6495 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/html-aam/roles.html @@ -0,0 +1,209 @@ + + + + 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 -->

+ + + + +
x
+ +
x
+ + + + + + + +
x
+ + + + + + +x + + + + + + +
+
x
+ +
x
+
+ +x +
xx
+x + + + + + +
+ +
x
+
x
+
+ +x + +
x
+ +
x
x
+ +
+ + + +

x

+

x

+

x

+

x

+
x
+
x
+ + + + +

x

+
+ + + +x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +x + + + + + + + +
  1. x
  2. x
+ + +
x
+ +x + +
  • x
  • + +x + + + +
    1. x
    2. x
    + + + + + + +x +

    x

    + + + +x + + + + +x + + +x + + + + + + + + + + + +x + +x + +x + + + + + + + + + + + + + + + + + + + + + + +