GithubHelp home page GithubHelp logo

addyosmani / a11y Goto Github PK

View Code? Open in Web Editor NEW
1.7K 1.7K 91.0 42.01 MB

Accessibility audit tooling for the web (beta)

Home Page: http://addyosmani.github.io/a11y/

License: Apache License 2.0

JavaScript 53.26% HTML 46.74%

a11y's Introduction

  • πŸ”­ I’m currently working on Google Chrome
  • πŸ‘― I’m looking to collaborate on Developer Tooling
  • πŸ€” I’m looking for help with Framework collaborations
  • πŸ’¬ Ask me about anything
  • πŸ“« How to reach me: @addyosmani on Twitter

a11y's People

Contributors

adamc00 avatar addyosmani avatar arthurvr avatar attiks avatar d-reinhold avatar jrcryer avatar lucalanca avatar markreeder avatar matt-royal avatar robloach avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

a11y's Issues

Break the build for html fragments in gulp

I'd like to break the build using gulp-a11y when there are issues building html fragments into angular components in my favorite stack, because there are expected errors, per issue 50. Concretely, I'd like for these two tasks, for [components] and (https://github.com/doug-wade/example-koa-angular/blob/master/gulpfile.js#L41) views to fail, but currently I can only break the build for non-compliant views.

In this comment, you seem to allude to the idea of having a .allyrc file, similar to .babelrc or .eslintrc, while also which seems like a great solution. Something like

Β» a11y ./components/*.html --config .components.allyrc
Β» a11y  ./views/*.html

And be able to do the same with the gulp wrapper

var a11y = require('gulp-a11y');

gulp.task('components', function () {
  return gulp.src('./components/*.html')
    .pipe(a11y({
      config: '.components.allyrc' 
    }))
    .pipe(gulp.dest('dist'));
});

gulp.task('views', function () {
  return gulp.src('./views/*.html')
    .pipe(a11y()) // defaults to .allyrc
    .pipe(gulp.dest('dist'));
});

I'd be interested in implementing this feature.

Not working for me on static local files.

I'm trying to use a11y to audit a bunch of static source captures that were generated by using protractor (selenium) to crawl an AngularJs app and save the page source to file at various points. If I run "a11y google.com" I get an audit report back. However, if I try "a11y ./path/to/my/file.html" I get this error

Command failed: /usr/local/lib/node_modules/a11y/node_modules/phantomjs/lib/phantom/bin/phantomjs /usr/local/lib/node_modules/a11y/audits.js {"delay":1,"url":"file:///full/path/to/my/file.html","width":1024,"height":768} --ignore-ssl-errors=true --ssl-protocol=tlsv1 --local-to-remote-url-access=true
Audit failed

I've tried installing phantomjs multiple ways and I'm already successfully using phantomjs for unit testing without issue. I'm running node v0.12.0. Any idea what's going on?

Plans to use puppeteer?

Was going through the code and noticed webpage, are there any plans to use puppeteer instead?

option for evaluating html fragments

I'm interested in including an a11y check as part of our continuous integration checks, but on otherwise well-formed templates that aren't a complete document, I get these errors:

βœ– The web page should have the content's human language indicated in the markup

html

βœ– The web page should have a title that describes topic or purpose

html

While acknowledging that testing fragments of html isn't a complete solution, it would be helpful as a first pass on every commit. Ideally this would be exposed through the a11y command line option, so I could run something like:

a11y */.html --fragment-ok

Disable PhantomJS Redirects

Using something like the following will stall and error out PhantomJS, due to the URL redirect in the HTML.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="refresh" content="1;url=http://example.com">
    <link rel="canonical" href="http://example.com">
    <script>
        window.location.replace('http://example.com');
    </script>
</head>
<body>
    <p>This page has been moved <a href="http://example.com">here</a>.</p>
</body>
</html>

Inconsistent reporting for aria-labelledby on an input with type="tel"

I have this in a file called test.html:

<div>
    <label id="mobile-label" for="mobile">Mobile number</label>
    <input name="mobile"
        id="mobile"
        type="tel"
        aria-labelledby="mobile-label">
</div>
<div>
    <label id="firstname-label" for="firstname">Fornavn</label>
    <input name="firstname"
        id="firstname"
        type="text"
        aria-labelledby="firstname-label">
</div>

When I run a11y test.html the output is

Γ— This element has an unsupported ARIA attribute
#firstname

Expected output was

Γ— This element has an unsupported ARIA attribute
#mobile
#firstname

If I change from type="tel" to type="text" in the first field I get the expected output so it seems that either that ARIA attribute is supported for type="tel" or inputs with that type is not evaluated correctly.

This was observed with v0.3.3

What is the difference between a11y and pa11y

I've stumbled upon pa11y, and –apart from that it uses HTML CodeSniffer to generate an accessibility report instead of Chrome Accessibility Tools– it looks very similar.

So what would be the differences? And otherwise, are there features in there, which also could be valuable for a11y?

results contain lots of headings without content?

5 Passed Rules
ARIA state and property values must be valid
Controls and media elements should have labels
These elements are focusable but either invisible or obscured by another element
The purpose of each link should be clear from the link text
The web page should have a title that describes topic or purpose

suggest these would be better marked up as a list or even p's (no headings except for X passed Rules)

Configure number of elements per rule

Right now, the elements property of each audit result only contains the first 5 elements failing that rule. E.g.

  βœ– Images should have an alt attribute

  body > .container.ptl > .content > DIV:nth-of-type(2) > .exampleOutput > .gravatar.gravatar-sm > IMG
  body > .container.ptl > .content > DIV:nth-of-type(2) > .exampleOutput > DIV:nth-of-type(2) > IMG
  body > .container.ptl > .content > DIV:nth-of-type(3) > .exampleOutput > .gravatar.gravatar-sm > IMG
  body > .container.ptl > .content > DIV:nth-of-type(3) > .exampleOutput > .gravatar.gravatar-sm.mlxl > IMG
  body > .container.ptl > .content > DIV:nth-of-type(3) > .exampleOutput > DIV:nth-of-type(3) > IMG

We would like to not be limited by only seeing 5 elements. It would be cool if we could configure the max-number of elements displayed. E.g.

ally <url> --elements-per-rule=<count>

or

a11y(page, {elementsPerRule: 10}, function (err, reports) {
  /* ... */
});

Would you be open to a PR?

cc/ @gpleiss @matt-royal @stubbornella @ctaymor

Cannot find module 'chalk'

Howdy! This looks like an awesome tool, thank you!

I installed the module npm install -g a11y and it installed without issue.
However when I tried to run it: a11y http://www.google.com

I got the following:

module.js:340 throw err; ^ Error: Cannot find module 'chalk' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/usr/local/lib/node_modules/a11y/cli.js:7:13) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10)

