aboutsummaryrefslogtreecommitdiff
path: root/guidelines
diff options
context:
space:
mode:
authorGravatar Benjamin Jones <bjones@galois.com>2013-07-11 16:07:03 -0700
committerGravatar Benjamin Jones <bjones@galois.com>2013-07-11 16:07:03 -0700
commit265f160e55d98b37aa8d8f9b16a1a5ccb32bdb0d (patch)
tree201e18d14c075b9cfd8097e693b020ce77ac72d1 /guidelines
parent7601ea165da8a865954df9dd49ecbf09f3556edd (diff)
added WCAG 1.0 Guideline 5 and test HTML for it
Diffstat (limited to 'guidelines')
-rw-r--r--guidelines/WCAG-1.0/guideline-5.js34
-rw-r--r--guidelines/WCAG-1.0/guideline-test.json6
-rw-r--r--guidelines/WCAG-1.0/test5.html40
3 files changed, 80 insertions, 0 deletions
diff --git a/guidelines/WCAG-1.0/guideline-5.js b/guidelines/WCAG-1.0/guideline-5.js
new file mode 100644
index 0000000..48feb49
--- /dev/null
+++ b/guidelines/WCAG-1.0/guideline-5.js
@@ -0,0 +1,34 @@
+exports.name = "WCAG 1.0 Guideline 5: Tables";
+exports.description = "Web Accessibility Guideline: Create tables that transform gracefully";
+exports.rule = function(report) {
+
+ /* Checkpoint 5.1 ***********************************************************
+ *
+ * For data tables, identify row and column headers.
+ */
+
+ $('table').each(function () {
+ if ($(this).find('th').length == 0) {
+ report.error('Table does not have column headers <TH>', this);
+ }
+ });
+
+
+ /* Checkpoint 5.5 ***********************************************************
+ *
+ * Provide summaries for tables.
+ */
+
+ $('table').each(function () {
+ var $cap = $(this).find('caption');
+ var title = $.trim($(this).attr('title'));
+ var sum = $.trim($(this).attr('summary'));
+ if ($cap.length == 0 && (title === undefined || title == '')) {
+ report.error('Table has no caption or title attribute', this);
+ }
+ if (sum === undefined || sum == '') {
+ report.error('Table has no summary attribute', this);
+ }
+ });
+
+};
diff --git a/guidelines/WCAG-1.0/guideline-test.json b/guidelines/WCAG-1.0/guideline-test.json
new file mode 100644
index 0000000..29bfaa3
--- /dev/null
+++ b/guidelines/WCAG-1.0/guideline-test.json
@@ -0,0 +1,6 @@
+{ "name": "guideline-test"
+, "description": "Test WCAG guidelines"
+, "license": "BSD3"
+, "rules":
+ [ "guideline-5.js" ]
+}
diff --git a/guidelines/WCAG-1.0/test5.html b/guidelines/WCAG-1.0/test5.html
new file mode 100644
index 0000000..8700531
--- /dev/null
+++ b/guidelines/WCAG-1.0/test5.html
@@ -0,0 +1,40 @@
+<html>
+ <head>
+ <title>Test 5</title>
+ <style type="txt/css">
+ table { border: 2px solid black; }
+ </style>
+ </head>
+ <body>
+
+ Hello World!
+
+ <!-- expect caption/title failure, summary failure, headers failure -->
+ <table>
+ <tbody>
+ <tr><td>A first row that's not a header</td><td>Another col</td></tr>
+ <tr><td>A first row that's not a header</td><td>Another col</td></tr>
+ </tbody></table>
+
+ Hello Wisconsin!
+
+ <!-- expect headers failure -->
+ <table title='some table' summary='summary of a table'>
+ <tbody>
+ <tr><td>WI</td> <td>A first row that's not a header</td><td>Another col</td></tr>
+ <tr><td>WI</td> <td>A first row that's not a header</td><td>Another col</td></tr>
+ </tbody></table>
+
+ Hello Oregon!
+
+ <!-- expect no failures-->
+ <table title='some table with headers' summary='summary of a table with headers'>
+ <caption>A mighty good table</caption>
+ <tbody>
+ <tr><th>State</th> <th>head 1</th> <th>head 2</th></tr>
+ <tr><td>OR</td> <td>A first row that's not a header</td> <td>Another col</td></tr>
+ <tr><td>OR</td> <td>A first row that's not a header</td> <td>Another col</td></tr>
+ </tbody></table>
+
+ <!-- expect 4 failures -->
+</body></html>