diff --git a/src/report/axe2ace.js b/src/report/axe2ace.js index ca2ff821..559fb7b0 100644 --- a/src/report/axe2ace.js +++ b/src/report/axe2ace.js @@ -9,6 +9,7 @@ const winston = require('winston'); const kbMap = { 'baseUrl': 'http://kb.daisy.org/publishing/', 'map': { + 'pagebreak-label': {url: 'docs/navigation/pagelist.html', 'title': 'Page Breaks'}, 'html-has-lang': {url: 'docs/html/lang.html', title: 'Language'}, 'html-lang-valid': {url: 'docs/html/lang.html', title: 'Language'}, 'valid-lang': {url: 'docs/html/lang.html', title: 'Language'}, diff --git a/src/scripts/ace-axe.js b/src/scripts/ace-axe.js index 93ae3ec1..c1bbf5e8 100644 --- a/src/scripts/ace-axe.js +++ b/src/scripts/ace-axe.js @@ -83,6 +83,20 @@ daisy.ace.run = function(done) { } }; + window.axe.configure({ + rules: [ + { + id: 'pagebreak-label', + selector: '[*|type~="pagebreak"], [role~="doc-pagebreak"]', + any: ['aria-label', 'non-empty-title'], + metadata: { + description: "Ensure page markers have an accessible label", + }, + tags: ['cat.epub'] + } + ] + }); + window.axe.run( { "rules": { diff --git a/tests/__tests__/axe-rules.test.js b/tests/__tests__/axe-rules.test.js index eefdbb3f..195ecbb9 100644 --- a/tests/__tests__/axe-rules.test.js +++ b/tests/__tests__/axe-rules.test.js @@ -45,3 +45,28 @@ test('DPUB ARIA roles are allowed', async () => { const report = await ace('../data/axerule-dpubroles'); expect(report['earl:result']['earl:outcome']).toEqual('pass'); }); + +test('Ensure page breaks have labels', async () => { + const report = await ace('../data/axerule-pagebreak-label'); + expect(report['earl:result']['earl:outcome']).toEqual('fail'); + expect(report.assertions).toEqual(expect.arrayContaining([ + expect.objectContaining({ + 'earl:testSubject': expect.objectContaining({ url: 'content_001.xhtml' }), + assertions: [ + expect.objectContaining({ + 'earl:test': expect.objectContaining({ 'dct:title': 'pagebreak-label' }), + 'earl:result': expect.objectContaining({ + 'earl:outcome': 'fail', + 'earl:pointer': expect.objectContaining({ css: ['#p3'] }), + }), + }), + expect.objectContaining({ + 'earl:test': expect.objectContaining({ 'dct:title': 'pagebreak-label' }), + 'earl:result': expect.objectContaining({ + 'earl:outcome': 'fail', + 'earl:pointer': expect.objectContaining({ css: ['#p4'] }), + }), + }), + ], + })])); +}); diff --git a/tests/data/axerule-dpubroles/EPUB/content_001.xhtml b/tests/data/axerule-dpubroles/EPUB/content_001.xhtml index ff451514..25a63448 100644 --- a/tests/data/axerule-dpubroles/EPUB/content_001.xhtml +++ b/tests/data/axerule-dpubroles/EPUB/content_001.xhtml @@ -42,7 +42,7 @@
-
+
diff --git a/tests/data/axerule-pagebreak-label/EPUB/content_001.xhtml b/tests/data/axerule-pagebreak-label/EPUB/content_001.xhtml new file mode 100644 index 00000000..0bc928b8 --- /dev/null +++ b/tests/data/axerule-pagebreak-label/EPUB/content_001.xhtml @@ -0,0 +1,13 @@ + + +Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + + + + + diff --git a/tests/data/axerule-pagebreak-label/EPUB/nav.xhtml b/tests/data/axerule-pagebreak-label/EPUB/nav.xhtml new file mode 100644 index 00000000..306a30ef --- /dev/null +++ b/tests/data/axerule-pagebreak-label/EPUB/nav.xhtml @@ -0,0 +1,20 @@ + + +Minimal Nav + + + + + + diff --git a/tests/data/axerule-pagebreak-label/EPUB/package.opf b/tests/data/axerule-pagebreak-label/EPUB/package.opf new file mode 100644 index 00000000..1e0bd931 --- /dev/null +++ b/tests/data/axerule-pagebreak-label/EPUB/package.opf @@ -0,0 +1,24 @@ + + + + Minimal EPUB 3.0 + en + NOID + https://example.com + 2017-01-01T00:00:01Z + structuralNavigation + everything OK! + noFlashingHazard + noSoundHazard + noMotionSimulationHazard + textual + textual + + + + + + + + + diff --git a/tests/data/axerule-pagebreak-label/META-INF/container.xml b/tests/data/axerule-pagebreak-label/META-INF/container.xml new file mode 100644 index 00000000..2cf00654 --- /dev/null +++ b/tests/data/axerule-pagebreak-label/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/data/axerule-pagebreak-label/mimetype b/tests/data/axerule-pagebreak-label/mimetype new file mode 100644 index 00000000..57ef03f2 --- /dev/null +++ b/tests/data/axerule-pagebreak-label/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file