diff --git a/lib/checks/media/caption.js b/lib/checks/media/caption.js index 80b6af6372..d7d6090521 100644 --- a/lib/checks/media/caption.js +++ b/lib/checks/media/caption.js @@ -3,7 +3,7 @@ var tracks = axe.utils.querySelectorAll(virtualNode, 'track'); if (tracks.length) { // return false if any track has kind === 'caption' return !tracks.some(({ actualNode }) => ( - actualNode.getAttribute('kind').toLowerCase() === 'captions' + (actualNode.getAttribute('kind') || '').toLowerCase() === 'captions' )); } // Undefined if there are no tracks - media may be decorative diff --git a/lib/checks/media/description.js b/lib/checks/media/description.js index 65e29cd3b2..f6bb01a5fb 100644 --- a/lib/checks/media/description.js +++ b/lib/checks/media/description.js @@ -3,7 +3,7 @@ var tracks = axe.utils.querySelectorAll(virtualNode, 'track'); if (tracks.length) { // return false if any track has kind === 'description' var out = !tracks.some(({ actualNode }) => ( - actualNode.getAttribute('kind').toLowerCase() === 'descriptions' + (actualNode.getAttribute('kind') || '').toLowerCase() === 'descriptions' )); axe.log(tracks.map(t => t.actualNode.getAttribute('kind')), out); return out; diff --git a/test/checks/media/caption.js b/test/checks/media/caption.js index 3c313ed72c..3d7606a644 100644 --- a/test/checks/media/caption.js +++ b/test/checks/media/caption.js @@ -19,6 +19,11 @@ describe('caption', function () { assert.isTrue(checks.caption.evaluate.apply(null, checkArgs)); }); + it('should fail if there is no kind attribute', function () { + var checkArgs = checkSetup('', 'video'); + assert.isTrue(checks.description.evaluate.apply(null, checkArgs)); + }); + it('should pass if there is a kind=captions attribute', function () { var checkArgs = checkSetup('', 'audio'); assert.isFalse(checks.caption.evaluate.apply(null, checkArgs)); diff --git a/test/checks/media/description.js b/test/checks/media/description.js index a423e1f98b..46512a2e5a 100644 --- a/test/checks/media/description.js +++ b/test/checks/media/description.js @@ -18,6 +18,11 @@ describe('description', function () { assert.isTrue(checks.description.evaluate.apply(null, checkArgs)); }); + it('should fail if there is no kind attribute', function () { + var checkArgs = checkSetup('', 'video'); + assert.isTrue(checks.description.evaluate.apply(null, checkArgs)); + }); + it('should pass if there is a kind=descriptions attribute', function () { var checkArgs = checkSetup('', 'video'); assert.isFalse(checks.description.evaluate.apply(null, checkArgs));