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

[WIP] [DO NOT MERGE] v4.3.3 diff #6

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
da2deae
changed package name to denote DAISY fork
danielweck Jan 19, 2021
bdcf58d
initial patching (scripts/axe-patch-is-aria-role-allowed.js scripts/a…
danielweck Jan 19, 2021
5830ea9
Mocha fast bail
danielweck Jan 19, 2021
8b3740d
semver is same as Axe Core but with DAISY addon suffix. Also added NP…
danielweck Jan 19, 2021
723b98a
semver is reflected in auto-generated doc
danielweck Jan 19, 2021
2e70235
added unit tests for implicit/explicit and DPUB role parsing
danielweck Jan 19, 2021
4ce706d
Scoped NPM package name, and files selection for NPM publish
danielweck Jan 19, 2021
1c9a0b2
NPM public publish
danielweck Jan 19, 2021
6590f7f
Merge branch 'v4.1.1_DAISY' into v4.1.2_DAISY
danielweck Feb 16, 2021
ea67596
rules MD
danielweck Feb 16, 2021
e04a57a
ignore epub:type
danielweck Feb 18, 2021
af3e209
Merge branch 'v4.1.2_DAISY' into v4.1.3_DAISY
danielweck Mar 10, 2021
161d97e
Unit tests require package.json version without canary or arbitrary e…
danielweck Mar 10, 2021
2a6ab7e
landmark-one-main now with page-no-duplicate-main in addition to page…
danielweck Mar 10, 2021
dae726f
doc: landmark-one-main now with page-no-duplicate-main in addition to…
danielweck Mar 10, 2021
2b5bb2d
intermediary commit (Axe hook seems to stash things in the working co…
danielweck Mar 10, 2021
6121f22
main element and div with role
danielweck Mar 10, 2021
10be613
added unit test for landmark-no-duplicate-main to pass content with n…
danielweck Mar 10, 2021
72707cf
matching-aria-role check port (untranslated)
danielweck Mar 10, 2021
45529c1
epub-type-has-matching-role pagebreak-label ported from Ace (translat…
danielweck Mar 10, 2021
5e5e6a7
working XHTML unit tests for EPUB in Axe! (port from Ace)
danielweck Mar 11, 2021
e460f1d
page-break label test (check)
danielweck Mar 11, 2021
da8e26c
Merge branch 'v4.1.3_DAISY' into v4.1.4_DAISY
danielweck Apr 6, 2021
908db3d
fixed semantic versioning handling (major.minor.patch-prerelease.buil…
danielweck Apr 6, 2021
9d64963
fixed dd, dt, dl, dfn lookup table
danielweck Apr 6, 2021
2565b38
re-instated DAISY mods
danielweck Apr 6, 2021
d61e3dd
DAISY landmark-one-main rule really is "has a unique main landmark ..…
danielweck Apr 6, 2021
e8e5645
get role type is super class role now (DAISY patch)
danielweck Apr 6, 2021
20748a7
super class role checks
danielweck Apr 6, 2021
3ce8040
owned roles fix for biblioentry and doc-endnote
danielweck Apr 6, 2021
4140347
DPUB ARIA 1.1 align https://w3c.github.io/dpub-aria/#changelog
danielweck Apr 7, 2021
05d0726
DPUB ARIA 1.1. deprecate doc-biblioentry and doc-endnote
danielweck Apr 7, 2021
c5005ba
further relaxation of doc-endnote and doc-biblioentry (deprecated in …
danielweck Apr 7, 2021
7673aaa
version bump and URL update
danielweck Apr 7, 2021
1a8dd7a
fixes landmark-unique (DPUB roles) https://github.com/daisy/ace/issue…
danielweck Apr 7, 2021
d159e51
version bump
danielweck Apr 7, 2021
09b6abe
Axe landmark unique fixes (weird DOM parser bug ignores some element …
danielweck Apr 7, 2021
a8d882a
added unit test for landmark unique (broken DOM parser it seems)
danielweck Apr 7, 2021
491abc8
final round of fixes for landmark unique (rule filter takes precedenc…
danielweck Apr 7, 2021
21375e0
version bump
danielweck Apr 7, 2021
f1eee5b
Merge branch 'v4.1.4_DAISY' into v4.2.3_DAISY
danielweck Jun 23, 2021
3c08e8c
added missing NPM publish files
danielweck Jun 23, 2021
6cf8250
removed unnecessary files
danielweck Jun 23, 2021
8144048
removed another useless file
danielweck Jun 23, 2021
205efb0
dpub roles were not taken into account for aria-label prohibited attr…
danielweck Jun 23, 2021
73d2cd9
version bump
danielweck Jun 23, 2021
9017f37
Merge branch 'v4.2.3_DAISY' into v4.3.3_DAISY
danielweck Aug 30, 2021
19dd52c
doc update (auto-gen)
danielweck Aug 30, 2021
6b68cb1
ChromeDriver version update (90 -> 92)
danielweck Aug 30, 2021
327b8c0
'null' origin fix, see https://github.com/daisy/ace/issues/358#issuec…
danielweck Sep 14, 2021
4b0dd53
version bump to 4.3.3-canary.2
danielweck Sep 14, 2021
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ typings/axe-core/axe-core-tests.js
# doc
doc/rule-descriptions.*.md

.history
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.3.3",
"version": "4.3.3-canary.2",
"contributors": [
{
"name": "David Sturley",
Expand Down
6 changes: 2 additions & 4 deletions build/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ var entities = new (require('html-entities').AllHtmlEntities)();
var packageJSON = require('../package.json');
var dotRegex = /\{\{.+?\}\}/g;

var axeVersion = packageJSON.version.substring(
0,
packageJSON.version.lastIndexOf('.')
);
var _v = packageJSON.version.replace(/-\w+\.\w+$/, '');
var axeVersion = _v.substring(0, _v.lastIndexOf('.'));

var descriptionTableHeader =
'| Rule ID | Description | Impact | Tags | Issue Type | ACT Rules |\n| :------- | :------- | :------- | :------- | :------- | :------- |\n';
Expand Down
2 changes: 1 addition & 1 deletion build/tasks/update-help.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function(grunt) {
var options = this.options({
version: '1.0.0'
});
var v = options.version.split('.');
var v = options.version.replace(/-\w+\.\w+$/, '').split('.');
v.pop();
var baseUrl =
'https://dequeuniversity.com/rules/axe/' + v.join('.') + '/';
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/qunit/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function(grunt) {

grunt.initConfig({
qunit: {
all: ['test/**/*.html']
all: ['test/**/*.html', 'test/**/*__.xhtml']
}
});
};
4 changes: 3 additions & 1 deletion doc/rule-descriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
| [autocomplete-valid](https://dequeuniversity.com/rules/axe/4.3/autocomplete-valid?application=RuleDescription) | Ensure the autocomplete attribute is correct and suitable for the form field | Serious | cat.forms, wcag21aa, wcag135 | failure | [73f2c2](https://act-rules.github.io/rules/73f2c2) |
| [avoid-inline-spacing](https://dequeuniversity.com/rules/axe/4.3/avoid-inline-spacing?application=RuleDescription) | Ensure that text spacing set through style attributes can be adjusted with custom stylesheets | Serious | cat.structure, wcag21aa, wcag1412 | failure | |
| [empty-table-header](https://dequeuniversity.com/rules/axe/4.3/empty-table-header?application=RuleDescription) | Ensures table headers have discernible text | Minor | wcag131, cat.aria | needs review | |
| [pagebreak-label](https://dequeuniversity.com/rules/axe/4.3/pagebreak-label?application=RuleDescription) | Ensure page markers have an accessible label | Serious | cat.epub | failure | |

## Best Practices Rules

Expand All @@ -87,6 +88,7 @@ Rules that do not necessarily conform to WCAG success criterion but are industry
| [aria-text](https://dequeuniversity.com/rules/axe/4.3/aria-text?application=RuleDescription) | Ensures "role=text" is used on elements with no focusable descendants | Serious | cat.aria, best-practice | failure, needs review | |
| [aria-treeitem-name](https://dequeuniversity.com/rules/axe/4.3/aria-treeitem-name?application=RuleDescription) | Ensures every ARIA treeitem node has an accessible name | Serious | cat.aria, best-practice | failure, needs review | |
| [empty-heading](https://dequeuniversity.com/rules/axe/4.3/empty-heading?application=RuleDescription) | Ensures headings have discernible text | Minor | cat.name-role-value, best-practice | failure, needs review | |
| [epub-type-has-matching-role](https://dequeuniversity.com/rules/axe/4.3/epub-type-has-matching-role?application=RuleDescription) | Ensure the element has an ARIA role matching its epub:type | Minor | best-practice, cat.aria | failure | |
| [frame-tested](https://dequeuniversity.com/rules/axe/4.3/frame-tested?application=RuleDescription) | Ensures <iframe> and <frame> elements contain the axe-core script | Critical | cat.structure, review-item, best-practice | failure, needs review | |
| [frame-title-unique](https://dequeuniversity.com/rules/axe/4.3/frame-title-unique?application=RuleDescription) | Ensures <iframe> and <frame> elements contain a unique title attribute | Serious | cat.text-alternatives, best-practice | failure | |
| [heading-order](https://dequeuniversity.com/rules/axe/4.3/heading-order?application=RuleDescription) | Ensures the order of headings is semantically correct | Moderate | cat.semantics, best-practice | failure, needs review | |
Expand All @@ -100,7 +102,7 @@ Rules that do not necessarily conform to WCAG success criterion but are industry
| [landmark-no-duplicate-banner](https://dequeuniversity.com/rules/axe/4.3/landmark-no-duplicate-banner?application=RuleDescription) | Ensures the document has at most one banner landmark | Moderate | cat.semantics, best-practice | failure | |
| [landmark-no-duplicate-contentinfo](https://dequeuniversity.com/rules/axe/4.3/landmark-no-duplicate-contentinfo?application=RuleDescription) | Ensures the document has at most one contentinfo landmark | Moderate | cat.semantics, best-practice | failure | |
| [landmark-no-duplicate-main](https://dequeuniversity.com/rules/axe/4.3/landmark-no-duplicate-main?application=RuleDescription) | Ensures the document has at most one main landmark | Moderate | cat.semantics, best-practice | failure | |
| [landmark-one-main](https://dequeuniversity.com/rules/axe/4.3/landmark-one-main?application=RuleDescription) | Ensures the document has a main landmark | Moderate | cat.semantics, best-practice | failure | |
| [landmark-one-main](https://dequeuniversity.com/rules/axe/4.3/landmark-one-main?application=RuleDescription) | Ensures the document has a unique main landmark | Moderate | cat.semantics, best-practice | failure | |
| [landmark-unique](https://dequeuniversity.com/rules/axe/4.3/landmark-unique?application=RuleDescription) | Landmarks should have a unique role or role/label/title (i.e. accessible name) combination | Moderate | cat.semantics, best-practice | failure | |
| [meta-viewport-large](https://dequeuniversity.com/rules/axe/4.3/meta-viewport-large?application=RuleDescription) | Ensures <meta name="viewport"> can scale a significant amount | Minor | cat.sensory-and-visual-cues, best-practice | failure | |
| [meta-viewport](https://dequeuniversity.com/rules/axe/4.3/meta-viewport?application=RuleDescription) | Ensures <meta name="viewport"> does not disable text scaling and zooming | Critical | cat.sensory-and-visual-cues, best-practice, ACT | failure | [b4f0c3](https://act-rules.github.io/rules/b4f0c3) |
Expand Down
2 changes: 1 addition & 1 deletion lib/checks/aria/aria-prohibited-attr-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function ariaProhibitedAttrEvaluate(node, options = {}, virtualNode) {
}

function listProhibitedAttrs(virtualNode, elementsAllowedAriaLabel) {
const role = getRole(virtualNode, { chromium: true });
const role = getRole(virtualNode, { dpub: true, chromium: true });
const roleSpec = standards.ariaRoles[role];
if (roleSpec) {
return roleSpec.prohibitedAttrs || [];
Expand Down
13 changes: 11 additions & 2 deletions lib/checks/aria/aria-required-children-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ import { hasContentVirtual, idrefs } from '../../commons/dom';
* Get all owned roles of an element
*/
function getOwnedRoles(virtualNode, required) {
// DAISY-AXE
const parentRole = getRole(virtualNode, { dpub: true });

const ownedRoles = [];
const ownedElements = getOwnedVirtual(virtualNode);
for (let i = 0; i < ownedElements.length; i++) {
const ownedElement = ownedElements[i];
const role = getRole(ownedElement, { noPresentational: true });

// DAISY-AXE
const role = getRole(ownedElement, { noPresentational: true, dpub: true });
// const role = getRole(ownedElement, { noPresentational: true });

// if owned node has no role or is presentational, or if role
// allows group or rowgroup, we keep parsing the descendant tree.
Expand All @@ -23,7 +29,10 @@ function getOwnedRoles(virtualNode, required) {
if (
!role ||
(['group', 'rowgroup'].includes(role) &&
required.some(requiredRole => requiredRole === role))
required.some(requiredRole => requiredRole === role)) ||
// DAISY-AXE
(['list'].includes(role) &&
['doc-bibliography', 'doc-endnotes'].includes(parentRole))
) {
ownedElements.push(...ownedElement.children);
} else if (role) {
Expand Down
185 changes: 185 additions & 0 deletions lib/checks/aria/matching-aria-role-evaluate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
import { tokenList } from '../../core/utils';
import { getRole } from '../../commons/aria';
import matchesSelector from '../../core/utils/element-matches';

function matchingAriaRoleEvaluate(node) {
// https://idpf.github.io/epub-guides/epub-aria-authoring/#sec-mappings
// https://www.w3.org/TR/dpub-aam-1.0/#mapping_role_table
// https://w3c.github.io/publ-cg/guides/aria-mapping.html#mapping-table
const mappings = new Map([
['abstract', 'doc-abstract'],
['acknowledgments', 'doc-acknowledgments'],
['afterword', 'doc-afterword'],
// ['answer', '??'],
// ['answers', '??'],
['appendix', 'doc-appendix'],
// ['assessment', '??'],
// ['assessments', '??'],
// ['backmatter', '??'],
// ['balloon', '??'],
// ['backlink', 'doc-backlink'], // ??
['biblioentry', 'doc-biblioentry'],
['bibliography', 'doc-bibliography'],
['biblioref', 'doc-biblioref'],
// ['bodymatter', '??'],
// ['bridgehead', '??'],
// ['case-study', '??'],
['chapter', 'doc-chapter'],
['colophon', 'doc-colophon'],
// ['concluding-sentence', '??'],
['conclusion', 'doc-conclusion'],
// ['contributors', '??'],
// ['copyright-page', '??'],
// ['cover', '??'],
// ['cover-image', 'doc-cover'], // ??
// ['covertitle', '??'],
['credit', 'doc-credit'],
['credits', 'doc-credits'],
['dedication', 'doc-dedication'],
// ['division', '??'],
['endnote', 'doc-endnote'],
['endnotes', 'doc-endnotes'],
['epigraph', 'doc-epigraph'],
['epilogue', 'doc-epilogue'],
['errata', 'doc-errata'],
// ['example', 'doc-example'],
// ['feedback', '??'],
['figure', 'figure'], // ARIA
// ['fill-in-the-blank-problem', '??'],
['footnote', 'doc-footnote'],
// ['footnotes', '??'],
['foreword', 'doc-foreword'],
// ['frontmatter', '??'],
// ['fulltitle', '??'],
// ['general-problem', '??'],
['glossary', 'doc-glossary'],
['glossdef', 'definition'], // ARIA
['glossref', 'doc-glossref'],
['glossterm', 'term'], // ARIA
// ['halftitle', '??'],
// ['halftitlepage', '??'],
// ['imprimatur', '??'],
// ['imprint', '??'],
['help', 'doc-tip'], // ??
['index', 'doc-index'],
// ['index-editor-note', '??'],
// ['index-entry', '??'],
// ['index-entry-list', '??'],
// ['index-group', '??'],
// ['index-headnotes', '??'],
// ['index-legend', '??'],
// ['index-locator', '??'],
// ['index-locator-list', '??'],
// ['index-locator-range', '??'],
// ['index-term', '??'],
// ['index-term-categories', '??'],
// ['index-term-category', '??'],
// ['index-xref-preferred', '??'],
// ['index-xref-related', '??'],
['introduction', 'doc-introduction'],
// ['keyword', '??'],
// ['keywords', '??'],
// ['label', '??'],
// ['landmarks', 'directory'], // ARIA (SKIPPED! NavDoc)
// ['learning-objective', '??'],
// ['learning-objectives', '??'],
// ['learning-outcome', '??'],
// ['learning-outcomes', '??'],
// ['learning-resource', '??'],
// ['learning-resources', '??'],
// ['learning-standard', '??'],
// ['learning-standards', '??'],
['list', 'list'], // ARIA
['list-item', 'listitem'], // ARIA
// ['loa', '??'],
// ['loi', '??'],
// ['lot', '??'],
// ['lov', '??'],
// ['match-problem', '??'],
// ['multiple-choice-problem', '??'],
['noteref', 'doc-noteref'],
['notice', 'doc-notice'],
// ['ordinal', '??'],
// ['other-credits', '??'],
['page-list', 'doc-pagelist'],
['pagebreak', 'doc-pagebreak'],
// ['panel', '??'],
// ['panel-group', '??'],
['part', 'doc-part'],
// ['practice', '??'],
// ['practices', '??'],
// ['preamble', '??'],
['preface', 'doc-preface'],
['prologue', 'doc-prologue'],
['pullquote', 'doc-pullquote'],
['qna', 'doc-qna'],
// ['question', '??'],
['referrer', 'doc-backlink'],
// ['revision-history', '??'],
// ['seriespage', '??'],
// ['sound-area', '??'],
// ['subchapter', '??'],
['subtitle', 'doc-subtitle'],
['table', 'table'],
['table-cell', 'cell'],
['table-row', 'row'],
// ['text-area', '??'],
['tip', 'doc-tip'],
// ['title', '??'],
// ['titlepage', '??'],
['toc', 'doc-toc']
// ['toc-brief', '??'],
// ['topic-sentence', '??'],
// ['true-false-problem', '??'],
// ['volume', '??'],
]);

const hasXmlEpubType = node.hasAttributeNS(
'http://www.idpf.org/2007/ops',
'type'
);
if (
hasXmlEpubType ||
node.hasAttribute('epub:type') // for unit tests that are not XML-aware due to fixture.innerHTML
) {
// abort if descendant of landmarks nav (nav with epub:type=landmarks)
if (
(hasXmlEpubType && matchesSelector(node, 'nav[*|type~="landmarks"] *')) ||
matchesSelector(node, 'nav[epub\\:type~="landmarks"] *')
) {
// console.log('BREAKPOINT');
// throw new Error('BREAKPOINT');
return true;
}

// iterate for each epub:type value
var types = tokenList(
hasXmlEpubType
? node.getAttributeNS('http://www.idpf.org/2007/ops', 'type')
: node.getAttribute('epub:type')
);
for (const type of types) {
// If there is a 1-1 mapping, check that the role is set (best practice)
if (mappings.has(type)) {
// Note: using axe’s `getRole` util returns the effective role of the element
// (either explicitly set with the role attribute or implicit)
// So this works for types mapping to core ARIA roles (eg. glossref/glossterm).
const mappedRole = mappings.get(type);
const role = getRole(node, { dpub: true });
// if (mappedRole !== role) {
// console.log('BREAKPOINT: ', type, mappedRole, role);
// // throw new Error('BREAKPOINT');
// }
return mappedRole === role;
} else {
// e.g. cover, landmarks
// console.log('BREAKPOINT: ', type);
// throw new Error('BREAKPOINT');
}
}
}

return true;
}

export default matchingAriaRoleEvaluate;
11 changes: 11 additions & 0 deletions lib/checks/aria/matching-aria-role.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "matching-aria-role",
"evaluate": "matching-aria-role-evaluate",
"metadata": {
"impact": "minor",
"messages": {
"pass": "Element has an ARIA role matching its epub:type",
"fail": "Element has no ARIA role matching its epub:type"
}
}
}
14 changes: 13 additions & 1 deletion lib/checks/landmarks/landmark-is-unique-after.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
function landmarkIsUniqueAfter(results) {
var uniqueLandmarks = [];

// console.log("landmarkIsUniqueAfter results: ", JSON.stringify(results, null, 4));

// filter out landmark elements that share the same role and accessible text
// so every non-unique landmark isn't reported as a failure (just the first)
return results.filter(currentResult => {
var filtered = results.filter(currentResult => {
if (!currentResult.data) {
// console.log('landmarkIsUniqueAfterlandmarkIsUniqueAfter NO DATA???!!!');
return false;
}

var findMatch = someResult => {
return (
// currentResult.data.isLandmark &&
// someResult.data.isLandmark &&
currentResult.data.role === someResult.data.role &&
currentResult.data.accessibleText === someResult.data.accessibleText
);
Expand All @@ -22,6 +31,9 @@ function landmarkIsUniqueAfter(results) {
currentResult.relatedNodes = [];
return true;
});

// console.log("landmarkIsUniqueAfter filtered: ", JSON.stringify(filtered, null, 4));
return filtered;
}

export default landmarkIsUniqueAfter;
Loading