Add null-check to aria_utils verifyLabelsBySelector (#44361)
* 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.
diff --git a/wai-aria/scripts/aria-utils.js b/wai-aria/scripts/aria-utils.js
index 9daee1b..ec53464 100644
--- a/wai-aria/scripts/aria-utils.js
+++ b/wai-aria/scripts/aria-utils.js
@@ -144,6 +144,7 @@
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