This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from alice/master
Round colour contrast when checking for low contrast; allow configuration of maximum number of results for audit rule
- Loading branch information
Showing
13 changed files
with
200 additions
and
68 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 |
---|---|---|
@@ -1,34 +1,34 @@ | ||
module('BadAriaAttributeValue'); | ||
|
||
test('Empty idref value is ok', function() { | ||
var fixtures = document.getElementById('qunit-fixture'); | ||
var fixture = document.getElementById('qunit-fixture'); | ||
var div = document.createElement('div'); | ||
fixtures.appendChild(div); | ||
fixture.appendChild(div); | ||
div.setAttribute('aria-activedescendant', ''); | ||
deepEqual( | ||
axs.AuditRules.getRule('badAriaAttributeValue').run([], fixtures), | ||
axs.AuditRules.getRule('badAriaAttributeValue').run({ scope: fixture }), | ||
{ elements: [], result: axs.constants.AuditResult.PASS } | ||
); | ||
}); | ||
|
||
test('Bad number value doesn\'t cause crash', function() { | ||
var fixtures = document.getElementById('qunit-fixture'); | ||
var fixture = document.getElementById('qunit-fixture'); | ||
var div = document.createElement('div'); | ||
fixtures.appendChild(div); | ||
fixture.appendChild(div); | ||
div.setAttribute('aria-valuenow', 'foo'); | ||
deepEqual( | ||
axs.AuditRules.getRule('badAriaAttributeValue').run([], fixtures), | ||
axs.AuditRules.getRule('badAriaAttributeValue').run({ scope: fixture }), | ||
{ elements: [div], result: axs.constants.AuditResult.FAIL } | ||
); | ||
}); | ||
|
||
test('Good number value is good', function() { | ||
var fixtures = document.getElementById('qunit-fixture'); | ||
var fixture = document.getElementById('qunit-fixture'); | ||
var div = document.createElement('div'); | ||
fixtures.appendChild(div); | ||
fixture.appendChild(div); | ||
div.setAttribute('aria-valuenow', '10'); | ||
deepEqual( | ||
axs.AuditRules.getRule('badAriaAttributeValue').run([], fixtures), | ||
axs.AuditRules.getRule('badAriaAttributeValue').run({ scope: fixture }), | ||
{ elements: [], result: axs.constants.AuditResult.PASS } | ||
); | ||
}); |
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 |
---|---|---|
@@ -1,14 +1,65 @@ | ||
module("LowContrast"); | ||
|
||
test("No text = no relevant elements", function() { | ||
var fixture = document.getElementById('qunit-fixture'); | ||
var div = document.createElement('div'); | ||
div.style.backgroundColor = 'white'; | ||
div.style.color = 'white'; | ||
fixture.appendChild(div); | ||
deepEqual( | ||
axs.AuditRules.getRule('lowContrastElements').run({ scope: fixture }), | ||
{ result: axs.constants.AuditResult.NA } | ||
); | ||
}); | ||
|
||
test("Black on white = no problem", function() { | ||
var fixture = document.getElementById('qunit-fixture'); | ||
var div = document.createElement('div'); | ||
div.style.backgroundColor = 'white'; | ||
div.style.color = 'black'; | ||
div.textContent = 'Some text'; | ||
fixture.appendChild(div); | ||
deepEqual( | ||
axs.AuditRules.getRule('lowContrastElements').run({ scope: fixture }), | ||
{ elements: [], result: axs.constants.AuditResult.PASS } | ||
); | ||
}); | ||
|
||
test("Low contrast = fail", function() { | ||
var fixture = document.getElementById('qunit-fixture'); | ||
var div = document.createElement('div'); | ||
div.style.backgroundColor = 'white'; | ||
div.style.color = '#aaa'; // Contrast ratio = 2.32 | ||
div.textContent = 'Some text'; | ||
fixture.appendChild(div); | ||
deepEqual( | ||
axs.AuditRules.getRule('lowContrastElements').run({ scope: fixture }), | ||
{ elements: [div], result: axs.constants.AuditResult.FAIL } | ||
); | ||
}); | ||
|
||
test("Opacity is handled", function() { | ||
// Setup fixture | ||
var fixtures = document.getElementById('qunit-fixture'); | ||
var fixture = document.getElementById('qunit-fixture'); | ||
var elementWithOpacity = document.createElement('div'); | ||
elementWithOpacity.style.opacity = '0.4'; | ||
elementWithOpacity.textContent = 'Some text'; | ||
fixtures.appendChild(elementWithOpacity); | ||
fixture.appendChild(elementWithOpacity); | ||
deepEqual( | ||
axs.AuditRules.getRule('lowContrastElements').run([], fixtures), | ||
axs.AuditRules.getRule('lowContrastElements').run({ scope: fixture }), | ||
{ elements: [elementWithOpacity], result: axs.constants.AuditResult.FAIL } | ||
); | ||
}); | ||
|
||
test("Uses tolerance value", function() { | ||
var fixture = document.getElementById('qunit-fixture'); | ||
var div = document.createElement('div'); | ||
div.style.backgroundColor = 'white'; | ||
div.style.color = '#777'; // Contrast ratio = 4.48 | ||
div.textContent = 'Some text'; | ||
fixture.appendChild(div); | ||
deepEqual( | ||
axs.AuditRules.getRule('lowContrastElements').run({ scope: fixture }), | ||
{ elements: [], result: axs.constants.AuditResult.PASS } | ||
); | ||
}); |
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.