Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Commit

Permalink
Phantom doesn't like requesting set files, limiting those tests to br…
Browse files Browse the repository at this point in the history
…owsers only. Tested subtitles for language. #93
  • Loading branch information
Kevin Miller committed Mar 1, 2014
1 parent 681f175 commit a4c53e9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
25 changes: 23 additions & 2 deletions src/js/custom/videosEmbeddedOrLinkedNeedCaptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,32 @@ quail.videosEmbeddedOrLinkedNeedCaptions = function() {
quail.testFails('videosEmbeddedOrLinkedNeedCaptions', $video);
}
else {
var language = quail.components.language.getDocumentLanguage(true);
if($video.parents('[lang]').length) {
language = $video.parents('[lang]').first().attr('lang').split('-')[0];
}
var foundLanguage = false;
$captions.each(function() {
if($.ajax({ url : $(this).attr('src'), async: false }).status === 404) {
quail.testFails('videosEmbeddedOrLinkedNeedCaptions', $video);
if(!$(this).attr('srclang') || $(this).attr('srclang').toLowerCase() === language) {
foundLanguage = true;
try{
var request = $.ajax({ url: $(this).attr('src'),
type: 'HEAD',
async: false,
error: function() { }
});
if(request.status === 404) {
quail.testFails('videosEmbeddedOrLinkedNeedCaptions', $video);
}
}
catch(e) {

}
}
});
if(!foundLanguage) {
quail.testFails('videosEmbeddedOrLinkedNeedCaptions', $video);
}
}
});
};
1 change: 1 addition & 0 deletions src/resources/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4267,6 +4267,7 @@ videosEmbeddedOrLinkedNeedCaptions:
- "content"
components:
- "video"
- "language"
callback: "videosEmbeddedOrLinkedNeedCaptions"
whiteSpaceInWord:
type: "custom"
Expand Down
16 changes: 12 additions & 4 deletions test/accessibility-tests/videosEmbeddedOrLinkedNeedCaptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,35 @@
<head>
<title>videosEmbeddedOrLinkedNeedCaptions</title>
</head>
<body>
<body lang="en">
<div class="quail-test" data-expected="fail" data-accessibility-test="videosEmbeddedOrLinkedNeedCaptions">
<p>
Hey, check
<a href="http://www.youtube.com/watch?v=V1HSNV9y25A" class="quail-failed-element">Out this awesome video.</a>
</p>
</div>
<div class="quail-test" data-expected="fail" data-accessibility-test="videosEmbeddedOrLinkedNeedCaptions">
<div class="quail-test" data-expected="fail" data-accessibility-test="videosEmbeddedOrLinkedNeedCaptions" title="No Subtitle">
<video controls class="quail-failed-element">
<source src="../assets/sample.ogv" type="video/ogv"/>
</video>
</div>

<div class="quail-test" data-expected="fail" data-accessibility-test="videosEmbeddedOrLinkedNeedCaptions">
<div class="quail-test limit-chrome" data-expected="fail" data-accessibility-test="videosEmbeddedOrLinkedNeedCaptions" title="Subtitle file missing">

<video controls class="quail-failed-element">
<source src="../assets/sample.ogv" type="video/ogv"/>
<track kind="subtitles" src="../assets/broken.srt" srclang="en"></track>
</video>
</div>

<div class="quail-test" data-expected="fail" data-accessibility-test="videosEmbeddedOrLinkedNeedCaptions" lang="fr" title="Subtitle not matching language">

<video controls class="quail-failed-element">
<source src="../assets/sample.ogv" type="video/ogv"/>
<track kind="subtitles" src="../assets/subtitle.srt" srclang="en"></track>
</video>
</div>

<div class="quail-test" data-expected="pass" data-accessibility-test="videosEmbeddedOrLinkedNeedCaptions">
<p>
Hey, check
Expand All @@ -35,7 +43,7 @@
</p>

</div>
<div class="quail-test" data-expected="pass" data-accessibility-test="videosEmbeddedOrLinkedNeedCaptions">
<div class="quail-test limit-chrome" data-expected="pass" data-accessibility-test="videosEmbeddedOrLinkedNeedCaptions" title="Video tag has correct subtitle">

<video controls>
<source src="../assets/sample.ogv" type="video/ogv"/>
Expand Down

0 comments on commit a4c53e9

Please sign in to comment.