Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Report should meet WCAG compliance #1427

Closed
smcclure15 opened this issue Jan 30, 2020 · 3 comments
Closed

HTML Report should meet WCAG compliance #1427

smcclure15 opened this issue Jan 30, 2020 · 3 comments
Assignees
Labels
Component: HTML Reporter Type: Bug Something isn't working right.
Milestone

Comments

@smcclure15
Copy link
Member

smcclure15 commented Jan 30, 2020

We'd like to use a tool like Axe to help lockdown WCAG rules for accessibility, but the QUnit page itself has some violations that we are forced to filter out. Ideally, yes, tests would only attempt to lockdown their particular widget/section, likely placed in the qunit-fixture, but this shouldn't be a limitation.

Aside from our specific intent, meeting these guidelines can independently benefit testing workflows with increased industry-standard accessibility.

Code that reproduces the problem:

<html>
<head>
  <link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.9.3.css">
</head>
<body>
  <div id="qunit"></div>
  <div id="qunit-fixture">
  <script src="https://code.jquery.com/qunit/qunit-2.9.3.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/axe-core/3.4.1/axe.min.js"></script>
  <script type="text/javascript">
    QUnit.test('Hello World', async assert => {
      await axe.run(document.body, (err, results) => {
        assert.equal(results.violations.length, 0);
        results.violations.forEach(v => {
          assert.notOk(v);
        })
      })
    })
  </script>
</body>
</html>

What did you expect to happen?

No violations to be found

What actually happened?

This currently finds 3 violations, failing the following rules:

  • color-contrast (impact: serious)
  • empty-heading (impact: minor)
  • link-name (impact: serious)

Checklist

See #1427 (comment)

@trentmwillis trentmwillis added Component: HTML Reporter good first issue Straight-forward to start and receive help with. Type: Bug Something isn't working right. labels Feb 5, 2020
@trentmwillis
Copy link
Member

Thanks for the report. I definitely agree that this should be fixed.

@Krinkle
Copy link
Member

Krinkle commented Aug 30, 2020

(Merged from #1469)


When scanning the default example at https://qunitjs.com/resources/example-index.html with the AXE tool in Firefox, there are a couple of issues detected currently. (Thanks to @zachleat for including these in Speedlify. We looked at similar tools in the past, but it's been years, and a ton of low-hanging fruit has crept in.)

  • QUnit 2.10.1
  • axe v4.5.3 (axe-core 3.5.5)

Most of these seem easy to fix:

  • 1) "Headings must not be empty", <h2 id="qunit-banner" class="qunit-pass"></h2>
  • Not sure why this is a heading. I think a presentational <div> might be more appropiate. (Never thought I'd say that!)
  • 2) "Document must have one main landmark", <html>
  • We're fairly constrained here, but as a quick fix we could add role="main" to <div id=qunit> at the same time as when we insert the UI.
  • 3) "All page content must be contained by landmarks" (9+ warnings)
  • This will mostly be obsoleted by point 2. Although we should add role="navigation" and/or or <nav> for qunit-toolbar.
  • 4) "Elements must have sufficient color contrast", <a …>Rerun</a>
  • This is pretty much invisible to everyone as far as I'm concerned. Needs to be much darker indeed.
  • 5) "Elements must have sufficient color contrast", <span class=runtime>3 ms</span>
  • Instead of the light blue tint it has today we can re-use the darker blue we already use for text elsewhere. There isn't really any semantic meaning being conveyed by this slightly brighter blue text so this would also reduce the overall color palette by one color.
  • 6) "Elements must have sufficient color contrast", #qunit-testresult-display
  • Same as point 5. Use the darker blue instead, perhaps the one we use for .test-name.
  • 7) "Elements must have sufficient color contrast", .module-name
  • Same as point 5. Use the darker blue instead, perhaps the one we use for .test-name. Here, the color distinction does currently convey meaning - to distinguish between module and test name. We could do that with bold/regular instead.
  • 8) " <html> element must have a lang attribute"
    • This is a tricky one. We could add lang="en" dir="ltr", which would be true for the test UI, but not per se about the content. Maybe leaving this undefined is best. Or perhaps we can set it on a subset of the UI where no user input is involved. Or perhaps it's worth to make it configurable, e.g. QUnit.config.userLang which we'd apply to all user-generated content?

