Skip to content

Commit

Permalink
Merged in audio-video-incomplete (pull request #122)
Browse files Browse the repository at this point in the history
feat: change audio/video rule to report incomplete

Closes #285

Approved-by: Wilco Fiers <wilco.fiers@deque.com>
  • Loading branch information
Marcy Sutton committed Apr 20, 2017
1 parent 4682b1e commit 30be884
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 16 deletions.
14 changes: 13 additions & 1 deletion lib/checks/media/caption.js
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
return !(node.querySelector('track[kind=captions]'));
var tracks = node.querySelectorAll('track');
if (tracks.length) {
for (var i=0; i<tracks.length; i++) {
var kind = tracks[i].getAttribute('kind');
if (kind && kind === 'captions') {
// only return for matching track, in case there are multiple
return false;
}
}
return true;
}
// for multiple track elements, return the first one that matches
return undefined;
3 changes: 2 additions & 1 deletion lib/checks/media/caption.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"impact": "critical",
"messages": {
"pass": "The multimedia element has a captions track",
"fail": "The multimedia element does not have a captions track"
"fail": "The multimedia element does not have a captions track",
"incomplete": "A captions track for this element could not be found"
}
}
}
13 changes: 12 additions & 1 deletion lib/checks/media/description.js
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
return !(node.querySelector('track[kind=descriptions]'));
var tracks = node.querySelectorAll('track');
if (tracks.length) {
for (var i=0; i<tracks.length; i++) {
var kind = tracks[i].getAttribute('kind');
if (kind && kind === 'descriptions') {
// only return for matching track, in case there are multiple
return false;
}
}
return true;
}
return undefined;
3 changes: 2 additions & 1 deletion lib/checks/media/description.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"impact": "serious",
"messages": {
"pass": "The multimedia element has an audio description track",
"fail": "The multimedia element does not have an audio description track"
"fail": "The multimedia element does not have an audio description track",
"incomplete": "An audio description track for this element could not be found"
}
}
}
4 changes: 2 additions & 2 deletions test/checks/media/caption.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ describe('caption', function () {
fixture.innerHTML = '';
});

it('should fail if there is no track element', function () {
it('should return undefined if there is no track element', function () {
fixture.innerHTML = '<audio></audio>';
var node = fixture.querySelector('audio');

assert.isTrue(checks.caption.evaluate(node));
assert.isUndefined(checks.caption.evaluate(node));
});

it('should fail if there is no kind=captions attribute', function () {
Expand Down
4 changes: 2 additions & 2 deletions test/checks/media/description.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ describe('description', function () {
fixture.innerHTML = '';
});

it('should fail if there is no track element', function () {
it('should return undefined if there is no track element', function () {
fixture.innerHTML = '<video></video>';
var node = fixture.querySelector('video');

assert.isTrue(checks.description.evaluate(node));
assert.isUndefined(checks.description.evaluate(node));
});

it('should fail if there is no kind=descriptions attribute', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/rules/audio-caption/audio-caption.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "audio-caption test",
"rule": "audio-caption",
"violations": [["#empty"]],
"incomplete": [["#empty"]],
"passes": [["#caption"]]
}
5 changes: 2 additions & 3 deletions test/integration/rules/video-caption/video-caption.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

<video id="fail1"></video>
<video id="fail2"><track kind="descriptions"></video>
<video id="incomplete1"></video>
<video id="fail1"><track kind="descriptions"></video>
<video id="pass1"><track kind="captions"></video>
<video id="pass2"><track kind="descriptions"><track kind="captions"></video>
3 changes: 2 additions & 1 deletion test/integration/rules/video-caption/video-caption.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"description": "video-caption test",
"rule": "video-caption",
"violations": [["#fail1"], ["#fail2"]],
"incomplete": [["#incomplete1"]],
"violations": [["#fail1"]],
"passes": [["#pass1"], ["#pass2"]]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

<video id="fail1"></video>
<video id="fail2"><track kind="captions"></video>
<video id="incomplete1"></video>
<video id="fail1"><track kind="captions"></video>
<video id="pass1"><track kind="descriptions"></video>
<video id="pass2"><track kind="descriptions"><track kind="captions"></video>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"description": "video-description test",
"rule": "video-description",
"violations": [["#fail1"], ["#fail2"]],
"incomplete": [["#incomplete1"]],
"violations": [["#fail1"]],
"passes": [["#pass1"], ["#pass2"]]
}

0 comments on commit 30be884

Please sign in to comment.