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

UltraBlame original commit: 2e5571db57132b0acd6a65e8baf83a2fc4d4ad5b
  • Loading branch information
marco-c committed Jun 16, 2023
1 parent 32c0200 commit 6037e64
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.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;
promise_test(async t => {
const expectedRole = el.getAttribute("data-expectedrole");


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;
promise_test(async t => {
const expectedLabel = el.getAttribute("data-expectedlabel");


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);


computedLabel = computedLabel.trim()

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

0 comments on commit 6037e64

Please sign in to comment.