Skip to content

Commit

Permalink
fix: bug-705: cleanupPlugins() should not throw exception when no arg…
Browse files Browse the repository at this point in the history
…uments are provided (#709)
  • Loading branch information
lsiden authored Feb 13, 2018
1 parent 4498680 commit fb1d2f7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
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

0 comments on commit fb1d2f7

Please sign in to comment.