@Krinkle Krinkle pinned this issue Aug 30, 2020
Krinkle pushed a commit that referenced this issue Dec 28, 2020
Krinkle pushed a commit that referenced this issue Dec 28, 2020
Fixes several WCAG violations (#1528).

Ref #1427.
Closes #1528.
Krinkle added a commit to Krinkle/qunit that referenced this issue Apr 10, 2021
Tweak our colors away from the semi-greyish colors we had before,
toward more dark/saturated or bright colors.

Also reduce the overall number of distinct colors, reusing the same
ones more often.

* Change most uses of black (`#000000`) to `#0D3349`, which is the
  very dark blue we already used for the `#qunit-header` background.

* Change the text color for `#qunit-testresult` from `#2B81AF` to
  that same very dark blue `#0D3349`. The text color previously used
  here was a medium blue that we didn't use for any other text.

* Change text in `#qunit .pass` from `#528CE0` to `#2F68DA`,
  this is more saturated and appears darker. I also moved its hue
  slightly from cyan-blue, more toward blue-violet.

* Change the Rerun link from the near-invisible `#C2CCD1` to instead
  inherit the text color of `#qunit .pass` or ``#qunit .fail`, e.g.
  `#2F68DA`. Also, to make it still stand out as special, add an
  underline. It retains its liberal padding for easy clickability.

Clean up:

* Remove unused color value for `#qunit-header`. Instead set it to that
  of `#qunit-header a` (it only contains a link), and let the latter
  inherit this color.

* Replace redundant `#qunit-tests .fail .test-name` and
  and `#qunit-tests .fail .module-name ` styles.

Ref qunitjs#1427.
Krinkle added a commit to Krinkle/qunit that referenced this issue Apr 10, 2021
Tweak our colors away from the semi-greyish colors we had before,
toward more dark/saturated or bright colors.

Also reduce the overall number of distinct colors, reusing the same
ones more often.

* Change most uses of black (`#000000`) to `#0D3349`, which is the
  very dark blue we already used for the `#qunit-header` background.

* Change the text color for `#qunit-testresult` from `#2B81AF` to
  that same very dark blue `#0D3349`. The text color previously used
  here was a medium blue that we didn't use for any other text.

* Change text in `#qunit .pass` from `#528CE0` to `#2F68DA`,
  this is more saturated and appears darker. I also moved its hue
  slightly from cyan-blue, more toward blue-violet.

* Change the Rerun link from the near-invisible `#C2CCD1` to instead
  inherit the text color of `#qunit .pass` or `#qunit .fail`, e.g.
  `#2F68DA`. Also, to make it still stand out as special, add an
  underline. It retains its liberal padding for easy clickability.

Clean up:

* Remove unused color value for `#qunit-header`. Instead set it to that
  of `#qunit-header a` (it only contains a link), and let the latter
  inherit this color.

* Replace redundant `#qunit-tests .fail .test-name` and
  and `#qunit-tests .fail .module-name ` styles.

Ref qunitjs#1427.
Krinkle added a commit to Krinkle/qunit that referenced this issue Apr 10, 2021
Tweak our colors away from the semi-greyish colors we had before,
toward more dark/saturated or bright colors.

Also reduce the overall number of distinct colors, reusing the same
ones more often.

* Change most uses of black (`#000000`) to `#0D3349`, which is the
  very dark blue we already used for the `#qunit-header` background.

* Change text in `#qunit .pass` from `#528CE0` to `#2F68DA`,
  this is more saturated and appears darker. I also moved its hue
  slightly from cyan-blue, more toward blue-violet.

* Change the text color for `#qunit-testresult` from `#3B81AF` to
  the same dark blue as used for module names, `#366097`. The color
  previously used here was a medium blue that we didn't use for any
  other text.

* Change the Rerun link from the near-invisible `#C2CCD1` to instead
  inherit the text color of `#qunit .pass` or `#qunit .fail`, e.g.
  `#2F68DA`. Also, to make it still stand out as special, add an
  underline. It retains its liberal padding for easy clickability.

Clean up:

* Remove unused color value for `#qunit-header`. Instead set it to that
  of `#qunit-header a` (it only contains a link), and let the latter
  inherit this color.

* Replace redundant `#qunit-tests .fail .test-name` and
  and `#qunit-tests .fail .module-name ` styles.

Ref qunitjs#1427.
Krinkle added a commit to Krinkle/qunit that referenced this issue Apr 11, 2021
Tweak our colors away from the semi-greyish colors we had before,
toward more dark/saturated or bright colors.

Also reduce the overall number of distinct colors, reusing the same
ones more often.

* Change most uses of black (`#000000`) to `#0D3349`, which is the
  very dark blue we already used for the `#qunit-header` background.

* Change text in `#qunit .pass` from `#528CE0` to `#2F68DA`,
  this is more saturated and appears darker. I also moved its hue
  slightly from cyan-blue, more toward blue-violet.

* Change the text color for `#qunit-testresult` from `#3B81AF` to
  the same dark blue as used for module names, `#366097`. The color
  previously used here was a medium blue that we didn't use for any
  other text.

* Change the Rerun link from the near-invisible `#C2CCD1` to instead
  inherit the text color of `#qunit .pass` or `#qunit .fail`, e.g.
  `#2F68DA`. Also, to make it still stand out as special, add an
  underline. It retains its liberal padding for easy clickability.

Clean up:

* Remove unused color value for `#qunit-header`. Instead set it to that
  of `#qunit-header a` (it only contains a link), and let the latter
  inherit this color.

* Replace redundant `#qunit-tests .fail .test-name` and
  and `#qunit-tests .fail .module-name ` styles.

Ref qunitjs#1427.
Krinkle added a commit to Krinkle/qunit that referenced this issue Apr 14, 2021
Tweak our colors away from the semi-greyish colors we had before,
toward more dark/saturated or bright colors.

Also reduce the overall number of distinct colors, reusing the same
ones more often.

* Change most uses of black (`#000000`) to `#0D3349`, which is the
  very dark blue we already used for the `#qunit-header` background.

* Change text in `#qunit .pass` from `#528CE0` to `#2F68DA`,
  this is more saturated and appears darker. I also moved its hue
  slightly from cyan-blue, more toward blue-violet.

* Change the text color for `#qunit-testresult` from `#3B81AF` to
  the same dark blue as used for module names, `#366097`. The color
  previously used here was a medium blue that we didn't use for any
  other text.

* Change the Rerun link from the near-invisible `#C2CCD1` to instead
  inherit the text color of `#qunit .pass` or `#qunit .fail`, e.g.
  `#2F68DA`. Also, to make it still stand out as special, add an
  underline. It retains its liberal padding for easy clickability.

Clean up:

* Remove unused color value for `#qunit-header`. Instead set it to that
  of `#qunit-header a` (it only contains a link), and let the latter
  inherit this color.

* Replace redundant `#qunit-tests .fail .test-name` and
  and `#qunit-tests .fail .module-name ` styles.

Ref qunitjs#1427.
Krinkle added a commit that referenced this issue Apr 14, 2021
Tweak our colors away from the semi-greyish colors we had before,
toward more dark/saturated or bright colors.

Also reduce the overall number of distinct colors, reusing the same
ones more often.

* Change most uses of black (`#000000`) to `#0D3349`, which is the
  very dark blue we already used for the `#qunit-header` background.

* Change text in `#qunit .pass` from `#528CE0` to `#2F68DA`,
  this is more saturated and appears darker. I also moved its hue
  slightly from cyan-blue, more toward blue-violet.

* Change the text color for `#qunit-testresult` from `#3B81AF` to
  the same dark blue as used for module names, `#366097`. The color
  previously used here was a medium blue that we didn't use for any
  other text.

* Change the Rerun link from the near-invisible `#C2CCD1` to instead
  inherit the text color of `#qunit .pass` or `#qunit .fail`, e.g.
  `#2F68DA`. Also, to make it still stand out as special, add an
  underline. It retains its liberal padding for easy clickability.

Clean up:

* Remove unused color value for `#qunit-header`. Instead set it to that
  of `#qunit-header a` (it only contains a link), and let the latter
  inherit this color.

* Replace redundant `#qunit-tests .fail .test-name` and
  and `#qunit-tests .fail .module-name ` styles.

Ref #1427.
@Krinkle Krinkle removed the good first issue Straight-forward to start and receive help with. label May 8, 2021
@Krinkle
Copy link
Member

Krinkle commented May 8, 2021

All points but one have been resolved and will be released shortly. The remaining point (H2 -> DIV, for the empty pixel banner) will be done in QUnit 3.

@Krinkle Krinkle added this to the 3.0 release milestone May 8, 2021
@Krinkle Krinkle unpinned this issue May 8, 2021
@Krinkle Krinkle self-assigned this Jul 1, 2024
Krinkle added a commit that referenced this issue Jul 1, 2024
There is no need for this presentational pixel bar to be a heading
element. It is completely a presentational thing that is better
represented with a DIV instead.

This previously produced the following accessiblity warning,
e.g. in Firefox's Accessibility inspector, or in Chrome with AXE.

> Headings must not be labeled.
>
> `Role: heading. "" [text label]`
>
> https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_WCAG/Text_labels_and_names

> Headings must not be empty.
>
> https://github.com/dequelabs/axe-core/blob/v4.9.1/doc/rule-descriptions.md
> https://act-rules.github.io/rules/ffd0e9

Fixes #1427.
@Krinkle Krinkle closed this as completed Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: HTML Reporter Type: Bug Something isn't working right.
Development

No branches or pull requests

3 participants