Skip to content

Commit

Permalink
Merge pull request #2792 from dequelabs/release-4.1.2
Browse files Browse the repository at this point in the history
Release 4.1.2
  • Loading branch information
WilcoFiers authored Feb 9, 2021
2 parents 7da2c51 + f8c0c21 commit 11a514d
Show file tree
Hide file tree
Showing 23 changed files with 596 additions and 340 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [4.1.2](https://github.com/dequelabs/axe-core/compare/v4.1.1...v4.1.2) (2021-02-08)

### Bug Fixes

- add noHtml to axe.configure ([#2789](https://github.com/dequelabs/axe-core/issues/2789)) ([6e23eb0](https://github.com/dequelabs/axe-core/commit/6e23eb0839da5806da5476a5158fb6324d3ee005))
- do not allow postMessage with axe version of x.y.z ([#2790](https://github.com/dequelabs/axe-core/issues/2790)) ([8b1671d](https://github.com/dequelabs/axe-core/commit/8b1671d46dd2238284fbfe1448ef36f8fc2048e7))

### [4.1.1](https://github.com/dequelabs/axe-core/compare/v4.1.0...v4.1.1) (2020-11-19)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "axe-core",
"version": "4.1.1",
"version": "4.1.2",
"contributors": [
{
"name": "David Sturley",
Expand Down
24 changes: 13 additions & 11 deletions doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,18 @@ User specifies the format of the JSON structure passed to the callback of `axe.r

```js
axe.configure({
branding: {
brand: String,
application: String
},
reporter: 'option' | Function,
checks: [Object],
rules: [Object],
standards: Object,
locale: Object,
axeVersion: String,
disableOtherRules: Boolean
branding: {
brand: String,
application: String
},
reporter: 'option' | Function,
checks: [Object],
rules: [Object],
standards: Object,
locale: Object,
axeVersion: String,
disableOtherRules: Boolean,
noHtml: Boolean
});
```

Expand Down Expand Up @@ -232,6 +233,7 @@ axe.configure({
- `disableOtherRules` - Disables all rules not included in the `rules` property.
- `locale` - A locale object to apply (at runtime) to all rules and checks, in the same shape as `/locales/*.json`.
- `axeVersion` - Set the compatible version of a custom rule with the current axe version. Compatible versions are all patch and minor updates that are the same as, or newer than those of the `axeVersion` property.
- `noHtml` - Disables the HTML output of nodes from rules.

**Returns:** Nothing

Expand Down
4 changes: 3 additions & 1 deletion lib/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function getDefaultConfiguration(audit) {
}

config.reporter = config.reporter || null;
config.noHtml = config.noHtml || false;
config.rules = config.rules || [];
config.checks = config.checks || [];
config.data = { checks: {}, rules: {}, ...config.data };
Expand Down Expand Up @@ -298,6 +299,7 @@ class Audit {
this.brand = 'axe';
this.application = 'axeAPI';
this.tagExclude = ['experimental'];
this.noHtml = audit.noHtml;
unpackToObject(audit.rules, this, 'addRule');
unpackToObject(audit.checks, this, 'addCheck');
this.data = {};
Expand All @@ -323,7 +325,7 @@ class Audit {
if (spec.metadata) {
this.data.rules[spec.id] = spec.metadata;
}
let rule = this.getRule(spec.id);
const rule = this.getRule(spec.id);
if (rule) {
rule.configure(spec);
} else {
Expand Down
18 changes: 11 additions & 7 deletions lib/core/public/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ function configure(spec) {
}

if (spec.axeVersion || spec.ver) {
let specVersion = spec.axeVersion || spec.ver;
const specVersion = spec.axeVersion || spec.ver;
if (!/^\d+\.\d+\.\d+(-canary)?/.test(specVersion)) {
throw new Error(`Invalid configured version ${specVersion}`);
}

let [version, canary] = specVersion.split('-');
let [major, minor, patch] = version.split('.').map(Number);
const [version, canary] = specVersion.split('-');
const [major, minor, patch] = version.split('.').map(Number);

let [axeVersion, axeCanary] = axe.version.split('-');
let [axeMajor, axeMinor, axePatch] = axeVersion.split('.').map(Number);
const [axeVersion, axeCanary] = axe.version.split('-');
const [axeMajor, axeMinor, axePatch] = axeVersion.split('.').map(Number);

if (
major !== axeMajor ||
Expand Down Expand Up @@ -49,7 +49,7 @@ function configure(spec) {
throw new TypeError('Checks property must be an array');
}

spec.checks.forEach(function(check) {
spec.checks.forEach(check => {
if (!check.id) {
throw new TypeError(
// eslint-disable-next-line max-len
Expand All @@ -69,7 +69,7 @@ function configure(spec) {
throw new TypeError('Rules property must be an array');
}

spec.rules.forEach(function(rule) {
spec.rules.forEach(rule => {
if (!rule.id) {
throw new TypeError(
// eslint-disable-next-line max-len
Expand Down Expand Up @@ -110,6 +110,10 @@ function configure(spec) {
if (spec.standards) {
configureStandards(spec.standards);
}

if (spec.noHtml) {
audit.noHtml = true;
}
}

export default configure;
10 changes: 8 additions & 2 deletions lib/core/utils/dq-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ function DqElement(element, options, spec) {
* The generated HTML source code of the element
* @type {String}
*/
this.source =
this.spec.source !== undefined ? this.spec.source : getSource(element);
// TODO: es-modules_audit
if (axe._audit && axe._audit.noHtml) {
this.source = null;
} else if (this.spec.source !== undefined) {
this.source = this.spec.source;
} else {
this.source = getSource(element);
}

/**
* The element which this object is based off or the containing frame, used for sorting.
Expand Down
5 changes: 1 addition & 4 deletions lib/core/utils/respondable.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ function verify(postedMessage) {
var messageSource = _getSource();
return (
// Check the version matches
postedMessage._source === messageSource ||
// Allow free communication with axe test
postedMessage._source === 'axeAPI.x.y.z' ||
messageSource === 'axeAPI.x.y.z'
postedMessage._source === messageSource
);
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "axe-core",
"description": "Accessibility engine for automated Web UI testing",
"version": "4.1.1",
"version": "4.1.2",
"license": "MPL-2.0",
"engines": {
"node": ">=4"
Expand Down
4 changes: 4 additions & 0 deletions sri-history.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,9 @@
"4.1.1": {
"axe.js": "sha256-Tz6yShAcKxP8ce//YhbRkOLinUj+htEK2MjIi5yjY58=",
"axe.min.js": "sha256-43geecotYZGPnRt6o9Uu7Pjl3GthxnDacXrzCGv11go="
},
"4.1.2": {
"axe.js": "sha256-wnrhK+P+FXp6U/oYQrYVu6/6PrpO0chRAkik/2ENuS0=",
"axe.min.js": "sha256-TzERMakAkktf5sw0quZYuHVmniguowRhWRIVYpjbLbA="
}
}
88 changes: 58 additions & 30 deletions test/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ describe('Audit', function() {

var Audit = axe._thisWillBeDeletedDoNotUse.base.Audit;
var Rule = axe._thisWillBeDeletedDoNotUse.base.Rule;
var ver = axe.version.substring(0, axe.version.lastIndexOf('.'));
var a, getFlattenedTree;
var isNotCalled = function(err) {
throw err || new Error('Reject should not be called');
Expand Down Expand Up @@ -95,6 +96,13 @@ describe('Audit', function() {
assert.isFunction(Audit);
});

describe('defaults', function() {
it('should set noHtml', function() {
var audit = new Audit();
assert.isFalse(audit.noHtml);
});
});

describe('Audit#_constructHelpUrls', function() {
it('should create default help URLS', function() {
var audit = new Audit();
Expand All @@ -108,7 +116,9 @@ describe('Audit', function() {
audit._constructHelpUrls();
assert.deepEqual(audit.data.rules.target, {
helpUrl:
'https://dequeuniversity.com/rules/axe/x.y/target?application=axeAPI'
'https://dequeuniversity.com/rules/axe/' +
ver +
'/target?application=axeAPI'
});
});
it('should use changed branding', function() {
Expand All @@ -124,7 +134,9 @@ describe('Audit', function() {
audit._constructHelpUrls();
assert.deepEqual(audit.data.rules.target, {
helpUrl:
'https://dequeuniversity.com/rules/thing/x.y/target?application=axeAPI'
'https://dequeuniversity.com/rules/thing/' +
ver +
'/target?application=axeAPI'
});
});
it('should use changed application', function() {
Expand All @@ -140,7 +152,9 @@ describe('Audit', function() {
audit._constructHelpUrls();
assert.deepEqual(audit.data.rules.target, {
helpUrl:
'https://dequeuniversity.com/rules/axe/x.y/target?application=thing'
'https://dequeuniversity.com/rules/axe/' +
ver +
'/target?application=thing'
});
});

Expand All @@ -152,7 +166,9 @@ describe('Audit', function() {
selector: 'bob',
metadata: {
helpUrl:
'https://dequeuniversity.com/rules/myproject/x.y/target1?application=axeAPI'
'https://dequeuniversity.com/rules/myproject/' +
ver +
'/target1?application=axeAPI'
}
});
audit.addRule({
Expand All @@ -163,7 +179,9 @@ describe('Audit', function() {

assert.equal(
audit.data.rules.target1.helpUrl,
'https://dequeuniversity.com/rules/myproject/x.y/target1?application=axeAPI'
'https://dequeuniversity.com/rules/myproject/' +
ver +
'/target1?application=axeAPI'
);
assert.isUndefined(audit.data.rules.target2);

Expand All @@ -173,11 +191,15 @@ describe('Audit', function() {

assert.equal(
audit.data.rules.target1.helpUrl,
'https://dequeuniversity.com/rules/myproject/x.y/target1?application=axeAPI'
'https://dequeuniversity.com/rules/myproject/' +
ver +
'/target1?application=axeAPI'
);
assert.equal(
audit.data.rules.target2.helpUrl,
'https://dequeuniversity.com/rules/thing/x.y/target2?application=axeAPI'
'https://dequeuniversity.com/rules/thing/' +
ver +
'/target2?application=axeAPI'
);
});
it('understands prerelease type version numbers', function() {
Expand All @@ -198,24 +220,7 @@ describe('Audit', function() {
'https://dequeuniversity.com/rules/axe/3.2/target?application=axeAPI'
);
});
it('sets x.y as version for invalid versions', function() {
var tempVersion = axe.version;
var audit = new Audit();
audit.addRule({
id: 'target',
matches: 'function () {return "hello";}',
selector: 'bob'
});

axe.version = 'in-3.0-valid';
audit._constructHelpUrls();

axe.version = tempVersion;
assert.equal(
audit.data.rules.target.helpUrl,
'https://dequeuniversity.com/rules/axe/x.y/target?application=axeAPI'
);
});
it('matches major release versions', function() {
var tempVersion = axe.version;
var audit = new Audit();
Expand Down Expand Up @@ -249,7 +254,9 @@ describe('Audit', function() {
audit._constructHelpUrls();
assert.deepEqual(audit.data.rules.target, {
helpUrl:
'https://dequeuniversity.com/rules/axe/x.y/target?application=axeAPI&lang=de'
'https://dequeuniversity.com/rules/axe/' +
ver +
'/target?application=axeAPI&lang=de'
});
});
});
Expand Down Expand Up @@ -289,7 +296,9 @@ describe('Audit', function() {
});
assert.deepEqual(audit.data.rules.target, {
helpUrl:
'https://dequeuniversity.com/rules/axe/x.y/target?application=thing'
'https://dequeuniversity.com/rules/axe/' +
ver +
'/target?application=thing'
});
});
it('should call _constructHelpUrls even when nothing changed', function() {
Expand All @@ -304,7 +313,9 @@ describe('Audit', function() {
audit.setBranding(undefined);
assert.deepEqual(audit.data.rules.target, {
helpUrl:
'https://dequeuniversity.com/rules/axe/x.y/target?application=axeAPI'
'https://dequeuniversity.com/rules/axe/' +
ver +
'/target?application=axeAPI'
});
});
it('should not replace custom set branding', function() {
Expand All @@ -315,7 +326,9 @@ describe('Audit', function() {
selector: 'bob',
metadata: {
helpUrl:
'https://dequeuniversity.com/rules/customer-x/x.y/target?application=axeAPI'
'https://dequeuniversity.com/rules/customer-x/' +
ver +
'/target?application=axeAPI'
}
});
audit.setBranding({
Expand All @@ -324,7 +337,9 @@ describe('Audit', function() {
});
assert.equal(
audit.data.rules.target.helpUrl,
'https://dequeuniversity.com/rules/customer-x/x.y/target?application=axeAPI'
'https://dequeuniversity.com/rules/customer-x/' +
ver +
'/target?application=axeAPI'
);
});
});
Expand Down Expand Up @@ -423,6 +438,13 @@ describe('Audit', function() {
axe._audit.resetRulesAndChecks();
assert.deepEqual(axe._audit.tagExclude, ['experimental']);
});

it('should reset noHtml', function() {
var audit = new Audit();
audit.noHtml = true;
audit.resetRulesAndChecks();
assert.isFalse(audit.noHtml);
});
});

describe('Audit#addCheck', function() {
Expand Down Expand Up @@ -1166,8 +1188,14 @@ describe('Audit', function() {
throw new Error('Launch the super sheep!');
}
});

// check error node requires _selectorCache to be setup
// axe.setup();
axe._tree = axe.utils.getFlattenedTree(fixture);
axe._selectorData = axe.utils.getSelectorData(axe._tree);

a.run(
{ include: [axe.utils.getFlattenedTree(fixture)[0]] },
{ include: [axe._tree[0]] },
{
debug: true,
runOnly: {
Expand Down
Loading

0 comments on commit 11a514d

Please sign in to comment.