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.
Also includes missing Angular map files
- Loading branch information
Marcy Sutton
committed
Feb 24, 2015
1 parent
64704e0
commit 4dc1b9a
Showing
8 changed files
with
192 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
var q = require('q'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
_ = require('lodash'); | ||
|
||
/** | ||
* You can enable this plugin in your config file: | ||
* | ||
* // The Chrome Accessibility Developer Tools are currently | ||
* // the only integration option. | ||
* | ||
* exports.config = { | ||
* ... | ||
* plugins: [{ | ||
* chromeA11YDevTools: true, | ||
* path: 'node_modules/protractor.plugins/accessiblity' | ||
* }] | ||
* } | ||
* | ||
*/ | ||
|
||
var AUDIT_FILE = path.join(__dirname, '../../node_modules/accessibility-developer-tools/dist/js/axs_testing.js'); | ||
|
||
/** | ||
* 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) { | ||
|
||
if (config.chromeA11YDevTools) { | ||
|
||
var data = fs.readFileSync(AUDIT_FILE, 'utf-8'); | ||
data = data + ' return axs.Audit.run();'; | ||
|
||
var testOut = {failedCount: 0, specResults: []}, | ||
elementPromises = []; | ||
|
||
return browser.executeScript_(data, 'a11y developer tool 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, add to promises array | ||
elementPromises.push( | ||
elem.getOuterHtml().then(function(text) { | ||
return { | ||
code: result.rule.code, | ||
list: text | ||
}; | ||
}) | ||
); | ||
}); | ||
result.elementCount = DOMElements.length; | ||
} | ||
return result; | ||
}); | ||
|
||
// Wait for element names to be fetched | ||
return q.all(elementPromises).then(function(elementFailures) { | ||
|
||
audit.forEach(function(result, index) { | ||
if (result.result === 'FAIL') { | ||
result.passed = false; | ||
testOut.failedCount++; | ||
|
||
var label = result.elementCount === 1 ? ' element ' : ' elements '; | ||
result.output = '\n\t\t' + result.elementCount + label + 'failed:'; | ||
|
||
// match elements returned via promises | ||
// by their failure codes | ||
elementFailures.forEach(function(element, index) { | ||
if (element.code === result.rule.code) { | ||
result.output += '\n\t\t' + elementFailures[index].list; | ||
} | ||
}); | ||
result.message = 'warning -- Inaccessible markup'; | ||
} | ||
else { | ||
result.passed = true; | ||
result.output = null; | ||
result.message = null; | ||
} | ||
result.output += '\n\n\t\t' + result.rule.url; | ||
|
||
testOut.specResults.push({ | ||
description: result.rule.heading, | ||
assertions: [{ | ||
passed: result.passed, | ||
errorMsg: result.output, | ||
warningMsg: 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
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,21 @@ | ||
<!DOCTYPE html> | ||
|
||
<html ng-app ng-hint> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Angular.js Example</title> | ||
<script src="../lib/angular_v1.3.13/angular.min.js"></script> | ||
<script src="../lib/angular_v1.3.13/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}} | ||
<img src="http://example.com/img.jpg"> | ||
</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,23 @@ | ||
<!DOCTYPE html> | ||
|
||
<html ng-app="xApp"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Angular.js Example</title> | ||
<script src="../../lib/angular_v1.3.13/angular.min.js"></script> | ||
<script src="../../lib/angular_v1.3.13/angular-aria.min.js"></script> | ||
<script> | ||
angular.module('xApp', []); | ||
</script> | ||
</head> | ||
<body> | ||
<label for="firstName">First name:</label> | ||
<input ng-model="firstName" type="text" id="firstName" /> | ||
<br> | ||
<label for="lastName">Last name:</label> | ||
<input ng-model="lastName" type="text" id="lastName" /> | ||
<br> | ||
Hello {{firstName}} {{lastName}} | ||
<img src="http://example.com/img.jpg" alt="{{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
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.