Skip to content

Commit

Permalink
Merged in merge-from-github (pull request #93)
Browse files Browse the repository at this point in the history
chore: merged changes from GitHub
  • Loading branch information
dylanb committed Nov 30, 2016
2 parents 4da19ef + e8114de commit dd797c9
Show file tree
Hide file tree
Showing 18 changed files with 396 additions and 85 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ axe.min.js
axe.es2016.js
*.tgz
npm-shrinkwrap.json
typings/axe-core/axe-core-tests.js
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ lib
test
*.tgz
bower.json
typings/axe-core
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ node_js:
- '4'
- '5'
before_install:
- npm install -g grunt-cli
- npm install
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
script:
- grunt test
- npm test
env:
global:
- secure: qjMwfcWDzEhGWxVhmGi5s0MlsU4N/SI96mx6Gj36/GySxgIUU9EFXeN4SZS2OvRmy2/+l0XSt5ln9PWp4Suh2LM8/GaR5I6FALs/9rOLU9py0/G9V1ImqNN9Z6Nk6PvS71SAwP7xOtR+xsywnUEdHZ7dCA3fYEIsOkyq4KRQ9M7JHWogP+h+WsHPcznjPeNxVBCfYCXW0KhrLDzL4ZA+b2UY/IMZDXITdZ99TZQA6XSKTfJg3xs/jqXEo91igHNKN6VxappBqPbDiFxf7az1RExq3oHAawCDTaKE7xxip+6UIxAeo63tiM0vgp92HVrVsIQETSQFBP4aqhl/pfxQ7d9lto7Mz5AlxKvJ3CIwDD/hspPzG5SNrj/FgQLgK7LrUOomMOjf8giRUg8XXLe7Rb1jmbePP3Z9DIEg4Z+ar3dpC2dNiWYFwBM14wY39GuU6tJpzImGRRUGCMPiO55TVTdRZacVeIq1XWRecIH0CabZThJCwOxyiGIT5ETiT5CVs0CgnbVe99l1qyi8wrMnbw4m4UAlMQ/5kytqtsL957RwxvcctCtX+LlshAgC3m1Aq/aF8V/wIYDcRlwOY2HbGiFQJewV7Aeln3t/S8VFjP9hHn8ZTsH9ez3VB57Q53YgrxFCr6CXEK4X3dkmRpx9in3oDI51TxW32tInwGTukSg=
Expand Down
32 changes: 32 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,35 @@ To build the package:
```
grunt build
```

## Using aXe with TypeScript

### aXe Development

The TypeScript definition file for axe-core is distributed with this module [axe.d.ts](./axe.d.ts). It currently supports TypeScript 2.0+.

To maintain aXe support for TypeScript you must first install it (globally recommended):
```
sudo npm -g install typescript
```

Once that's installed, you can run TypeScript definition tests (with the optional `--noImplicitAny` flag):
```
tsc --noImplicitAny typings/axe-core/axe-core-tests.ts
```

## Including aXe's type definition in tests

Installing aXe to run accessibility tests in your TypeScript project should be as simple as importing the module:

```javascript
import * as axe from 'axe-core';

describe('Module', () => {
it('should have no accessibility violations', () => {
axe.a11yCheck(compiledFixture, {}, (results) => {
expect(results.violations.length).toBe(0);
});
});
});
```
7 changes: 4 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-snyk');
grunt.loadTasks('build/tasks');
grunt.loadNpmTasks('grunt-parallel');

Expand Down Expand Up @@ -282,14 +283,14 @@ module.exports = function (grunt) {

grunt.registerTask('default', ['build']);

grunt.registerTask('build', ['clean', 'validate', 'concat:commons', 'configure',
grunt.registerTask('build', ['clean', 'jshint', 'validate', 'snyk', 'concat:commons', 'configure',
'babel', 'concat:engine', 'uglify']);

grunt.registerTask('test', ['build', 'testconfig', 'fixture', 'connect',
'mocha', 'parallel', 'jshint']);
'mocha', 'parallel']);

grunt.registerTask('test-fast', ['build', 'testconfig', 'fixture', 'connect',
'mocha', 'jshint']);
'mocha']);

grunt.registerTask('dev', ['build', 'testconfig', 'fixture', 'connect', 'watch']);
};
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ We believe that automated testing has an important role to play in achieving dig

## Manifesto

