();
+ // https://w3c.github.io/html-aam/#el-td
+ // https://w3c.github.io/html-aam/#el-th/
+ // (ancestor table element has table role)
+ if (table_element->role_or_default() == ARIA::Role::table)
+ return ARIA::Role::cell;
+ // https://w3c.github.io/html-aam/#el-td-gridcell
+ // https://w3c.github.io/html-aam/#el-th-gridcell
+ // (ancestor table element has grid or treegrid role)
+ if (first_is_one_of(table_element->role_or_default(), ARIA::Role::grid, ARIA::Role::gridcell))
+ return ARIA::Role::gridcell;
return {};
}
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html-aam/table-roles.txt b/Tests/LibWeb/Text/expected/wpt-import/html-aam/table-roles.txt
new file mode 100644
index 00000000000..ee75a8ab898
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html-aam/table-roles.txt
@@ -0,0 +1,12 @@
+Harness status: OK
+
+Found 7 tests
+
+7 Pass
+Pass el-table
+Pass el-caption
+Pass el-tr-thead
+Pass el-th
+Pass el-tr-tbody
+Pass el-th-in-row
+Pass el-td
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/wai-aria/role/table-roles.txt b/Tests/LibWeb/Text/expected/wpt-import/wai-aria/role/table-roles.txt
new file mode 100644
index 00000000000..6111915e656
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/wai-aria/role/table-roles.txt
@@ -0,0 +1,14 @@
+Harness status: OK
+
+Found 9 tests
+
+9 Pass
+Pass div role is caption (in div with table role)
+Pass orphan p role is caption
+Pass span role is cell (in div with row role, in div with rowgroup role, in div with table role)
+Pass orphan span role is cell
+Pass span role is columnheader (in div with row role, in div with rowgroup role, in div with table role)
+Pass div role is row (in div with rowgroup role, in div with table role)
+Pass div role is rowgroup (in div with table role)
+Pass role is rowheader (in div with row role, in div with rowgroup role, in div with table role)
+Pass div role is table
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/html-aam/table-roles.html b/Tests/LibWeb/Text/input/wpt-import/html-aam/table-roles.html
new file mode 100644
index 00000000000..9ed64cd4f39
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html-aam/table-roles.html
@@ -0,0 +1,53 @@
+
+
+
+ HTML-AAM Role Verification Tests
+
+
+
+
+
+
+
+
+
+Tests the computedrole mappings for the table-related roles defined in HTML-AAM. Most test names correspond to unique ID defined in the spec.
+
+
+
+
+ caption
+
+
+ a |
+ b |
+ c |
+
+
+
+
+ 1 |
+ 2 |
+ 3 |
+
+
+ 4 |
+ 5 |
+ 6 |
+
+
+
+
+ x |
+ y |
+ z |
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/wai-aria/role/table-roles.html b/Tests/LibWeb/Text/input/wpt-import/wai-aria/role/table-roles.html
new file mode 100644
index 00000000000..9ce6b330349
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/wai-aria/role/table-roles.html
@@ -0,0 +1,148 @@
+
+
+
+ Table Role Verification Tests
+
+
+
+
+
+
+
+
+ Tests table and related roles.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ x
+
+
+
+
+ x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ x
+ x
+
+
+ x
+ x
+
+
+
+
+
+
+
\ No newline at end of file