I tried running npm cache clean which I found after a few google searches but it did not work.
Not sure if this is specific to me or is a wider problem.

Sorry to post an issue so quickly after you released it to the world!

glob patterns are not supported when using as a module

// file: test-a11y.js
const a11y = require('a11y');
const _glob = './src/**/*.html';
const options = {
    viewportSize: '800x600'
};

a11y(_glob, options, (err, reports) => {
    if (err) console.log(err);
    const audit = reports.audit; // `a11y` Formatted report
    const report = reports.report; // DevTools Accessibility Audit formatted report
});

The above file, when ran (node test-a11y.js), will always fail with the following error. Couldn't load url: "./src/**/*.html"

False positives on custom elements that do not appear with the Chrome extension

I'm working on implementing some custom elements for basic web design pattern like tabs ect... I am seeing a few errors that a11y is reporting that do not appear when auditing via the Chrome extension.

Β± a11y http://localhost:3000/

  βœ– Elements with ARIA roles must be in the correct scope

  CALCITE-TABS > .tab-nav

  βœ– Text elements should have a reasonable contrast ratio

  CALCITE-TABS > .tab-nav > A:nth-of-type(2)
  CALCITE-TABS > .tab-nav > A:nth-of-type(3)

  βœ– This element has an unsupported ARIA attribute

  CALCITE-TABS


  βœ” This element does not support ARIA roles, states and properties
  βœ” This element has an invalid ARIA attribute
  βœ” ARIA state and property values must be valid
  βœ” Elements with ARIA roles must use a valid, non-abstract ARIA role
  βœ” An element's ID must be unique in the DOM
  βœ” These elements are focusable but either invisible or obscured by another element
  βœ” The web page should have the content's human language indicated in the markup
  βœ” The purpose of each link should be clear from the link text
  βœ” Meaningful images should not be used in element backgrounds
  βœ” The web page should have a title that describes topic or purpose
  βœ” Elements with ARIA roles must have all required attributes for that role
  βœ” Elements with ARIA roles must ensure required owned elements are present
  βœ” Avoid positive integer values for tabIndex

calcite_ui_kit_kitchen_sink_and_calcite-web_js_-_users_patricklocal_code_calcite-web-atom_and_index_html-_users_patricklocal_code_calcite-web-ui-kit-_atom

Is this just a version mismatch?

Add --quiet option for error-only output

I'm running a11y on an entire folder of files from the command line. It would really help me if there was a way to only output errors. I'm thinking that if all the rules pass for a page, it would just log the page with a checkmark. Example output:

