This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marcy Sutton
committed
Feb 24, 2015
1 parent
361ae21
commit ef0a2f3
Showing
12 changed files
with
457 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
var q = require('q'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
_ = require('lodash'); | ||
|
||
var AUDIT_FILE = path.join(__dirname, '../../node_modules/accessibility-developer-tools/dist/js/axs_testing.js'); | ||
|
||
/** | ||
* You enable this plugin in your config file: | ||
* | ||
* // Chrome Accessibility Developer Tools: | ||
* exports.config = { | ||
* ... | ||
* plugins: { | ||
* ... | ||
* accessibility: { | ||
* developerTools: true, | ||
* } | ||
* } | ||
* } | ||
*/ | ||
|
||
/** | ||
* Checks the information returned by the accessibility audit and | ||
* displays passed/failed results as console output | ||
* | ||
* @param {Object} config The configuration file for the accessibility plugin | ||
* @return {q.Promise} A promise which resolves to the results of any passed or | ||
* failed tests | ||
* @public | ||
*/ | ||
function teardown(config) { | ||
|
||
var data = fs.readFileSync(AUDIT_FILE, 'utf-8'); | ||
data = data + ' return axs.Audit.run();'; | ||
|
||
var testOut = {failedCount: 0, specResults: []}, | ||
elementPromises = []; | ||
|
||
return browser.executeScript_(data, 'axs rules').then(function(results) { | ||
|
||
var audit = results.map(function (result) { | ||
|
||
var DOMElements = result.elements; | ||
if (DOMElements !== undefined) { | ||
DOMElements.forEach(function(elem) { | ||
// get elements from WebDriver | ||
elementPromises.push( | ||
elem.getOuterHtml().then(function(text) { | ||
return '\n\t\t' + text; | ||
}) | ||
); | ||
}); | ||
} | ||
|
||
if(result.result === 'FAIL') { | ||
result.passed = false; | ||
testOut.failedCount++; | ||
} | ||
else { | ||
result.passed = true; | ||
} | ||
|
||
return result; | ||
}); | ||
|
||
// Wait for element names to be fetched | ||
return q.all(elementPromises).then(function(message) { | ||
audit.forEach(function(result) { | ||
result.message = message; | ||
result.message += '\n\n\t\t' + result.rule.url; | ||
|
||
testOut.specResults.push({ | ||
description: result.rule.heading, | ||
assertions: [{passed: result.passed, errorMsg: result.message}], | ||
duration: 1 | ||
}); | ||
}); | ||
|
||
if ((testOut.failedCount > 0) || (testOut.specResults.length > 0)) { | ||
return testOut; | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
// Export | ||
exports.teardown = teardown; |
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,6 @@ | ||
describe('check if accessibility plugin works on bad apps', function() { | ||
it('should have accessibility problems on bad apps', function() { | ||
browser.get('accessibility/noContent.html'); | ||
browser.get('accessibility/unused.html'); | ||
}); | ||
}); |
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,11 @@ | ||
var env = require('../../../spec/environment.js'); | ||
|
||
exports.config = { | ||
seleniumAddress: env.seleniumAddress, | ||
framework: 'jasmine2', | ||
specs: ['fail_spec.js'], | ||
baseUrl: env.baseUrl, | ||
plugins: [{ | ||
path: '../index.js' | ||
}] | ||
}; |
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,11 @@ | ||
var env = require('../../../spec/environment.js'); | ||
|
||
exports.config = { | ||
seleniumAddress: env.seleniumAddress, | ||
framework: 'jasmine2', | ||
specs: ['success_spec.js'], | ||
baseUrl: env.baseUrl, | ||
plugins: [{ | ||
path: "../index.js" | ||
}] | ||
}; |
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,9 @@ | ||
describe('accessibility', function() { | ||
it('should get a file to test', function() { | ||
browser.get('accessibility/index.html'); | ||
|
||
element.all(by.css('input')).then(function(inputs) { | ||
expect(inputs.length).toEqual(2); | ||
}); | ||
}); | ||
}); |
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,20 @@ | ||
<!DOCTYPE html> | ||
|
||
<html ng-app="xApp"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Angular.js Example</title> | ||
<script src="../../lib/angular_v1.3.5/angular.min.js"></script> | ||
<script src="../../lib/angular_v1.3.5/angular-aria.min.js"></script> | ||
<script> | ||
angular.module('xApp', []); | ||
</script> | ||
</head> | ||
<body class="a11y"> | ||
First name:<input ng-model="firstName" type="text"/> | ||
<br> | ||
Last name:<input ng-model="lastName" type="text"/> | ||
<br> | ||
Hello {{firstName}} {{lastName}} | ||
</body> | ||
</html> |
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,15 @@ | ||
<!DOCTYPE html> | ||
|
||
<html ng-app ng-hint> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Angular.js Example</title> | ||
<script src="../lib/angular_v1.3.5/angular.min.js"></script> | ||
<script src="../lib/angular_v1.3.5/angular-aria.min.js"></script> | ||
<script> | ||
angular.module('xApp', []); | ||
</script> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
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,20 @@ | ||
<!DOCTYPE html> | ||
|
||
<html ng-app ng-hint> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Angular.js Example</title> | ||
<script src="../lib/angular_v1.3.5/angular.min.js"></script> | ||
<script src="../lib/angular_v1.3.5/angular-aria.min.js"></script> | ||
<script> | ||
angular.module('xApp', []); | ||
</script> | ||
</head> | ||
<body> | ||
First name:<input ng-model="firstName" type="text"/> | ||
<br> | ||
Last name:<input ng-model="lastName" type="text"/> | ||
<br> | ||
Hello {{firstName}} {{lastName}} | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.