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

Provide default arguments to axe.cleanup() #709

Merged
merged 1 commit into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,18 @@ Register a plugin with the aXe plugin system. See [implementing a plugin](plugin

### API Name: axe.cleanup

Call the plugin system's cleanup function. See [implementing a plugin](plugins.md).
Call each plugin's cleanup function. See [implementing a plugin](plugins.md).

The signature is:

```
axe.cleanup(resolve, reject)
```

`resolve` and `reject` are functions that will be invoked on success or failure respectively.

`resolve` takes no arguments and `reject` takes a single argument that must be a string or have a toString() method in its prototype.


### API Name: axe.a11yCheck

Expand Down
5 changes: 4 additions & 1 deletion lib/core/public/cleanup-plugins.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

function cleanupPlugins(resolve, reject) {
'use strict';
'use strict';
resolve = resolve || function() {};
reject = reject || axe.log;

if (!axe._audit) {
throw new Error('No audit configured');
}
Expand Down
24 changes: 24 additions & 0 deletions test/core/public/cleanup-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,30 @@ describe('cleanupPlugins', function () {
});


it('should not throw exception if no arguments are provided', function(done) {
var cleaned = false;
axe._load({
rules: []
});
axe.registerPlugin({
id: 'p',
run: function () {},
add: function (impl) {
this._registry[impl.id] = impl;
},
commands: []
});
axe.plugins.p.cleanup = function (res) {
cleaned = true;
res();
};
assert.doesNotThrow(function () {
cleanupPlugins();
done();
});
});


it('should send command to frames to cleanup', function (done) {
createFrames(function () {
axe._load({});
Expand Down