$ ally **/*.html

βœ” file1.html
βœ” file2.html
βœ– file3.html

  βœ– The purpose of each link should be clear from the link text

   body > .panel.panel-white.article.article-red > A

βœ” file4.html

Let me know if you'd be interested in a feature like this, happy to pr.

"role=main should only appear on significant elements"

Hey Team!

I just ran the a11y audit for a project I'm working on and got the following failure:
X role=main should only appear on significant elements

I have defined role=main only on my <main></main> element, which as far as I am aware is a fine practice to do.

After a little googling I found the following: https://groups.google.com/forum/#!topic/introduction-to-web-accessibility/ChGzBSe0_yU but after following the fix (updating my accessibility developer tools) nothing changed unfortunately.

Any idea what the problem might be?

Author unit tests

  • Test no input supplied
  • Test valid input supplied
  • Test valid local URL supplies expected report
  • Test valid remote URL supplies expected report
  • Test verbose output works

support for sitemap

I will probably write a script which reads a sitemap and checks all the non-external urls

The target is an implementation for a11y and pa11y.

Support auditing files on localhost

$ a11y http://localhost:3000/

undefined:1
TypeError: 'undefined' is not a function (evaluating 'document.querySelector.b
^
SyntaxError: Unexpected token T
    at Object.parse (native)
    at /Users/addyo/projects/a11y/index.js:23:23
    at ChildProcess.exithandler (child_process.js:635:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Socket.<anonymous> (child_process.js:956:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:465:12)

Similarly, this fails:

$ a11y http://192.168.1.105:3000

undefined:1
TypeError: 'undefined' is not a function (evaluating 'document.querySelector.b
^
SyntaxError: Unexpected token T
    at Object.parse (native)
    at /Users/addyo/projects/a11y/index.js:23:23
    at ChildProcess.exithandler (child_process.js:635:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Socket.<anonymous> (child_process.js:956:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:465:12)

Improve auditing for webapps

When using the Chrome Accessibility DevTools extension, pages such as this Angular Todo app will display severity issues that are not reported by A11y when conducting an audit.

Example:

vs:

My current theory is that we're not giving the page sufficient time to complete JS execution so not all content is present and in an auditable state.

After experimenting with adding a custom timeout (similar to this) and playing with timeouts of differing values, this doesn't appear to improve our ability to report back on such issues.

These issues aren't specific to this module (as far as I can tell). I've been able to repro the same with https://github.com/GoogleChrome/accessibility-developer-tools. Looking into this further.

PhantomJS Issues

I get the following error when trying to run the tests:

Command failed: /usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /usr/local/lib/node_modules/a11y/audits.js {"delay":1,"url":"http://bbc.co.uk","width":1024,"height":768} --ignore-ssl-errors=true --ssl-protocol=tlsv1 --local-to-remote-url-access=true
Audit failed

I got a similar error on initial install so I manually installed PhantomJS but still can't get any test to work.

Team feedback

Sindre Sorhus
Addy: nice!
Re notifier; insane. Chalk also has insane amounts of downloads.
Sindre β€’ Sun, 10:24 PM
Sindre Sorhus
Addy: You can use https://github.com/sindresorhus/log-symbols to get the colored symbols with windows fallbacks. I would only have the symbols colored so not to be distracting. Could be interesting to maybe have stats through https://github.com/yeoman/insight on which are the most popular violations. I would also include links to more information about the violations and how to fix. Will have more feedback when I see the code πŸ˜‰
Sindre β€’ Sun, 10:45 PM
All good suggestions :) Thanks Sindre! I was curious about windows fallbacks so the first link is def getting used.
12:10 AM
Addy Osmani
Sindre Sorhus
If you only need symbols I have a module with a bunch of symbols that have windows equivalent fallbacks: https://github.com/sindresorhus/figures/blob/master/index.js

run checks against index.slim ?

I'm trying to run checks for pages using https://github.com/slim-template/slim
Is it possible?

find . -name "index.slim" | xargs a11y

Command failed: /usr/local/bin/phantomjs /usr/local/lib/node_modules/a11y/audits.js {"delay":1,"url":"file:///~/app/views/.../index.slim","width":1024,"height":768} --ignore-ssl-errors=true --ssl-protocol=tlsv1 --local-to-remote-url-access=true
Couldn't load url: "file:///~/app/views/.../index.slim"

ERR_INVALID_ARG_TYPE

Just tried to install a11y to play around with it a little, but could not get anything to run, as soon as I try a11y <url> I get the following error:

child_process.js:397
    throw new ERR_INVALID_ARG_TYPE('file', 'string', file);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object
    at normalizeSpawnArguments (child_process.js:397:11)
    at spawn (child_process.js:522:38)
    at execFile (child_process.js:218:15)
    at module.exports (/<path>/.nvm/versions/node/v10.4.1/lib/node_modules/a11y/index.js:33:5)
    at Immediate.eachAsync (/<path>/.nvm/versions/node/v10.4.1/lib/node_modules/a11y/cli.js:43:5)
    at runCallback (timers.js:697:11)
    at tryOnImmediate (timers.js:667:5)
    at processImmediate (timers.js:649:5)

On OS X with node 10.4.1.

Any idea what could go wrong here?

Network timeout on resource

I am getting network timeout on resource when I am trying to run a11y through command line.
What is the parameter I need to set to solve this???

Error:
C:\workspace\a11y>a11y http://localhost:4200
Command failed: C:\Users\dkuma172\AppData\Roaming\npm\node_modules\a11y\node_modules\phantomjs-prebuilt\lib\phantom\bin\phantomjs.exe C:\Users\dkuma172\AppData
Roaming\npm\node_modules\a11y\audits.js {"delay":1,"url":"http://localhost:4200"
,"width":1024,"height":768} --ignore-ssl-errors=true --ssl-protocol=tlsv1 --local-to-remote-url-access=true
Error code:408 Network timeout on resource. for http://localhost:4200/vendor.bundle.js

Contrast ratio test fails on background gradients

When the test runs on pages with a gradient as a background, the background is evaluated as #ffffff. If the text colour happens to be too light β€”or white as wellβ€” the test obviously fails with:

Text elements should have a reasonable contrast ratio

It would probably be a good idea to pick the lightest of the gradient colours and run the test on that one instead, or on each colour separately.

Show total number of elements violating a rule

Somewhat related to #40

Right now, the results look like there are only 5 elements violation a given rule, and it is a bit misleading.

  βœ– Images should have an alt attribute

  body > .container.ptl > .content > DIV:nth-of-type(2) > .exampleOutput > .gravatar.gravatar-sm > IMG
  body > .container.ptl > .content > DIV:nth-of-type(2) > .exampleOutput > DIV:nth-of-type(2) > IMG
  body > .container.ptl > .content > DIV:nth-of-type(3) > .exampleOutput > .gravatar.gravatar-sm > IMG
  body > .container.ptl > .content > DIV:nth-of-type(3) > .exampleOutput > .gravatar.gravatar-sm.mlxl > IMG
  body > .container.ptl > .content > DIV:nth-of-type(3) > .exampleOutput > DIV:nth-of-type(3) > IMG

The google accessibility audit outputs the total number of elements by each rule (e.g. (1 - 5 of 30)). It would be nice if a11y included this in the output as well.

  βœ– Images should have an alt attribute (1 -5 of 30)
...

Similarly, the API could have a numElements property

{
  elements: '\nbody > .container.ptl > .content > .section-nav > LI > A\n...',
  numElements: 30,
  heading: 'Text elements should have a reasonable contrast ratio',
  result: 'FAIL',
  severity: 'Warning' 
}

Would you be open to a PR?

cc/ @gpleiss, @matt-royal, @stubbornella, @ctaymor

Audit skips over React components/Phantom JS woes

We ran the audit against this page: http://reddizen.com/r/aww/3e7xu3/domain/imgur.com

The cat image in the right panel - which does not have an alt tag - is added via React. If we run the ADT runner on this page in the browser, it catches the lack of alt tag on the cat image. However, when we run a11y, it doesn't catch this. We tried similar tests on other react sites, and most of the time a11y didn't catch errors on (non-server-side-rendered) React elements.

We figured out that the issue is PhantomJS. We modified our local version of a11y to use the system version of Phantom JS (version 2.0.0) instead of the node_module version (version 1.9.x) and then a11y caught all accessibility errors on React components. πŸ˜’

Unfortunately, since there is no node_module for Phantom 2, we can't really provide a fix for all users. However, as a (hopefully) temporary solution, we would like to be able to customize the headless browser that a11y runs on. Ideally, we'd like to run a11y with SlimerJS. SlimerJS caught all errors for our React components.

Does this sound good? Open to a PR?

cc/ @kennyw12 @ctaymor @matt-royal @stubbornella

contrast of some text insufficient

example: code in error (tested http://google.com)

pmocntr2 > TABLE > TBODY > TR:nth-of-type(2) > .padi > IMG

Foreground:#999999 Background:#FFFFFF
The contrast ratio is: 2.85:1
Text failed at Level AA
WCAG 2.0 SC 1.4.3 Contrast (Minimum): The visual presentation of text and images of text has a contrast ratio of at least 4.5:1, except for the following: (Level AA) Large Print: Large-scale text and images of large-scale text have a contrast ratio of at least 3:1;

reports is not parseable as JSON via Javascript API

Judging from the a11y docs the following should be possible:

var a11y = require('a11y');
a11y("http://www.google.com", function (err, reports) {
    JSON.parse(reports);
});

However, this causes an error Unexpected token o.

Looking at the raw reports string it is not valid JSON - it's missing quotes around field names and also uses single-quotes; i.e.:

{ audit:
   [ { elements: '',
       heading: 'Audio elements should have controls',
       result: 'NA',
       severity: 'Warning' },
    ...]
}         

Or am I missing something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.