diff --git a/wai-aria/META.yml b/wai-aria/META.yml index 864132a5a36c6d..25ab1c28495042 100644 --- a/wai-aria/META.yml +++ b/wai-aria/META.yml @@ -1,5 +1,6 @@ spec: https://w3c.github.io/aria/ suggested_reviewers: + - cookiecrook - halindrome - joanmarie - michael-n-cooper diff --git a/wai-aria/role/ReadMe.md b/wai-aria/role/ReadMe.md new file mode 100644 index 00000000000000..189c9f75eb8b60 --- /dev/null +++ b/wai-aria/role/ReadMe.md @@ -0,0 +1,16 @@ + +# WPT Roles Tests + +/wai-aria/roles/ includes various files broken up by test type + +- **roles.html** covers simple assignment/verification of most core WAI-ARIA roles, and includes a list of cross-references to other specific files and spec directories. +- role testing of *host language* implicit roles (E.g., `
-> main`) are in other directories (E.g., [html-aam](https://github.com/web-platform-tests/interop-2023-accessibility-testing/issues/13)) +- role testing of **ARIA extension specs** are in other directories (E.g., [graphics-aria](https://github.com/web-platform-tests/interop-2023-accessibility-testing/issues/9)) +- basic.html was the first to ensure basic test coverage of webdriver getcomputedrole +- other context-dependent role tests, error handling, and edge cases are covered in separate files + - list-roles.html + - region-roles.html + - grid, listbox, menu, tree, etc + - fallback roles + - invalid roles + - error handling, etc. diff --git a/wai-aria/role/basic.html b/wai-aria/role/basic.html index d371aa72dcba64..5cb838647015de 100644 --- a/wai-aria/role/basic.html +++ b/wai-aria/role/basic.html @@ -11,13 +11,13 @@

test heading

promise_test(async t => { const role = await test_driver.get_computed_role(document.getElementById('d')); - assert_true(role == "group"); + assert_equals(role, "group"); }, "tests explicit role"); promise_test(async t => { const role = await test_driver.get_computed_role(document.getElementById('h')); - assert_true(role == "heading"); + assert_equals(role, "heading"); }, "tests implicit role"); diff --git a/wai-aria/role/list-roles.html b/wai-aria/role/list-roles.html new file mode 100644 index 00000000000000..5d9787f04bfdcb --- /dev/null +++ b/wai-aria/role/list-roles.html @@ -0,0 +1,24 @@ + + + + List-related Role Verification Tests + + + + + + + + + +
+
x
+
x
+
+ + + + + \ No newline at end of file diff --git a/wai-aria/role/region-roles.html b/wai-aria/role/region-roles.html new file mode 100644 index 00000000000000..d087f8f69bd0a0 --- /dev/null +++ b/wai-aria/role/region-roles.html @@ -0,0 +1,25 @@ + + + + Region Role Verification Tests + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wai-aria/role/roles.html b/wai-aria/role/roles.html new file mode 100644 index 00000000000000..71946cbffa50de --- /dev/null +++ b/wai-aria/role/roles.html @@ -0,0 +1,137 @@ + + + + Simple Core ARIA Role Verification Tests + + + + + + + + + + + \ No newline at end of file diff --git a/wai-aria/scripts/aria-utils.js b/wai-aria/scripts/aria-utils.js new file mode 100644 index 00000000000000..41d8535f91be4d --- /dev/null +++ b/wai-aria/scripts/aria-utils.js @@ -0,0 +1,61 @@ +/* Utilities related to WAI-ARIA */ + +const AriaUtils = { + + /* + Tests simple role assignment:
x
+ Not intended for nested, context-dependent, or other complex role tests. + */ + assignAndVerifyRolesByRoleNames: function(roleNames) { + for (const role of roleNames) { + promise_test(async t => { + let el = document.createElement("div"); + el.appendChild(document.createTextNode("x")); + el.setAttribute("role", role); // el.role not yet supported by Gecko. + el.id = `role_${role}`; + document.body.appendChild(el); + const computedRole = await test_driver.get_computed_role(document.getElementById(el.id)); + assert_equals(computedRole, role, el.outerHTML); + }, `role: ${role}`); + } + }, + + /* + Tests computed role of all elements matching selector + against the string value of their data-role attribute. + + Ex:
+ + AriaUtils.verifyRolesBySelector(".ex") + + */ + verifyRolesBySelector: function(selector) { + const els = document.querySelectorAll(selector); + for (const el of els) { + let role = el.getAttribute("data-expectedrole"); + let testName = el.getAttribute("data-testname") || role; // data-testname optional if role unique per test file + promise_test(async t => { + const expectedRole = el.getAttribute("data-expectedrole"); + + // ensure ID existence and uniqueness for the webdriver callback + if (!el.id) { + let roleCount = 1; + let elID = `${expectedRole}${roleCount}`; + while(document.getElementById(elID)) { + roleCount++; + elID = `${expectedRole}${roleCount}`; + } + el.id = elID; + } + + const computedRole = await test_driver.get_computed_role(document.getElementById(el.id)); + assert_equals(computedRole, expectedRole, el.outerHTML); + }, `${testName}`); + } + }, + +}; +