Skip to content

Commit

Permalink
Bug 1837038 [wpt PR 39724] - refactor aria-utils to remove unnecessar…
Browse files Browse the repository at this point in the history
…y ID usage, a=testonly

Automatic update from web-platform-tests
refactor aria-utils to remove unnecessary ID usage (#39724)

Resolves web-platform-tests/interop-accessibility#29

Refactors aria-utils to remove unnecessary ID usage.
--

wpt-commits: 886b8496dcfb6f9489f57867a1767eee244414f8
wpt-pr: 39724
  • Loading branch information
cookiecrook authored and moz-wptsync-bot committed Jun 13, 2023
1 parent 70d4f19 commit 45be5a8
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions testing/web-platform/tests/wai-aria/scripts/aria-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ const AriaUtils = {
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));
const computedRole = await test_driver.get_computed_role(el);
assert_equals(computedRole, role, el.outerHTML);
}, `role: ${role}`);
}
Expand Down Expand Up @@ -49,19 +48,7 @@ const AriaUtils = {
let testName = el.getAttribute("data-testname") || role; // data-testname optional if role is 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));
const computedRole = await test_driver.get_computed_role(el);
assert_equals(computedRole, expectedRole, el.outerHTML);
}, `${testName}`);
}
Expand Down Expand Up @@ -90,23 +77,9 @@ const AriaUtils = {
let testName = el.getAttribute("data-testname") || label; // data-testname optional if label is unique per test file
promise_test(async t => {
const expectedLabel = el.getAttribute("data-expectedlabel");

// ensure ID existence and uniqueness for the webdriver callback
if (!el.id) {
let labelCount = 1;
let elID = `labelTest${labelCount}`;
while(document.getElementById(elID)) {
labelCount++;
elID = `labelTest${labelCount}`;
}
el.id = elID;
}

let computedLabel = await test_driver.get_computed_label(el);

// Todo: Remove whitespace normalization after https://github.com/w3c/accname/issues/192 is addressed. Change prior line back to `const`, too.
computedLabel = computedLabel.trim()

assert_equals(computedLabel, expectedLabel, el.outerHTML);
}, `${testName}`);
}
Expand Down

0 comments on commit 45be5a8

Please sign in to comment.