1. Automated accessibility testing rules must have a zero false positive rate
1. Automated accessibility testing rules must have a zero false-positive rate
2. Automated accessibility testing rules must be lightweight and fast
3. Automated accessibility testing rules must work in all modern browsers
4. Automated accessibility testing rules must, themselves, be tested automatically
Expand All @@ -44,15 +44,15 @@ First download the package:
npm install axe-core --save-dev
```

Now include the javascript file in each of your iframes in you fixtures or test systems:
Now include the javascript file in each of your iframes in your fixtures or test systems:

```html
<script src="node_modules/axe-core/axe.min.js" ></script>
```

Now insert calls at each point in your tests where a new piece of UI becomes visible or exposed:

```
```js
axe.run(function (err, results) {
if (err) throw err;
ok(results.violations.length === 0, 'Should be no accessibility issues');
Expand All @@ -77,7 +77,7 @@ The complete list of rules run by axe-core can be found in [doc/rule-description

The [aXe API](doc/API.md) package consists of:

* `axe.js` - the javascript file that should be included in your web site under test (API)
* `axe.js` - the JavaScript file that should be included in your web site under test (API)
* `axe.min.js` - a minified version of the above file


Expand Down
165 changes: 165 additions & 0 deletions axe.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
// Type definitions for axe-core 2.0.8
// Project: https://github.com/dequelabs/axe-core
// Definitions by: Marcy Sutton <https://github.com/marcysutton>

declare module axe {

export type ImpactValue = "minor" | "moderate" | "serious" | "critical";

export type TagValue = "wcag2a" | "wcag2aa" | "section508" | "best-practice";

export type ReporterVersion = "v1" | "v2";

export type RunOnlyType = "rule" | "rules" | "tag" | "tags";

export interface ElementContext {
node?: Object,
selector?: string,
include?: any[],
exclude?: any[]
}
export interface RunOnly {
type: RunOnlyType,
value?: {
include?: string[],
exclude?: string[]
}
values?: TagValue[]
}
export interface AxeResults {
url: string,
timestamp: string,
passes: Pass[],
violations: Violation[]
}
export interface Pass {
description: string,
help: string,
helpUrl: string,
id: string,
impact: ImpactValue,
tags: TagValue[],
nodes: NodeResult[]
}
export interface Violation {
description: string,
help: string,
helpUrl: string,
id: string,
impact: ImpactValue,
tags: TagValue[],
nodes: NodeResult[]
}
export interface NodeResult {
html: string,
impact: ImpactValue,
target: string[],
any: CheckResult[],
all: CheckResult[],
none: CheckResult[]
}
export interface CheckResult {
id: string,
impact: string,
message: string,
data: any,
relatedNodes?: RelatedNode[]
}
export interface RelatedNode {
target: string[],
html: string
}
export interface Spec {
branding?: {
brand: string,
application: string
},
reporter?: ReporterVersion,
checks?: Check[],
rules?: Rule[]
}
export interface Check {
id: string,
evaluate: Function,
after?: Function,
options?: any,
matches?: string,
enabled?: boolean
}
export interface Rule {
id: string,
selector?: string,
excludeHidden?: boolean,
enabled?: boolean,
pageLevel?: boolean,
any?: string[],
all?: string[],
none?: string[],
tags?: string[],
matches?: string
}
export interface AxePlugin {
id: string,
run(...args:any[]): any,
commands: {
id: string,
callback(...args:any[]): void
}[],
cleanup?(callback:Function): void
}

export let plugins: any

/**
* Source string to use as an injected script in Selenium
*/
export let source: string

/**
* Object for aXe Results
*/
export var AxeResults: AxeResults

/**
* Starts analysis on the current document and its subframes
*
* @param {Object} context The `Context` specification object @see Context
* @param {Array} options Options passed into rules or checks, temporarily modifyint them.
* @param {Function} callback The function to invoke when analysis is complete.
* @returns {Object} results The aXe results object
*/
export function a11yCheck(context: ElementContext, options: {runOnly?: RunOnly, rules?: Object}, callback: (results:AxeResults) => void): AxeResults

/**
* Method for configuring the data format used by aXe. Helpful for adding new
* rules, which must be registered with the library to execute.
* @param {Spec} Spec Object with valid `branding`, `reporter`, `checks` and `rules` data
*/
export function configure(spec: Spec): void

/**
* Searches and returns rules that contain a tag in the list of tags.
* @param {Array} tags Optional array of tags
* @return {Array} Array of rules
*/
export function getRules(tags?: string[]): Object[]

/**
* Restores the default axe configuration
*/
export function reset(): void

/**
* Function to register a plugin configuration in document and its subframes
* @param {Object} plugin A plugin configuration object
*/
export function registerPlugin(plugin: AxePlugin): void

/**
* Function to clean up plugin configuration in document and its subframes
*/
export function cleanup(): void

}

export = axe;
4 changes: 2 additions & 2 deletions doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ axe.run(document, function(err, results) {
* `passes[0]`
...
* `help` - `"Elements must have sufficient color contrast"`
* `helpURL` - `"https://dequeuniversity.com/courses/html-css/visual-layout/color-contrast"`
* `helpUrl` - `"https://dequeuniversity.com/courses/html-css/visual-layout/color-contrast"`
* `id` - `"color-contrast"`
* `nodes`
* `target[0]` - `"#js_off-canvas-wrap > .inner-wrap >.kinja-title.proxima.js_kinja-title-desktop"`
Expand All @@ -484,7 +484,7 @@ axe.run(document, function(err, results) {

* `violations[0]`
* `help` - `"<button> elements must have alternate text"`
* `helpURL` - `"https://dequeuniversity.com/courses/html-css/forms/form-labels#id84_example_button"`
* `helpUrl` - `"https://dequeuniversity.com/courses/html-css/forms/form-labels#id84_example_button"`
* `id` - `"button-name"`
* `nodes`
* `target[0]` - `"post_5919997 > .row.content-wrapper > .column > span > iframe"`
Expand Down
6 changes: 5 additions & 1 deletion doc/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ Add your project/integration to this file and submit a pull request.
11. [ReactJS Accessibility Checker](https://github.com/dylanb/react-axe) (react-axe)
12. [Vorlon.js Remote Debugger](https://github.com/MicrosoftDX/Vorlonjs)
13. [Selenium IDE aXe Extension](https://github.com/bkardell/selenium-ide-axe)
14. [gulp-axe-core](https://www.npmjs.com/package/gulp-axe-core)
14. [gulp-axe-webdriver](https://github.com/felixzapata/gulp-axe-webdriver)
15. [AccessLint](https://github.com/accesslint/accesslint.js)
16. [Lighthouse](https://github.com/GoogleChrome/lighthouse)
17. [Axegrinder](https://github.com/claflamme/axegrinder)
18. [Ghost-Axe](https://www.npmjs.com/package/ghost-axe)
Loading

0 comments on commit dd797c9

Please sign in to comment.