This repository has been archived by the owner on Sep 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'wcag2' into feature/aInPhasADistinctStyle
- Loading branch information
Showing
29 changed files
with
1,432 additions
and
588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
quail.animatedGifMayBePresent=function(quail, test, Case){ | ||
|
||
/** | ||
* Test if gif is animated | ||
* Implemented from: https://gist.github.com/3012623.git | ||
* @param src | ||
* @param ext | ||
* @param cb | ||
*/ | ||
function isAnimatedGif(src, ext, cb){ | ||
|
||
if(ext !== 'gif'){ | ||
cb(false); | ||
return; | ||
} | ||
|
||
var request=new XMLHttpRequest(); | ||
request.open('GET', src, true); | ||
request.responseType='arraybuffer'; | ||
request.addEventListener('load', function () { | ||
var arr = new Uint8Array(request.response); | ||
var frames = 0; | ||
|
||
// make sure it's a gif (GIF8) | ||
if (arr[0] !== 0x47 || arr[1] !== 0x49 || | ||
arr[2] !== 0x46 || arr[3] !== 0x38) | ||
{ | ||
cb(false); | ||
return; | ||
} | ||
|
||
//ported from php http://www.php.net/manual/en/function.imagecreatefromgif.php#104473 | ||
//an animated gif contains multiple "frames", with each frame having a | ||
//header made up of: | ||
// * a static 4-byte sequence (\x00\x21\xF9\x04) | ||
// * 4 variable bytes | ||
// * a static 2-byte sequence (\x00\x2C) (some variants may use \x00\x21 ?) | ||
// We read through the file til we reach the end of the file, or we've found | ||
// at least 2 frame headers | ||
for (var i=0; i < arr.length -9; i++) { | ||
if (arr[i] === 0x00 && arr[i+1] === 0x21 && | ||
arr[i+2] === 0xF9 && arr[i+3] === 0x04 && | ||
arr[i+8] === 0x00 && | ||
(arr[i+9] === 0x2C || arr[i+9] === 0x21)) | ||
{ | ||
frames++; | ||
} | ||
if(frames > 1){ | ||
cb(true); | ||
return; | ||
} | ||
} | ||
|
||
cb(false); | ||
window.console.log("AFTER PARSING: ", frames); | ||
}); | ||
request.send(); | ||
} | ||
|
||
test.get('$scope').find('img').each(function(){ | ||
|
||
var _case=Case({ | ||
element: this, | ||
expected: $(this).closest('.quail-test').data('expected') | ||
}); | ||
test.add(_case); | ||
|
||
var imgSrc=$(this).attr('src'); | ||
var ext=$(this).attr('src').split('.').pop().toLowerCase(); | ||
|
||
if (ext !== 'gif') { | ||
_case.set({ | ||
'status': 'inapplicable' | ||
}); | ||
return; | ||
} | ||
|
||
isAnimatedGif(imgSrc, ext, function(animated){ | ||
if (animated) { | ||
_case.set({ | ||
'status': 'cantTell' | ||
}); | ||
return; | ||
} else{ | ||
_case.set({ | ||
'status': 'inapplicable' | ||
}); | ||
return; | ||
} | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
quail.audioMayBePresent=function(quail, test, Case){ | ||
var audioExtensions = ['mp3', 'm4p', 'ogg', 'oga', 'opus', 'wav', 'wma', 'wv']; | ||
|
||
test.get('$scope').each(function() { | ||
var $this = $(this); | ||
var hasCase = false; // Test if a case has been created | ||
|
||
// Audio is definately an audio, and objects could be too. | ||
$this.find('object, audio').each(function () { | ||
hasCase = true; | ||
test.add(Case({ | ||
element: this, | ||
expected: $(this).closest('.quail-test').data('expected'), | ||
status: 'cantTell' | ||
})); | ||
}); | ||
|
||
// Links refering to files with an audio extensions are good indicators too | ||
$this.find('a[href]').each(function () { | ||
var $this = $(this); | ||
var extension = $this.attr('href').split('.').pop(); | ||
if ($.inArray(extension, audioExtensions) !== -1) { | ||
hasCase = true; | ||
test.add(Case({ | ||
element: this, | ||
expected: $this.closest('.quail-test').data('expected'), | ||
status: 'cantTell' | ||
})); | ||
} | ||
}); | ||
|
||
// if no case was added, return inapplicable | ||
if (!hasCase) { | ||
test.add(Case({ | ||
element: this, | ||
status: 'inapplicable', | ||
expected: $(this).closest('.quail-test').data('expected') | ||
})); | ||
} | ||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,46 @@ | ||
quail.documentIDsMustBeUnique = function(quail, test, Case) { | ||
var ids = {}; | ||
test.get('$scope').each(function(){ | ||
if($(this).children().length === 0) { | ||
test.add(Case({ | ||
element: this, | ||
'status': 'inapplicable', | ||
expected: $(this).closest('.quail-test').data('expected') | ||
})); | ||
} | ||
}); | ||
test.get('$scope').find(':not([id])').each(function() { | ||
var _case = Case({ | ||
element: this | ||
}); | ||
test.add(_case); | ||
_case.set({ | ||
test.add(Case({ | ||
element: this, | ||
'status': 'inapplicable', | ||
expected: $(this).closest('.quail-test').data('expected') | ||
}); | ||
})); | ||
}); | ||
test.get('$scope').find('[id]').each(function() { | ||
var _case = Case({ | ||
element: this, | ||
expected: (function (element) { | ||
return quail.components.resolveExpectation(element); | ||
}(this)) | ||
}); | ||
test.add(_case); | ||
if (typeof ids[$(this).attr('id')] === 'undefined') { | ||
_case.set({ | ||
'status': 'passed' | ||
}); | ||
ids[$(this).attr('id')] = $(this).attr('id'); | ||
} | ||
else { | ||
_case.set({ | ||
'status': 'failed' | ||
test.get('$scope').each(function(){ | ||
var ids = {}; | ||
$(this).find('[id]').each(function() { | ||
var _case = Case({ | ||
element: this, | ||
expected: (function (element) { | ||
return quail.components.resolveExpectation(element); | ||
}(this)) | ||
}); | ||
} | ||
test.add(_case); | ||
if(typeof ids[$(this).attr('id')] === 'undefined' && Object.keys(ids).length === 0){ | ||
_case.set({ | ||
'status': 'inapplicable' | ||
}); | ||
ids[$(this).attr('id')] = $(this).attr('id'); | ||
}else if (typeof ids[$(this).attr('id')] === 'undefined') { | ||
_case.set({ | ||
'status': 'passed' | ||
}); | ||
ids[$(this).attr('id')] = $(this).attr('id'); | ||
} | ||
else { | ||
_case.set({ | ||
'status': 'failed' | ||
}); | ||
} | ||
}); | ||
}); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
quail.headersAttrRefersToATableCell = function(quail, test, Case) { | ||
|
||
// Table cell headers without referred ids | ||
test.get('$scope').find('table').each(function() { | ||
|
||
var element = this; | ||
var _case = Case({ | ||
element: element, | ||
expected: $(this).closest('.quail-test').data('expected') | ||
}); | ||
test.add(_case); | ||
var elmHeaders = $(element).find('th[headers], td[headers]'); | ||
|
||
if (elmHeaders.length === 0) { | ||
_case.set({ | ||
'status': 'inapplicable' | ||
}); | ||
return; | ||
} else { | ||
elmHeaders.each(function() { | ||
var headers = $(this).attr('headers').split(/\s+/); | ||
$.each(headers, function(index, item) { | ||
if (item === "" || $(element).find('th#' + item + ',td#' + item).length > 0) { | ||
_case.set({ | ||
'status': 'passed' | ||
}); | ||
return; | ||
} else { | ||
_case.set({ | ||
'status': 'failed' | ||
}); | ||
return; | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.