Skip to content

Commit

Permalink
Add null-check to aria_utils verifyLabelsBySelector (#44361)
Browse files Browse the repository at this point in the history
* Add null-check to aria_utils verifyLabelsBySelector

Before this commit, verifyLabelsBySelector calls test_driver.get_computed_label
and then does string-manipulation on the result. For some reason, this
get_computed_label invocation returns null in Firefox, and so the
string-manipulation causes a JS exception to be thrown, which makes for awkward
test failure results.

Let's just explicitly assert that the result is not-null, to make that
expectation clearer and to give a cleaner test-failure in cases where it is
unexpectedly null.
  • Loading branch information
dholbert authored and marcoscaceres committed Feb 23, 2024
1 parent 726547e commit 4e1476d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions wai-aria/scripts/aria-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const AriaUtils = {
promise_test(async t => {
const expectedLabel = el.getAttribute("data-expectedlabel");
let computedLabel = await test_driver.get_computed_label(el);
assert_not_equals(computedLabel, null, `get_computed_label(el) shouldn't return null for ${el.outerHTML}`);

// See:
// - https://github.com/w3c/accname/pull/165
Expand Down

0 comments on commit 4e1476d

Please sign in to comment.