access_lint 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +0 -6
- data/lib/access_lint/version.rb +1 -1
- data/vendor/access-lint/README.md +34 -0
- data/vendor/access-lint/bin/auditor.js +29 -0
- data/vendor/access-lint/test.html +2 -0
- data/vendor/access-lint/vendor/google-chrome/axs_testing.js +1546 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 055aeefa3d58a7afaf7751bdc5f0cc75da096a5e
|
4
|
+
data.tar.gz: b61cf331d28cac860726a00fee4fd3c9616c17e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2525c9c3f57a24376933c860a8bdc3b21f05efef384cfd35e31c4fdfbee39c8279ff62785b1c6efb73b3758169f1027207317f26cb39fff137742ef01e450945
|
7
|
+
data.tar.gz: fd72e8ee8da340aca4bac14b86075437c42c7170c4f23ea19933dd0283bedc988af6f69ae627b379f0c9c8fcd004b3492f892eeb0d782ebef72b7d37e7e13987
|
data/.gitmodules
CHANGED
@@ -1,9 +1,3 @@
|
|
1
1
|
[submodule "vendor/accessibility-developer-tools"]
|
2
2
|
path = vendor/accessibility-developer-tools
|
3
3
|
url = https://github.com/GoogleChrome/accessibility-developer-tools.git
|
4
|
-
[submodule "access-lint"]
|
5
|
-
path = access-lint
|
6
|
-
url = https://github.com/ckundo/access-lint.git
|
7
|
-
[submodule "vendor/access-lint"]
|
8
|
-
path = vendor/access-lint
|
9
|
-
url = https://github.com/ckundo/access-lint.git
|
data/lib/access_lint/version.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
# access-lint
|
2
|
+
A command line runner for [Google's Accessibility Developer Tools](https://github.com/GoogleChrome/accessibility-developer-tools).
|
3
|
+
|
4
|
+
Google's Accessibility Developer Tools perform basic accessibility assertions on a rendered page.
|
5
|
+
This runner applies those assertions via the command line during a [phantomjs](http://phantomjs.org/) session.
|
6
|
+
Use it with the knowledge that it *will not capture most accessibility failures*.
|
7
|
+
These assertions catch "low-hanging fruit".
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
$ cd /path/to/access-lint/
|
12
|
+
$ git submodule update --init
|
13
|
+
$ phantomjs bin/auditor.js <url or filepath>
|
14
|
+
|
15
|
+
## Example
|
16
|
+
|
17
|
+
$ phantomjs auditor.js http://github.com # you can also audit a file
|
18
|
+
> *** Begin accessibility audit results ***
|
19
|
+
An accessibility audit found
|
20
|
+
Warnings:
|
21
|
+
Warning: AX_FOCUS_01 (These elements are focusable but either invisible or obscured by another element) failed on the following element:
|
22
|
+
body > .container > .site-footer > A
|
23
|
+
See https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules#AX_FOCUS_01:_These_elements_are_focusable_but_either_invisible_o for more information.
|
24
|
+
|
25
|
+
Warning: AX_COLOR_01 (Text elements should have a reasonable contrast ratio) failed on the following elements (1 - 5 of 15):
|
26
|
+
#site-container > .marketing-section.marketing-benefits > .container > .row > .one-third.column:nth-of-type(3) > P > A
|
27
|
+
#site-container > .marketing-section.marketing-desktop > .container > .marketing-header > .show-mac.show-linux > .text-muted
|
28
|
+
#site-container > .marketing-section.marketing-desktop > .container > .marketing-header > .show-mac.show-linux > .text-muted > A
|
29
|
+
body > .container > .site-footer > .site-footer-links.right > LI > A
|
30
|
+
body > .container > .site-footer > .site-footer-links.right > LI:nth-of-type(2) > A
|
31
|
+
See https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules#AX_COLOR_01:_Text_elements_should_have_a_reasonable_contrast_rat for more information.
|
32
|
+
|
33
|
+
|
34
|
+
*** End accessibility audit results ***
|
@@ -0,0 +1,29 @@
|
|
1
|
+
// do stuff
|
2
|
+
var page = require('webpage').create(),
|
3
|
+
system = require('system'),
|
4
|
+
url;
|
5
|
+
|
6
|
+
if (system.args.length !== 2) {
|
7
|
+
console.log('Usage: phantomjs auditor.js URL');
|
8
|
+
phantom.exit();
|
9
|
+
} else {
|
10
|
+
url = system.args[1];
|
11
|
+
page.open(url, function (status) {
|
12
|
+
if (status === 'success') {
|
13
|
+
page.injectJs('../vendor/google-chrome/axs_testing.js');
|
14
|
+
var report = page.evaluate(function() {
|
15
|
+
var results = axs.Audit.run();
|
16
|
+
return axs.Audit.createReport(results);
|
17
|
+
});
|
18
|
+
console.log(report);
|
19
|
+
phantom.exit();
|
20
|
+
} else {
|
21
|
+
console.log('Failed to load the page at ' +
|
22
|
+
url +
|
23
|
+
". Status was: " +
|
24
|
+
status
|
25
|
+
);
|
26
|
+
phantom.exit();
|
27
|
+
}
|
28
|
+
});
|
29
|
+
}
|
@@ -0,0 +1,1546 @@
|
|
1
|
+
var COMPILED = !0, goog = goog || {};
|
2
|
+
goog.global = this;
|
3
|
+
goog.exportPath_ = function(a, b, c) {
|
4
|
+
a = a.split(".");
|
5
|
+
c = c || goog.global;
|
6
|
+
a[0] in c || !c.execScript || c.execScript("var " + a[0]);
|
7
|
+
for(var d;a.length && (d = a.shift());) {
|
8
|
+
a.length || void 0 === b ? c = c[d] ? c[d] : c[d] = {} : c[d] = b
|
9
|
+
}
|
10
|
+
};
|
11
|
+
goog.define = function(a, b) {
|
12
|
+
var c = b;
|
13
|
+
COMPILED || goog.global.CLOSURE_DEFINES && Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES, a) && (c = goog.global.CLOSURE_DEFINES[a]);
|
14
|
+
goog.exportPath_(a, c)
|
15
|
+
};
|
16
|
+
goog.DEBUG = !0;
|
17
|
+
goog.LOCALE = "en";
|
18
|
+
goog.TRUSTED_SITE = !0;
|
19
|
+
goog.provide = function(a) {
|
20
|
+
if(!COMPILED) {
|
21
|
+
if(goog.isProvided_(a)) {
|
22
|
+
throw Error('Namespace "' + a + '" already declared.');
|
23
|
+
}
|
24
|
+
delete goog.implicitNamespaces_[a];
|
25
|
+
for(var b = a;(b = b.substring(0, b.lastIndexOf("."))) && !goog.getObjectByName(b);) {
|
26
|
+
goog.implicitNamespaces_[b] = !0
|
27
|
+
}
|
28
|
+
}
|
29
|
+
goog.exportPath_(a)
|
30
|
+
};
|
31
|
+
goog.setTestOnly = function(a) {
|
32
|
+
if(COMPILED && !goog.DEBUG) {
|
33
|
+
throw a = a || "", Error("Importing test-only code into non-debug environment" + a ? ": " + a : ".");
|
34
|
+
}
|
35
|
+
};
|
36
|
+
COMPILED || (goog.isProvided_ = function(a) {
|
37
|
+
return!goog.implicitNamespaces_[a] && !!goog.getObjectByName(a)
|
38
|
+
}, goog.implicitNamespaces_ = {});
|
39
|
+
goog.getObjectByName = function(a, b) {
|
40
|
+
for(var c = a.split("."), d = b || goog.global, e;e = c.shift();) {
|
41
|
+
if(goog.isDefAndNotNull(d[e])) {
|
42
|
+
d = d[e]
|
43
|
+
}else {
|
44
|
+
return null
|
45
|
+
}
|
46
|
+
}
|
47
|
+
return d
|
48
|
+
};
|
49
|
+
goog.globalize = function(a, b) {
|
50
|
+
var c = b || goog.global, d;
|
51
|
+
for(d in a) {
|
52
|
+
c[d] = a[d]
|
53
|
+
}
|
54
|
+
};
|
55
|
+
goog.addDependency = function(a, b, c) {
|
56
|
+
if(goog.DEPENDENCIES_ENABLED) {
|
57
|
+
var d;
|
58
|
+
a = a.replace(/\\/g, "/");
|
59
|
+
for(var e = goog.dependencies_, f = 0;d = b[f];f++) {
|
60
|
+
e.nameToPath[d] = a, a in e.pathToNames || (e.pathToNames[a] = {}), e.pathToNames[a][d] = !0
|
61
|
+
}
|
62
|
+
for(d = 0;b = c[d];d++) {
|
63
|
+
a in e.requires || (e.requires[a] = {}), e.requires[a][b] = !0
|
64
|
+
}
|
65
|
+
}
|
66
|
+
};
|
67
|
+
goog.ENABLE_DEBUG_LOADER = !0;
|
68
|
+
goog.require = function(a) {
|
69
|
+
if(!COMPILED && !goog.isProvided_(a)) {
|
70
|
+
if(goog.ENABLE_DEBUG_LOADER) {
|
71
|
+
var b = goog.getPathFromDeps_(a);
|
72
|
+
if(b) {
|
73
|
+
goog.included_[b] = !0;
|
74
|
+
goog.writeScripts_();
|
75
|
+
return
|
76
|
+
}
|
77
|
+
}
|
78
|
+
a = "goog.require could not find: " + a;
|
79
|
+
goog.global.console && goog.global.console.error(a);
|
80
|
+
throw Error(a);
|
81
|
+
}
|
82
|
+
};
|
83
|
+
goog.basePath = "";
|
84
|
+
goog.nullFunction = function() {
|
85
|
+
};
|
86
|
+
goog.identityFunction = function(a, b) {
|
87
|
+
return a
|
88
|
+
};
|
89
|
+
goog.abstractMethod = function() {
|
90
|
+
throw Error("unimplemented abstract method");
|
91
|
+
};
|
92
|
+
goog.addSingletonGetter = function(a) {
|
93
|
+
a.getInstance = function() {
|
94
|
+
if(a.instance_) {
|
95
|
+
return a.instance_
|
96
|
+
}
|
97
|
+
goog.DEBUG && (goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = a);
|
98
|
+
return a.instance_ = new a
|
99
|
+
}
|
100
|
+
};
|
101
|
+
goog.instantiatedSingletons_ = [];
|
102
|
+
goog.DEPENDENCIES_ENABLED = !COMPILED && goog.ENABLE_DEBUG_LOADER;
|
103
|
+
goog.DEPENDENCIES_ENABLED && (goog.included_ = {}, goog.dependencies_ = {pathToNames:{}, nameToPath:{}, requires:{}, visited:{}, written:{}}, goog.inHtmlDocument_ = function() {
|
104
|
+
var a = goog.global.document;
|
105
|
+
return"undefined" != typeof a && "write" in a
|
106
|
+
}, goog.findBasePath_ = function() {
|
107
|
+
if(goog.global.CLOSURE_BASE_PATH) {
|
108
|
+
goog.basePath = goog.global.CLOSURE_BASE_PATH
|
109
|
+
}else {
|
110
|
+
if(goog.inHtmlDocument_()) {
|
111
|
+
for(var a = goog.global.document.getElementsByTagName("script"), b = a.length - 1;0 <= b;--b) {
|
112
|
+
var c = a[b].src, d = c.lastIndexOf("?"), d = -1 == d ? c.length : d;
|
113
|
+
if("base.js" == c.substr(d - 7, 7)) {
|
114
|
+
goog.basePath = c.substr(0, d - 7);
|
115
|
+
break
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}, goog.importScript_ = function(a) {
|
121
|
+
var b = goog.global.CLOSURE_IMPORT_SCRIPT || goog.writeScriptTag_;
|
122
|
+
!goog.dependencies_.written[a] && b(a) && (goog.dependencies_.written[a] = !0)
|
123
|
+
}, goog.writeScriptTag_ = function(a) {
|
124
|
+
if(goog.inHtmlDocument_()) {
|
125
|
+
var b = goog.global.document;
|
126
|
+
if("complete" == b.readyState) {
|
127
|
+
if(/\bdeps.js$/.test(a)) {
|
128
|
+
return!1
|
129
|
+
}
|
130
|
+
throw Error('Cannot write "' + a + '" after document load');
|
131
|
+
}
|
132
|
+
b.write('<script type="text/javascript" src="' + a + '">\x3c/script>');
|
133
|
+
return!0
|
134
|
+
}
|
135
|
+
return!1
|
136
|
+
}, goog.writeScripts_ = function() {
|
137
|
+
function a(e) {
|
138
|
+
if(!(e in d.written)) {
|
139
|
+
if(!(e in d.visited) && (d.visited[e] = !0, e in d.requires)) {
|
140
|
+
for(var g in d.requires[e]) {
|
141
|
+
if(!goog.isProvided_(g)) {
|
142
|
+
if(g in d.nameToPath) {
|
143
|
+
a(d.nameToPath[g])
|
144
|
+
}else {
|
145
|
+
throw Error("Undefined nameToPath for " + g);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
e in c || (c[e] = !0, b.push(e))
|
151
|
+
}
|
152
|
+
}
|
153
|
+
var b = [], c = {}, d = goog.dependencies_, e;
|
154
|
+
for(e in goog.included_) {
|
155
|
+
d.written[e] || a(e)
|
156
|
+
}
|
157
|
+
for(e = 0;e < b.length;e++) {
|
158
|
+
if(b[e]) {
|
159
|
+
goog.importScript_(goog.basePath + b[e])
|
160
|
+
}else {
|
161
|
+
throw Error("Undefined script input");
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}, goog.getPathFromDeps_ = function(a) {
|
165
|
+
return a in goog.dependencies_.nameToPath ? goog.dependencies_.nameToPath[a] : null
|
166
|
+
}, goog.findBasePath_(), goog.global.CLOSURE_NO_DEPS || goog.importScript_(goog.basePath + "deps.js"));
|
167
|
+
goog.typeOf = function(a) {
|
168
|
+
var b = typeof a;
|
169
|
+
if("object" == b) {
|
170
|
+
if(a) {
|
171
|
+
if(a instanceof Array) {
|
172
|
+
return"array"
|
173
|
+
}
|
174
|
+
if(a instanceof Object) {
|
175
|
+
return b
|
176
|
+
}
|
177
|
+
var c = Object.prototype.toString.call(a);
|
178
|
+
if("[object Window]" == c) {
|
179
|
+
return"object"
|
180
|
+
}
|
181
|
+
if("[object Array]" == c || "number" == typeof a.length && "undefined" != typeof a.splice && "undefined" != typeof a.propertyIsEnumerable && !a.propertyIsEnumerable("splice")) {
|
182
|
+
return"array"
|
183
|
+
}
|
184
|
+
if("[object Function]" == c || "undefined" != typeof a.call && "undefined" != typeof a.propertyIsEnumerable && !a.propertyIsEnumerable("call")) {
|
185
|
+
return"function"
|
186
|
+
}
|
187
|
+
}else {
|
188
|
+
return"null"
|
189
|
+
}
|
190
|
+
}else {
|
191
|
+
if("function" == b && "undefined" == typeof a.call) {
|
192
|
+
return"object"
|
193
|
+
}
|
194
|
+
}
|
195
|
+
return b
|
196
|
+
};
|
197
|
+
goog.isDef = function(a) {
|
198
|
+
return void 0 !== a
|
199
|
+
};
|
200
|
+
goog.isNull = function(a) {
|
201
|
+
return null === a
|
202
|
+
};
|
203
|
+
goog.isDefAndNotNull = function(a) {
|
204
|
+
return null != a
|
205
|
+
};
|
206
|
+
goog.isArray = function(a) {
|
207
|
+
return"array" == goog.typeOf(a)
|
208
|
+
};
|
209
|
+
goog.isArrayLike = function(a) {
|
210
|
+
var b = goog.typeOf(a);
|
211
|
+
return"array" == b || "object" == b && "number" == typeof a.length
|
212
|
+
};
|
213
|
+
goog.isDateLike = function(a) {
|
214
|
+
return goog.isObject(a) && "function" == typeof a.getFullYear
|
215
|
+
};
|
216
|
+
goog.isString = function(a) {
|
217
|
+
return"string" == typeof a
|
218
|
+
};
|
219
|
+
goog.isBoolean = function(a) {
|
220
|
+
return"boolean" == typeof a
|
221
|
+
};
|
222
|
+
goog.isNumber = function(a) {
|
223
|
+
return"number" == typeof a
|
224
|
+
};
|
225
|
+
goog.isFunction = function(a) {
|
226
|
+
return"function" == goog.typeOf(a)
|
227
|
+
};
|
228
|
+
goog.isObject = function(a) {
|
229
|
+
var b = typeof a;
|
230
|
+
return"object" == b && null != a || "function" == b
|
231
|
+
};
|
232
|
+
goog.getUid = function(a) {
|
233
|
+
return a[goog.UID_PROPERTY_] || (a[goog.UID_PROPERTY_] = ++goog.uidCounter_)
|
234
|
+
};
|
235
|
+
goog.removeUid = function(a) {
|
236
|
+
"removeAttribute" in a && a.removeAttribute(goog.UID_PROPERTY_);
|
237
|
+
try {
|
238
|
+
delete a[goog.UID_PROPERTY_]
|
239
|
+
}catch(b) {
|
240
|
+
}
|
241
|
+
};
|
242
|
+
goog.UID_PROPERTY_ = "closure_uid_" + (1E9 * Math.random() >>> 0);
|
243
|
+
goog.uidCounter_ = 0;
|
244
|
+
goog.getHashCode = goog.getUid;
|
245
|
+
goog.removeHashCode = goog.removeUid;
|
246
|
+
goog.cloneObject = function(a) {
|
247
|
+
var b = goog.typeOf(a);
|
248
|
+
if("object" == b || "array" == b) {
|
249
|
+
if(a.clone) {
|
250
|
+
return a.clone()
|
251
|
+
}
|
252
|
+
var b = "array" == b ? [] : {}, c;
|
253
|
+
for(c in a) {
|
254
|
+
b[c] = goog.cloneObject(a[c])
|
255
|
+
}
|
256
|
+
return b
|
257
|
+
}
|
258
|
+
return a
|
259
|
+
};
|
260
|
+
goog.bindNative_ = function(a, b, c) {
|
261
|
+
return a.call.apply(a.bind, arguments)
|
262
|
+
};
|
263
|
+
goog.bindJs_ = function(a, b, c) {
|
264
|
+
if(!a) {
|
265
|
+
throw Error();
|
266
|
+
}
|
267
|
+
if(2 < arguments.length) {
|
268
|
+
var d = Array.prototype.slice.call(arguments, 2);
|
269
|
+
return function() {
|
270
|
+
var c = Array.prototype.slice.call(arguments);
|
271
|
+
Array.prototype.unshift.apply(c, d);
|
272
|
+
return a.apply(b, c)
|
273
|
+
}
|
274
|
+
}
|
275
|
+
return function() {
|
276
|
+
return a.apply(b, arguments)
|
277
|
+
}
|
278
|
+
};
|
279
|
+
goog.bind = function(a, b, c) {
|
280
|
+
Function.prototype.bind && -1 != Function.prototype.bind.toString().indexOf("native code") ? goog.bind = goog.bindNative_ : goog.bind = goog.bindJs_;
|
281
|
+
return goog.bind.apply(null, arguments)
|
282
|
+
};
|
283
|
+
goog.partial = function(a, b) {
|
284
|
+
var c = Array.prototype.slice.call(arguments, 1);
|
285
|
+
return function() {
|
286
|
+
var b = Array.prototype.slice.call(arguments);
|
287
|
+
b.unshift.apply(b, c);
|
288
|
+
return a.apply(this, b)
|
289
|
+
}
|
290
|
+
};
|
291
|
+
goog.mixin = function(a, b) {
|
292
|
+
for(var c in b) {
|
293
|
+
a[c] = b[c]
|
294
|
+
}
|
295
|
+
};
|
296
|
+
goog.now = goog.TRUSTED_SITE && Date.now || function() {
|
297
|
+
return+new Date
|
298
|
+
};
|
299
|
+
goog.globalEval = function(a) {
|
300
|
+
if(goog.global.execScript) {
|
301
|
+
goog.global.execScript(a, "JavaScript")
|
302
|
+
}else {
|
303
|
+
if(goog.global.eval) {
|
304
|
+
if(null == goog.evalWorksForGlobals_ && (goog.global.eval("var _et_ = 1;"), "undefined" != typeof goog.global._et_ ? (delete goog.global._et_, goog.evalWorksForGlobals_ = !0) : goog.evalWorksForGlobals_ = !1), goog.evalWorksForGlobals_) {
|
305
|
+
goog.global.eval(a)
|
306
|
+
}else {
|
307
|
+
var b = goog.global.document, c = b.createElement("script");
|
308
|
+
c.type = "text/javascript";
|
309
|
+
c.defer = !1;
|
310
|
+
c.appendChild(b.createTextNode(a));
|
311
|
+
b.body.appendChild(c);
|
312
|
+
b.body.removeChild(c)
|
313
|
+
}
|
314
|
+
}else {
|
315
|
+
throw Error("goog.globalEval not available");
|
316
|
+
}
|
317
|
+
}
|
318
|
+
};
|
319
|
+
goog.evalWorksForGlobals_ = null;
|
320
|
+
goog.getCssName = function(a, b) {
|
321
|
+
var c = function(a) {
|
322
|
+
return goog.cssNameMapping_[a] || a
|
323
|
+
}, d = function(a) {
|
324
|
+
a = a.split("-");
|
325
|
+
for(var b = [], d = 0;d < a.length;d++) {
|
326
|
+
b.push(c(a[d]))
|
327
|
+
}
|
328
|
+
return b.join("-")
|
329
|
+
}, d = goog.cssNameMapping_ ? "BY_WHOLE" == goog.cssNameMappingStyle_ ? c : d : function(a) {
|
330
|
+
return a
|
331
|
+
};
|
332
|
+
return b ? a + "-" + d(b) : d(a)
|
333
|
+
};
|
334
|
+
goog.setCssNameMapping = function(a, b) {
|
335
|
+
goog.cssNameMapping_ = a;
|
336
|
+
goog.cssNameMappingStyle_ = b
|
337
|
+
};
|
338
|
+
!COMPILED && goog.global.CLOSURE_CSS_NAME_MAPPING && (goog.cssNameMapping_ = goog.global.CLOSURE_CSS_NAME_MAPPING);
|
339
|
+
goog.getMsg = function(a, b) {
|
340
|
+
var c = b || {}, d;
|
341
|
+
for(d in c) {
|
342
|
+
var e = ("" + c[d]).replace(/\$/g, "$$$$");
|
343
|
+
a = a.replace(RegExp("\\{\\$" + d + "\\}", "gi"), e)
|
344
|
+
}
|
345
|
+
return a
|
346
|
+
};
|
347
|
+
goog.getMsgWithFallback = function(a, b) {
|
348
|
+
return a
|
349
|
+
};
|
350
|
+
goog.exportSymbol = function(a, b, c) {
|
351
|
+
goog.exportPath_(a, b, c)
|
352
|
+
};
|
353
|
+
goog.exportProperty = function(a, b, c) {
|
354
|
+
a[b] = c
|
355
|
+
};
|
356
|
+
goog.inherits = function(a, b) {
|
357
|
+
function c() {
|
358
|
+
}
|
359
|
+
c.prototype = b.prototype;
|
360
|
+
a.superClass_ = b.prototype;
|
361
|
+
a.prototype = new c;
|
362
|
+
a.prototype.constructor = a
|
363
|
+
};
|
364
|
+
goog.base = function(a, b, c) {
|
365
|
+
var d = arguments.callee.caller;
|
366
|
+
if(goog.DEBUG && !d) {
|
367
|
+
throw Error("arguments.caller not defined. goog.base() expects not to be running in strict mode. See http://www.ecma-international.org/ecma-262/5.1/#sec-C");
|
368
|
+
}
|
369
|
+
if(d.superClass_) {
|
370
|
+
return d.superClass_.constructor.apply(a, Array.prototype.slice.call(arguments, 1))
|
371
|
+
}
|
372
|
+
for(var e = Array.prototype.slice.call(arguments, 2), f = !1, g = a.constructor;g;g = g.superClass_ && g.superClass_.constructor) {
|
373
|
+
if(g.prototype[b] === d) {
|
374
|
+
f = !0
|
375
|
+
}else {
|
376
|
+
if(f) {
|
377
|
+
return g.prototype[b].apply(a, e)
|
378
|
+
}
|
379
|
+
}
|
380
|
+
}
|
381
|
+
if(a[b] === d) {
|
382
|
+
return a.constructor.prototype[b].apply(a, e)
|
383
|
+
}
|
384
|
+
throw Error("goog.base called from a method of one name to a method of a different name");
|
385
|
+
};
|
386
|
+
goog.scope = function(a) {
|
387
|
+
a.call(goog.global)
|
388
|
+
};
|
389
|
+
var axs = {AuditResults:function() {
|
390
|
+
this.errors_ = [];
|
391
|
+
this.warnings_ = []
|
392
|
+
}};
|
393
|
+
goog.exportSymbol("axs.AuditResults", axs.AuditResults);
|
394
|
+
axs.AuditResults.prototype.addError = function(a) {
|
395
|
+
"" != a && this.errors_.push(a)
|
396
|
+
};
|
397
|
+
goog.exportProperty(axs.AuditResults.prototype, "addError", axs.AuditResults.prototype.addError);
|
398
|
+
axs.AuditResults.prototype.addWarning = function(a) {
|
399
|
+
"" != a && this.warnings_.push(a)
|
400
|
+
};
|
401
|
+
goog.exportProperty(axs.AuditResults.prototype, "addWarning", axs.AuditResults.prototype.addWarning);
|
402
|
+
axs.AuditResults.prototype.numErrors = function() {
|
403
|
+
return this.errors_.length
|
404
|
+
};
|
405
|
+
goog.exportProperty(axs.AuditResults.prototype, "numErrors", axs.AuditResults.prototype.numErrors);
|
406
|
+
axs.AuditResults.prototype.numWarnings = function() {
|
407
|
+
return this.warnings_.length
|
408
|
+
};
|
409
|
+
goog.exportProperty(axs.AuditResults.prototype, "numWarnings", axs.AuditResults.prototype.numWarnings);
|
410
|
+
axs.AuditResults.prototype.getErrors = function() {
|
411
|
+
return this.errors_
|
412
|
+
};
|
413
|
+
goog.exportProperty(axs.AuditResults.prototype, "getErrors", axs.AuditResults.prototype.getErrors);
|
414
|
+
axs.AuditResults.prototype.getWarnings = function() {
|
415
|
+
return this.warnings_
|
416
|
+
};
|
417
|
+
goog.exportProperty(axs.AuditResults.prototype, "getWarnings", axs.AuditResults.prototype.getWarnings);
|
418
|
+
axs.AuditResults.prototype.toString = function() {
|
419
|
+
for(var a = "", b = 0;b < this.errors_.length;b++) {
|
420
|
+
0 == b && (a += "\nErrors:\n");
|
421
|
+
var c = this.errors_[b], a = a + (c + "\n\n")
|
422
|
+
}
|
423
|
+
for(b = 0;b < this.warnings_.length;b++) {
|
424
|
+
0 == b && (a += "\nWarnings:\n"), c = this.warnings_[b], a += c + "\n\n"
|
425
|
+
}
|
426
|
+
return a
|
427
|
+
};
|
428
|
+
goog.exportProperty(axs.AuditResults.prototype, "toString", axs.AuditResults.prototype.toString);
|
429
|
+
axs.browserUtils = {};
|
430
|
+
axs.browserUtils.matchSelector = function(a, b) {
|
431
|
+
return a.webkitMatchesSelector ? a.webkitMatchesSelector(b) : a.mozMatchesSelector(b)
|
432
|
+
};
|
433
|
+
axs.constants = {};
|
434
|
+
axs.constants.ARIA_ROLES = {alert:{namefrom:["author"], parent:["region"]}, alertdialog:{namefrom:["author"], namerequired:!0, parent:["alert", "dialog"]}, application:{namefrom:["author"], namerequired:!0, parent:["landmark"]}, article:{namefrom:["author"], parent:["document", "region"]}, banner:{namefrom:["author"], parent:["landmark"]}, button:{childpresentational:!0, namefrom:["contents", "author"], namerequired:!0, parent:["command"], properties:["aria-expanded", "aria-pressed"]}, checkbox:{namefrom:["contents",
|
435
|
+
"author"], namerequired:!0, parent:["input"], requiredProperties:["aria-checked"], properties:["aria-checked"]}, columnheader:{namefrom:["contents", "author"], namerequired:!0, parent:["gridcell", "sectionhead", "widget"], properties:["aria-sort"]}, combobox:{mustcontain:["listbox", "textbox"], namefrom:["author"], namerequired:!0, parent:["select"], requiredProperties:["aria-expanded"], properties:["aria-expanded", "aria-autocomplete", "aria-required"]}, command:{"abstract":!0, namefrom:["author"],
|
436
|
+
parent:["widget"]}, complementary:{namefrom:["author"], parent:["landmark"]}, composite:{"abstract":!0, childpresentational:!1, namefrom:["author"], parent:["widget"], properties:["aria-activedescendant"]}, contentinfo:{namefrom:["author"], parent:["landmark"]}, definition:{namefrom:["author"], parent:["section"]}, dialog:{namefrom:["author"], namerequired:!0, parent:["window"]}, directory:{namefrom:["contents", "author"], parent:["list"]}, document:{namefrom:[" author"], namerequired:!0, parent:["structure"],
|
437
|
+
properties:["aria-expanded"]}, form:{namefrom:["author"], parent:["landmark"]}, grid:{mustcontain:["row", "rowgroup"], namefrom:["author"], namerequired:!0, parent:["composite", "region"], properties:["aria-level", "aria-multiselectable", "aria-readonly"]}, gridcell:{namefrom:["contents", "author"], namerequired:!0, parent:["section", "widget"], properties:["aria-readonly", "aria-required", "aria-selected"]}, group:{namefrom:[" author"], parent:["section"], properties:["aria-activedescendant"]},
|
438
|
+
heading:{namerequired:!0, parent:["sectionhead"], properties:["aria-level"]}, img:{childpresentational:!0, namefrom:["author"], namerequired:!0, parent:["section"]}, input:{"abstract":!0, namefrom:["author"], parent:["widget"]}, landmark:{"abstract":!0, namefrom:["contents", "author"], namerequired:!1, parent:["region"]}, link:{namefrom:["contents", "author"], namerequired:!0, parent:["command"], properties:["aria-expanded"]}, list:{mustcontain:["group", "listitem"], namefrom:["author"], parent:["region"]},
|
439
|
+
listbox:{mustcontain:["option"], namefrom:["author"], namerequired:!0, parent:["list", "select"], properties:["aria-multiselectable", "aria-required"]}, listitem:{namefrom:["contents", "author"], namerequired:!0, parent:["section"], properties:["aria-level", "aria-posinset", "aria-setsize"]}, log:{namefrom:[" author"], namerequired:!0, parent:["region"]}, main:{namefrom:["author"], parent:["landmark"]}, marquee:{namerequired:!0, parent:["section"]}, math:{childpresentational:!0, namefrom:["author"],
|
440
|
+
parent:["section"]}, menu:{mustcontain:["group", "menuitemradio", "menuitem", "menuitemcheckbox"], namefrom:["author"], namerequired:!0, parent:["list", "select"]}, menubar:{namefrom:["author"], parent:["menu"]}, menuitem:{namefrom:["contents", "author"], namerequired:!0, parent:["command"]}, menuitemcheckbox:{namefrom:["contents", "author"], namerequired:!0, parent:["checkbox", "menuitem"]}, menuitemradio:{namefrom:["contents", "author"], namerequired:!0, parent:["menuitemcheckbox", "radio"]}, navigation:{namefrom:["author"],
|
441
|
+
parent:["landmark"]}, note:{namefrom:["author"], parent:["section"]}, option:{namefrom:["contents", "author"], namerequired:!0, parent:["input"], properties:["aria-checked", "aria-posinset", "aria-selected", "aria-setsize"]}, presentation:{parent:["structure"]}, progressbar:{childpresentational:!0, namefrom:["author"], namerequired:!0, parent:["range"]}, radio:{namefrom:["contents", "author"], namerequired:!0, parent:["checkbox", "option"]}, radiogroup:{mustcontain:["radio"], namefrom:["author"],
|
442
|
+
namerequired:!0, parent:["select"], properties:["aria-required"]}, range:{"abstract":!0, namefrom:["author"], parent:["widget"], properties:["aria-valuemax", "aria-valuemin", "aria-valuenow", "aria-valuetext"]}, region:{namefrom:[" author"], parent:["section"]}, roletype:{"abstract":!0, properties:"aria-atomic aria-busy aria-controls aria-describedby aria-disabled aria-dropeffect aria-flowto aria-grabbed aria-haspopup aria-hidden aria-invalid aria-label aria-labelledby aria-live aria-owns aria-relevant".split(" ")},
|
443
|
+
row:{mustcontain:["columnheader", "gridcell", "rowheader"], namefrom:["contents", "author"], parent:["group", "widget"], properties:["aria-level", "aria-selected"]}, rowgroup:{mustcontain:["row"], namefrom:["contents", "author"], parent:["group"]}, rowheader:{namefrom:["contents", "author"], namerequired:!0, parent:["gridcell", "sectionhead", "widget"], properties:["aria-sort"]}, search:{namefrom:["author"], parent:["landmark"]}, section:{"abstract":!0, namefrom:["contents", "author"], parent:["structure"],
|
444
|
+
properties:["aria-expanded"]}, sectionhead:{"abstract":!0, namefrom:["contents", "author"], parent:["structure"], properties:["aria-expanded"]}, select:{"abstract":!0, namefrom:["author"], parent:["composite", "group", "input"]}, separator:{childpresentational:!0, namefrom:["author"], parent:["structure"], properties:["aria-expanded", "aria-orientation"]}, scrollbar:{childpresentational:!0, namefrom:["author"], namerequired:!1, parent:["input", "range"], requiredProperties:["aria-controls", "aria-orientation",
|
445
|
+
"aria-valuemax", "aria-valuemin", "aria-valuenow"], properties:["aria-controls", "aria-orientation", "aria-valuemax", "aria-valuemin", "aria-valuenow"]}, slider:{childpresentational:!0, namefrom:["author"], namerequired:!0, parent:["input", "range"], requiredProperties:["aria-valuemax", "aria-valuemin", "aria-valuenow"], properties:["aria-valuemax", "aria-valuemin", "aria-valuenow", "aria-orientation"]}, spinbutton:{namefrom:["author"], namerequired:!0, parent:["input", "range"], requiredProperties:["aria-valuemax",
|
446
|
+
"aria-valuemin", "aria-valuenow"], properties:["aria-valuemax", "aria-valuemin", "aria-valuenow", "aria-required"]}, status:{parent:["region"]}, structure:{"abstract":!0, parent:["roletype"]}, tab:{namefrom:["contents", "author"], parent:["sectionhead", "widget"], properties:["aria-selected"]}, tablist:{mustcontain:["tab"], namefrom:["author"], parent:["composite", "directory"], properties:["aria-level"]}, tabpanel:{namefrom:["author"], namerequired:!0, parent:["region"]}, textbox:{namefrom:["author"],
|
447
|
+
namerequired:!0, parent:["input"], properties:["aria-activedescendant", "aria-autocomplete", "aria-multiline", "aria-readonly", "aria-required"]}, timer:{namefrom:["author"], namerequired:!0, parent:["status"]}, toolbar:{namefrom:["author"], parent:["group"]}, tooltip:{namerequired:!0, parent:["section"]}, tree:{mustcontain:["group", "treeitem"], namefrom:["author"], namerequired:!0, parent:["select"], properties:["aria-multiselectable", "aria-required"]}, treegrid:{mustcontain:["row"], namefrom:["author"],
|
448
|
+
namerequired:!0, parent:["grid", "tree"]}, treeitem:{namefrom:["contents", "author"], namerequired:!0, parent:["listitem", "option"]}, widget:{"abstract":!0, parent:["roletype"]}, window:{"abstract":!0, namefrom:[" author"], parent:["roletype"], properties:["aria-expanded"]}};
|
449
|
+
axs.constants.WIDGET_ROLES = {};
|
450
|
+
axs.constants.addAllParentRolesToSet_ = function(a, b) {
|
451
|
+
if(a.parent) {
|
452
|
+
for(var c = a.parent, d = 0;d < c.length;d++) {
|
453
|
+
var e = c[d];
|
454
|
+
b[e] = !0;
|
455
|
+
axs.constants.addAllParentRolesToSet_(axs.constants.ARIA_ROLES[e], b)
|
456
|
+
}
|
457
|
+
}
|
458
|
+
};
|
459
|
+
axs.constants.addAllPropertiesToSet_ = function(a, b, c) {
|
460
|
+
var d = a[b];
|
461
|
+
if(d) {
|
462
|
+
for(var e = 0;e < d.length;e++) {
|
463
|
+
c[d[e]] = !0
|
464
|
+
}
|
465
|
+
}
|
466
|
+
if(a.parent) {
|
467
|
+
for(a = a.parent, d = 0;d < a.length;d++) {
|
468
|
+
axs.constants.addAllPropertiesToSet_(axs.constants.ARIA_ROLES[a[d]], b, c)
|
469
|
+
}
|
470
|
+
}
|
471
|
+
};
|
472
|
+
for(var roleName in axs.constants.ARIA_ROLES) {
|
473
|
+
var role = axs.constants.ARIA_ROLES[roleName], propertiesSet = {};
|
474
|
+
axs.constants.addAllPropertiesToSet_(role, "properties", propertiesSet);
|
475
|
+
role.propertiesSet = propertiesSet;
|
476
|
+
var requiredPropertiesSet = {};
|
477
|
+
axs.constants.addAllPropertiesToSet_(role, "requiredProperties", requiredPropertiesSet);
|
478
|
+
role.requiredPropertiesSet = requiredPropertiesSet;
|
479
|
+
var parentRolesSet = {};
|
480
|
+
axs.constants.addAllParentRolesToSet_(role, parentRolesSet);
|
481
|
+
role.allParentRolesSet = parentRolesSet;
|
482
|
+
"widget" in parentRolesSet && (axs.constants.WIDGET_ROLES[roleName] = role)
|
483
|
+
}
|
484
|
+
axs.constants.ARIA_PROPERTIES = {activedescendant:{type:"property", valueType:"idref"}, atomic:{defaultValue:"false", type:"property", valueType:"boolean"}, autocomplete:{defaultValue:"none", type:"property", valueType:"token", values:["inline", "list", "both", "none"]}, busy:{defaultValue:"false", type:"state", valueType:"boolean"}, checked:{defaultValue:"undefined", type:"state", valueType:"token", values:["true", "false", "mixed", "undefined"]}, controls:{type:"property", valueType:"idref_list"},
|
485
|
+
describedby:{type:"property", valueType:"idref_list"}, disabled:{defaultValue:"false", type:"state", valueType:"boolean"}, dropeffect:{defaultValue:"none", type:"property", valueType:"token_list", values:"copy move link execute popup none".split(" ")}, expanded:{defaultValue:"undefined", type:"state", valueType:"token", values:["true", "false", "undefined"]}, flowto:{type:"property", valueType:"idref_list"}, grabbed:{defaultValue:"undefined", type:"state", valueType:"token", values:["true", "false",
|
486
|
+
"undefined"]}, haspopup:{defaultValue:"false", type:"property", valueType:"boolean"}, hidden:{defaultValue:"false", type:"state", valueType:"boolean"}, invalid:{defaultValue:"false", type:"state", valueType:"token", values:["grammar", "false", "spelling", "true"]}, label:{type:"property", valueType:"string"}, labelledby:{type:"property", valueType:"idref_list"}, level:{type:"property", valueType:"integer"}, live:{defaultValue:"off", type:"property", valueType:"token", values:["off", "polite", "assertive"]},
|
487
|
+
multiline:{defaultValue:"false", type:"property", valueType:"boolean"}, multiselectable:{defaultValue:"false", type:"property", valueType:"boolean"}, orientation:{defaultValue:"vertical", type:"property", valueType:"token", values:["horizontal", "vertical"]}, owns:{type:"property", valueType:"idref_list"}, posinset:{type:"property", valueType:"integer"}, pressed:{defaultValue:"undefined", type:"state", valueType:"token", values:["true", "false", "mixed", "undefined"]}, readonly:{defaultValue:"false",
|
488
|
+
type:"property", valueType:"boolean"}, relevant:{defaultValue:"additions text", type:"property", valueType:"token_list", values:["additions", "removals", "text", "all"]}, required:{defaultValue:"false", type:"property", valueType:"boolean"}, selected:{defaultValue:"undefined", type:"state", valueType:"token", values:["true", "false", "undefined"]}, setsize:{type:"property", valueType:"integer"}, sort:{defaultValue:"none", type:"property", valueType:"token", values:["ascending", "descending", "none",
|
489
|
+
"other"]}, valuemax:{type:"property", valueType:"decimal"}, valuemin:{type:"property", valueType:"decimal"}, valuenow:{type:"property", valueType:"decimal"}, valuetext:{type:"property", valueType:"string"}};
|
490
|
+
axs.constants.GLOBAL_PROPERTIES = "aria-atomic aria-busy aria-controls aria-describedby aria-disabled aria-dropeffect aria-flowto aria-grabbed aria-haspopup aria-hidden aria-invalid aria-label aria-labelledby aria-live aria-owns aria-relevant".split(" ");
|
491
|
+
axs.constants.NO_ROLE_NAME = " ";
|
492
|
+
axs.constants.WIDGET_ROLE_TO_NAME = {alert:"aria_role_alert", alertdialog:"aria_role_alertdialog", button:"aria_role_button", checkbox:"aria_role_checkbox", columnheader:"aria_role_columnheader", combobox:"aria_role_combobox", dialog:"aria_role_dialog", grid:"aria_role_grid", gridcell:"aria_role_gridcell", link:"aria_role_link", listbox:"aria_role_listbox", log:"aria_role_log", marquee:"aria_role_marquee", menu:"aria_role_menu", menubar:"aria_role_menubar", menuitem:"aria_role_menuitem", menuitemcheckbox:"aria_role_menuitemcheckbox",
|
493
|
+
menuitemradio:"aria_role_menuitemradio", option:axs.constants.NO_ROLE_NAME, progressbar:"aria_role_progressbar", radio:"aria_role_radio", radiogroup:"aria_role_radiogroup", rowheader:"aria_role_rowheader", scrollbar:"aria_role_scrollbar", slider:"aria_role_slider", spinbutton:"aria_role_spinbutton", status:"aria_role_status", tab:"aria_role_tab", tabpanel:"aria_role_tabpanel", textbox:"aria_role_textbox", timer:"aria_role_timer", toolbar:"aria_role_toolbar", tooltip:"aria_role_tooltip", treeitem:"aria_role_treeitem"};
|
494
|
+
axs.constants.STRUCTURE_ROLE_TO_NAME = {article:"aria_role_article", application:"aria_role_application", banner:"aria_role_banner", columnheader:"aria_role_columnheader", complementary:"aria_role_complementary", contentinfo:"aria_role_contentinfo", definition:"aria_role_definition", directory:"aria_role_directory", document:"aria_role_document", form:"aria_role_form", group:"aria_role_group", heading:"aria_role_heading", img:"aria_role_img", list:"aria_role_list", listitem:"aria_role_listitem",
|
495
|
+
main:"aria_role_main", math:"aria_role_math", navigation:"aria_role_navigation", note:"aria_role_note", region:"aria_role_region", rowheader:"aria_role_rowheader", search:"aria_role_search", separator:"aria_role_separator"};
|
496
|
+
axs.constants.ATTRIBUTE_VALUE_TO_STATUS = [{name:"aria-autocomplete", values:{inline:"aria_autocomplete_inline", list:"aria_autocomplete_list", both:"aria_autocomplete_both"}}, {name:"aria-checked", values:{"true":"aria_checked_true", "false":"aria_checked_false", mixed:"aria_checked_mixed"}}, {name:"aria-disabled", values:{"true":"aria_disabled_true"}}, {name:"aria-expanded", values:{"true":"aria_expanded_true", "false":"aria_expanded_false"}}, {name:"aria-invalid", values:{"true":"aria_invalid_true",
|
497
|
+
grammar:"aria_invalid_grammar", spelling:"aria_invalid_spelling"}}, {name:"aria-multiline", values:{"true":"aria_multiline_true"}}, {name:"aria-multiselectable", values:{"true":"aria_multiselectable_true"}}, {name:"aria-pressed", values:{"true":"aria_pressed_true", "false":"aria_pressed_false", mixed:"aria_pressed_mixed"}}, {name:"aria-readonly", values:{"true":"aria_readonly_true"}}, {name:"aria-required", values:{"true":"aria_required_true"}}, {name:"aria-selected", values:{"true":"aria_selected_true",
|
498
|
+
"false":"aria_selected_false"}}];
|
499
|
+
axs.constants.INPUT_TYPE_TO_INFORMATION_TABLE_MSG = {button:"input_type_button", checkbox:"input_type_checkbox", color:"input_type_color", datetime:"input_type_datetime", "datetime-local":"input_type_datetime_local", date:"input_type_date", email:"input_type_email", file:"input_type_file", image:"input_type_image", month:"input_type_month", number:"input_type_number", password:"input_type_password", radio:"input_type_radio", range:"input_type_range", reset:"input_type_reset", search:"input_type_search",
|
500
|
+
submit:"input_type_submit", tel:"input_type_tel", text:"input_type_text", url:"input_type_url", week:"input_type_week"};
|
501
|
+
axs.constants.TAG_TO_INFORMATION_TABLE_VERBOSE_MSG = {A:"tag_link", BUTTON:"tag_button", H1:"tag_h1", H2:"tag_h2", H3:"tag_h3", H4:"tag_h4", H5:"tag_h5", H6:"tag_h6", LI:"tag_li", OL:"tag_ol", SELECT:"tag_select", TEXTAREA:"tag_textarea", UL:"tag_ul", SECTION:"tag_section", NAV:"tag_nav", ARTICLE:"tag_article", ASIDE:"tag_aside", HGROUP:"tag_hgroup", HEADER:"tag_header", FOOTER:"tag_footer", TIME:"tag_time", MARK:"tag_mark"};
|
502
|
+
axs.constants.TAG_TO_INFORMATION_TABLE_BRIEF_MSG = {BUTTON:"tag_button", SELECT:"tag_select", TEXTAREA:"tag_textarea"};
|
503
|
+
axs.constants.MIXED_VALUES = {"true":!0, "false":!0, mixed:!0};
|
504
|
+
for(var propertyName in axs.constants.ARIA_PROPERTIES) {
|
505
|
+
var propertyDetails = axs.constants.ARIA_PROPERTIES[propertyName];
|
506
|
+
if(propertyDetails.values) {
|
507
|
+
for(var valuesSet = {}, i = 0;i < propertyDetails.values.length;i++) {
|
508
|
+
valuesSet[propertyDetails.values[i]] = !0
|
509
|
+
}
|
510
|
+
propertyDetails.valuesSet = valuesSet
|
511
|
+
}
|
512
|
+
}
|
513
|
+
axs.constants.Severity = {INFO:"Info", WARNING:"Warning", SEVERE:"Severe"};
|
514
|
+
axs.constants.AuditResult = {PASS:"PASS", FAIL:"FAIL", NA:"NA"};
|
515
|
+
axs.constants.InlineElements = {TT:!0, I:!0, B:!0, BIG:!0, SMALL:!0, EM:!0, STRONG:!0, DFN:!0, CODE:!0, SAMP:!0, KBD:!0, VAR:!0, CITE:!0, ABBR:!0, ACRONYM:!0, A:!0, IMG:!0, OBJECT:!0, BR:!0, SCRIPT:!0, MAP:!0, Q:!0, SUB:!0, SUP:!0, SPAN:!0, BDO:!0, INPUT:!0, SELECT:!0, TEXTAREA:!0, LABEL:!0, BUTTON:!0};
|
516
|
+
axs.utils = {};
|
517
|
+
axs.utils.FOCUSABLE_ELEMENTS_SELECTOR = "input:not([type=hidden]):not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),a[href],iframe,[tabindex]";
|
518
|
+
axs.utils.Color = function(a, b, c, d) {
|
519
|
+
this.red = a;
|
520
|
+
this.green = b;
|
521
|
+
this.blue = c;
|
522
|
+
this.alpha = d
|
523
|
+
};
|
524
|
+
axs.utils.calculateContrastRatio = function(a, b) {
|
525
|
+
if(!a || !b) {
|
526
|
+
return null
|
527
|
+
}
|
528
|
+
1 > a.alpha && (a = axs.utils.flattenColors(a, b));
|
529
|
+
var c = axs.utils.calculateLuminance(a), d = axs.utils.calculateLuminance(b);
|
530
|
+
return(Math.max(c, d) + 0.05) / (Math.min(c, d) + 0.05)
|
531
|
+
};
|
532
|
+
axs.utils.luminanceRatio = function(a, b) {
|
533
|
+
return(Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05)
|
534
|
+
};
|
535
|
+
axs.utils.asElement = function(a) {
|
536
|
+
switch(a.nodeType) {
|
537
|
+
case Node.COMMENT_NODE:
|
538
|
+
return null;
|
539
|
+
case Node.ELEMENT_NODE:
|
540
|
+
if("script" == a.tagName.toLowerCase()) {
|
541
|
+
return null
|
542
|
+
}
|
543
|
+
break;
|
544
|
+
case Node.TEXT_NODE:
|
545
|
+
a = a.parentElement;
|
546
|
+
break;
|
547
|
+
default:
|
548
|
+
return console.warn("Unhandled node type: ", a.nodeType), null
|
549
|
+
}
|
550
|
+
return a
|
551
|
+
};
|
552
|
+
axs.utils.elementIsTransparent = function(a) {
|
553
|
+
return"0" == a.style.opacity
|
554
|
+
};
|
555
|
+
axs.utils.elementHasZeroArea = function(a) {
|
556
|
+
a = a.getBoundingClientRect();
|
557
|
+
var b = a.top - a.bottom;
|
558
|
+
return a.right - a.left && b ? !1 : !0
|
559
|
+
};
|
560
|
+
axs.utils.elementIsOutsideScrollArea = function(a) {
|
561
|
+
a = a.getBoundingClientRect();
|
562
|
+
var b = document.body.scrollWidth, c = document.body.scrollTop, d = document.body.scrollLeft;
|
563
|
+
return a.top >= document.body.scrollHeight || a.bottom <= -c || a.left >= b || a.right <= -d ? !0 : !1
|
564
|
+
};
|
565
|
+
axs.utils.overlappingElement = function(a) {
|
566
|
+
function b(a, c) {
|
567
|
+
return null == c ? !1 : c === a ? !0 : b(a, c.parentNode)
|
568
|
+
}
|
569
|
+
if(axs.utils.elementHasZeroArea(a)) {
|
570
|
+
return null
|
571
|
+
}
|
572
|
+
var c = a.getBoundingClientRect(), c = document.elementFromPoint((c.left + c.right) / 2, (c.top + c.bottom) / 2);
|
573
|
+
return null == c || c == a || b(c, a) ? null : c
|
574
|
+
};
|
575
|
+
axs.utils.elementIsHtmlControl = function(a) {
|
576
|
+
var b = a.ownerDocument.defaultView;
|
577
|
+
return a instanceof b.HTMLButtonElement || a instanceof b.HTMLInputElement || a instanceof b.HTMLSelectElement || a instanceof b.HTMLTextAreaElement ? !0 : !1
|
578
|
+
};
|
579
|
+
axs.utils.elementIsAriaWidget = function(a) {
|
580
|
+
return a.hasAttribute("role") && (a = a.getAttribute("role")) && (a = axs.constants.ARIA_ROLES[a]) && "widget" in a.allParentRolesSet ? !0 : !1
|
581
|
+
};
|
582
|
+
axs.utils.elementIsVisible = function(a) {
|
583
|
+
if(axs.utils.elementIsTransparent(a) || axs.utils.elementHasZeroArea(a) || axs.utils.elementIsOutsideScrollArea(a)) {
|
584
|
+
return!1
|
585
|
+
}
|
586
|
+
if(a = axs.utils.overlappingElement(a)) {
|
587
|
+
var b = window.getComputedStyle(a, null);
|
588
|
+
if(b && (a = axs.utils.getBgColor(b, a)) && 0 < a.alpha) {
|
589
|
+
return!1
|
590
|
+
}
|
591
|
+
}
|
592
|
+
return!0
|
593
|
+
};
|
594
|
+
axs.utils.isLargeFont = function(a) {
|
595
|
+
var b = a.fontSize;
|
596
|
+
a = "bold" == a.fontWeight;
|
597
|
+
var c = b.match(/(\d+)px/);
|
598
|
+
if(c) {
|
599
|
+
b = parseInt(c[1], 10);
|
600
|
+
if(c = window.getComputedStyle(document.body, null).fontSize.match(/(\d+)px/)) {
|
601
|
+
var d = parseInt(c[1], 10), c = 1.2 * d, d = 1.5 * d
|
602
|
+
}else {
|
603
|
+
c = 19.2, d = 24
|
604
|
+
}
|
605
|
+
return a && b >= c || b >= d
|
606
|
+
}
|
607
|
+
if(c = b.match(/(\d+)em/)) {
|
608
|
+
return b = parseInt(c[1], 10), a && 1.2 <= b || 1.5 <= b ? !0 : !1
|
609
|
+
}
|
610
|
+
if(c = b.match(/(\d+)%/)) {
|
611
|
+
return b = parseInt(c[1], 10), a && 120 <= b || 150 <= b ? !0 : !1
|
612
|
+
}
|
613
|
+
if(c = b.match(/(\d+)pt/)) {
|
614
|
+
if(b = parseInt(c[1], 10), a && 14 <= b || 14 <= b) {
|
615
|
+
return!0
|
616
|
+
}
|
617
|
+
}
|
618
|
+
return!1
|
619
|
+
};
|
620
|
+
axs.utils.getBgColor = function(a, b) {
|
621
|
+
var c = axs.utils.parseColor(a.backgroundColor);
|
622
|
+
if(!c || a.backgroundImage && "none" != a.backgroundImage) {
|
623
|
+
return null
|
624
|
+
}
|
625
|
+
if(1 > c.alpha) {
|
626
|
+
var d = b, e = [];
|
627
|
+
e.push(c);
|
628
|
+
for(c = null;d = d.parentElement;) {
|
629
|
+
var f = window.getComputedStyle(d, null);
|
630
|
+
if(f) {
|
631
|
+
if(f.backgroundImage && "none" != f.backgroundImage) {
|
632
|
+
return null
|
633
|
+
}
|
634
|
+
if((f = axs.utils.parseColor(f.backgroundColor)) && 0 != f.alpha && (e.push(f), 1 == f.alpha)) {
|
635
|
+
c = null;
|
636
|
+
break
|
637
|
+
}
|
638
|
+
}
|
639
|
+
}
|
640
|
+
c || e.push(new axs.utils.Color(255, 255, 255, 1));
|
641
|
+
for(d = e.pop();e.length;) {
|
642
|
+
c = e.pop(), d = axs.utils.flattenColors(c, d)
|
643
|
+
}
|
644
|
+
c = d
|
645
|
+
}
|
646
|
+
return c
|
647
|
+
};
|
648
|
+
axs.utils.getFgColor = function(a, b) {
|
649
|
+
var c = axs.utils.parseColor(a.color);
|
650
|
+
if(!c) {
|
651
|
+
return null
|
652
|
+
}
|
653
|
+
1 > c.alpha && (c = axs.utils.flattenColors(c, b));
|
654
|
+
return c
|
655
|
+
};
|
656
|
+
axs.utils.parseColor = function(a) {
|
657
|
+
var b = a.match(/^rgb\((\d+), (\d+), (\d+)\)$/);
|
658
|
+
if(b) {
|
659
|
+
a = parseInt(b[1], 10);
|
660
|
+
var c = parseInt(b[2], 10), b = parseInt(b[3], 10), d;
|
661
|
+
return new axs.utils.Color(a, c, b, 1)
|
662
|
+
}
|
663
|
+
return(b = a.match(/^rgba\((\d+), (\d+), (\d+), (\d+(\.\d+)?)\)/)) ? (d = parseInt(b[4], 10), a = parseInt(b[1], 10), c = parseInt(b[2], 10), b = parseInt(b[3], 10), new axs.utils.Color(a, c, b, d)) : null
|
664
|
+
};
|
665
|
+
axs.utils.colorChannelToString = function(a) {
|
666
|
+
return 15 >= a ? "0" + a.toString(16) : a.toString(16)
|
667
|
+
};
|
668
|
+
axs.utils.colorToString = function(a) {
|
669
|
+
return 1 == a.alpha ? "#" + axs.utils.colorChannelToString(a.red) + axs.utils.colorChannelToString(a.green) + axs.utils.colorChannelToString(a.blue) : "rgba(" + [a.red, a.green, a.blue, a.alpha].join() + ")"
|
670
|
+
};
|
671
|
+
axs.utils.luminanceFromContrastRatio = function(a, b, c) {
|
672
|
+
return c ? (a + 0.05) * b - 0.05 : (a + 0.05) / b - 0.05
|
673
|
+
};
|
674
|
+
axs.utils.translateColor = function(a, b) {
|
675
|
+
var c = a[0], c = (b - c) / ((c > b ? 0 : 1) - c);
|
676
|
+
return axs.utils.fromYCC([b, a[1] - a[1] * c, a[2] - a[2] * c])
|
677
|
+
};
|
678
|
+
axs.utils.suggestColors = function(a, b, c, d) {
|
679
|
+
if(!axs.utils.isLowContrast(c, d, !0)) {
|
680
|
+
return null
|
681
|
+
}
|
682
|
+
var e = {}, f = axs.utils.calculateLuminance(a), g = axs.utils.calculateLuminance(b), h = axs.utils.isLargeFont(d) ? 3 : 4.5, k = axs.utils.isLargeFont(d) ? 4.5 : 7, m = g > f, l = axs.utils.luminanceFromContrastRatio(f, h + 0.02, m), n = axs.utils.luminanceFromContrastRatio(f, k + 0.02, m), q = axs.utils.toYCC(b);
|
683
|
+
if(axs.utils.isLowContrast(c, d, !1) && 1 >= l && 0 <= l) {
|
684
|
+
var p = axs.utils.translateColor(q, l), l = axs.utils.calculateContrastRatio(p, a);
|
685
|
+
axs.utils.calculateLuminance(p);
|
686
|
+
f = {};
|
687
|
+
f.fg = axs.utils.colorToString(p);
|
688
|
+
f.bg = axs.utils.colorToString(a);
|
689
|
+
f.contrast = l.toFixed(2);
|
690
|
+
e.AA = f
|
691
|
+
}
|
692
|
+
axs.utils.isLowContrast(c, d, !0) && (1 >= n && 0 <= n) && (n = axs.utils.translateColor(q, n), l = axs.utils.calculateContrastRatio(n, a), f = {}, f.fg = axs.utils.colorToString(n), f.bg = axs.utils.colorToString(a), f.contrast = l.toFixed(2), e.AAA = f);
|
693
|
+
h = axs.utils.luminanceFromContrastRatio(g, h + 0.02, !m);
|
694
|
+
g = axs.utils.luminanceFromContrastRatio(g, k + 0.02, !m);
|
695
|
+
a = axs.utils.toYCC(a);
|
696
|
+
!("AA" in e) && (axs.utils.isLowContrast(c, d, !1) && 1 >= h && 0 <= h) && (k = axs.utils.translateColor(a, h), l = axs.utils.calculateContrastRatio(b, k), f = {}, f.bg = axs.utils.colorToString(k), f.fg = axs.utils.colorToString(b), f.contrast = l.toFixed(2), e.AA = f);
|
697
|
+
!("AAA" in e) && (axs.utils.isLowContrast(c, d, !0) && 1 >= g && 0 <= g) && (c = axs.utils.translateColor(a, g), l = axs.utils.calculateContrastRatio(b, c), f = {}, f.bg = axs.utils.colorToString(c), f.fg = axs.utils.colorToString(b), f.contrast = l.toFixed(2), e.AAA = f);
|
698
|
+
return e
|
699
|
+
};
|
700
|
+
axs.utils.flattenColors = function(a, b) {
|
701
|
+
var c = a.alpha;
|
702
|
+
return new axs.utils.Color((1 - c) * b.red + c * a.red, (1 - c) * b.green + c * a.green, (1 - c) * b.blue + c * a.blue, 1)
|
703
|
+
};
|
704
|
+
axs.utils.calculateLuminance = function(a) {
|
705
|
+
return axs.utils.toYCC(a)[0]
|
706
|
+
};
|
707
|
+
axs.utils.RGBToYCCMatrix = function(a, b) {
|
708
|
+
return[[a, 1 - a - b, b], [-a / (2 - 2 * b), (a + b - 1) / (2 - 2 * b), (1 - b) / (2 - 2 * b)], [(1 - a) / (2 - 2 * a), (a + b - 1) / (2 - 2 * a), -b / (2 - 2 * a)]]
|
709
|
+
};
|
710
|
+
axs.utils.invert3x3Matrix = function(a) {
|
711
|
+
var b = a[0][0], c = a[0][1], d = a[0][2], e = a[1][0], f = a[1][1], g = a[1][2], h = a[2][0], k = a[2][1];
|
712
|
+
a = a[2][2];
|
713
|
+
return axs.utils.scalarMultiplyMatrix([[f * a - g * k, d * k - c * a, c * g - d * f], [g * h - e * a, b * a - d * h, d * e - b * g], [e * k - f * h, h * c - b * k, b * f - c * e]], 1 / (b * (f * a - g * k) - c * (a * e - g * h) + d * (e * k - f * h)))
|
714
|
+
};
|
715
|
+
axs.utils.scalarMultiplyMatrix = function(a, b) {
|
716
|
+
for(var c = [[], [], []], d = 0;3 > d;d++) {
|
717
|
+
for(var e = 0;3 > e;e++) {
|
718
|
+
c[d][e] = a[d][e] * b
|
719
|
+
}
|
720
|
+
}
|
721
|
+
return c
|
722
|
+
};
|
723
|
+
axs.utils.kR = 0.2126;
|
724
|
+
axs.utils.kB = 0.0722;
|
725
|
+
axs.utils.YCC_MATRIX = axs.utils.RGBToYCCMatrix(axs.utils.kR, axs.utils.kB);
|
726
|
+
axs.utils.INVERTED_YCC_MATRIX = axs.utils.invert3x3Matrix(axs.utils.YCC_MATRIX);
|
727
|
+
axs.utils.convertColor = function(a, b) {
|
728
|
+
var c = b[0], d = b[1], e = b[2];
|
729
|
+
return[a[0][0] * c + a[0][1] * d + a[0][2] * e, a[1][0] * c + a[1][1] * d + a[1][2] * e, a[2][0] * c + a[2][1] * d + a[2][2] * e]
|
730
|
+
};
|
731
|
+
axs.utils.multiplyMatrices = function(a, b) {
|
732
|
+
for(var c = [[], [], []], d = 0;3 > d;d++) {
|
733
|
+
for(var e = 0;3 > e;e++) {
|
734
|
+
c[d][e] = a[d][0] * b[0][e] + a[d][1] * b[1][e] + a[d][2] * b[2][e]
|
735
|
+
}
|
736
|
+
}
|
737
|
+
return c
|
738
|
+
};
|
739
|
+
axs.utils.toYCC = function(a) {
|
740
|
+
var b = a.red / 255, c = a.green / 255;
|
741
|
+
a = a.blue / 255;
|
742
|
+
b = 0.03928 >= b ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4);
|
743
|
+
c = 0.03928 >= c ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
744
|
+
a = 0.03928 >= a ? a / 12.92 : Math.pow((a + 0.055) / 1.055, 2.4);
|
745
|
+
return axs.utils.convertColor(axs.utils.YCC_MATRIX, [b, c, a])
|
746
|
+
};
|
747
|
+
axs.utils.fromYCC = function(a) {
|
748
|
+
var b = axs.utils.convertColor(axs.utils.INVERTED_YCC_MATRIX, a), c = b[0];
|
749
|
+
a = b[1];
|
750
|
+
b = b[2];
|
751
|
+
c = 0.00303949 >= c ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;
|
752
|
+
a = 0.00303949 >= a ? 12.92 * a : 1.055 * Math.pow(a, 1 / 2.4) - 0.055;
|
753
|
+
b = 0.00303949 >= b ? 12.92 * b : 1.055 * Math.pow(b, 1 / 2.4) - 0.055;
|
754
|
+
c = Math.min(Math.max(Math.round(255 * c), 0), 255);
|
755
|
+
a = Math.min(Math.max(Math.round(255 * a), 0), 255);
|
756
|
+
b = Math.min(Math.max(Math.round(255 * b), 0), 255);
|
757
|
+
return new axs.utils.Color(c, a, b, 1)
|
758
|
+
};
|
759
|
+
axs.utils.scalarMultiplyMatrix = function(a, b) {
|
760
|
+
for(var c = [[], [], []], d = 0;3 > d;d++) {
|
761
|
+
for(var e = 0;3 > e;e++) {
|
762
|
+
c[d][e] = a[d][e] * b
|
763
|
+
}
|
764
|
+
}
|
765
|
+
return c
|
766
|
+
};
|
767
|
+
axs.utils.multiplyMatrices = function(a, b) {
|
768
|
+
for(var c = [[], [], []], d = 0;3 > d;d++) {
|
769
|
+
for(var e = 0;3 > e;e++) {
|
770
|
+
c[d][e] = a[d][0] * b[0][e] + a[d][1] * b[1][e] + a[d][2] * b[2][e]
|
771
|
+
}
|
772
|
+
}
|
773
|
+
return c
|
774
|
+
};
|
775
|
+
axs.utils.getContrastRatioForElement = function(a) {
|
776
|
+
var b = window.getComputedStyle(a, null);
|
777
|
+
return axs.utils.getContrastRatioForElementWithComputedStyle(b, a)
|
778
|
+
};
|
779
|
+
axs.utils.getContrastRatioForElementWithComputedStyle = function(a, b) {
|
780
|
+
if(!axs.utils.elementIsVisible(b)) {
|
781
|
+
return null
|
782
|
+
}
|
783
|
+
var c = axs.utils.getBgColor(a, b);
|
784
|
+
if(!c) {
|
785
|
+
return null
|
786
|
+
}
|
787
|
+
var d = axs.utils.getFgColor(a, c);
|
788
|
+
return d ? axs.utils.calculateContrastRatio(d, c) : null
|
789
|
+
};
|
790
|
+
axs.utils.isNativeTextElement = function(a) {
|
791
|
+
var b = a.tagName.toLowerCase();
|
792
|
+
a = a.type ? a.type.toLowerCase() : "";
|
793
|
+
if("textarea" == b) {
|
794
|
+
return!0
|
795
|
+
}
|
796
|
+
if("input" != b) {
|
797
|
+
return!1
|
798
|
+
}
|
799
|
+
switch(a) {
|
800
|
+
case "email":
|
801
|
+
;
|
802
|
+
case "number":
|
803
|
+
;
|
804
|
+
case "password":
|
805
|
+
;
|
806
|
+
case "search":
|
807
|
+
;
|
808
|
+
case "text":
|
809
|
+
;
|
810
|
+
case "tel":
|
811
|
+
;
|
812
|
+
case "url":
|
813
|
+
;
|
814
|
+
case "":
|
815
|
+
return!0;
|
816
|
+
default:
|
817
|
+
return!1
|
818
|
+
}
|
819
|
+
};
|
820
|
+
axs.utils.isLowContrast = function(a, b, c) {
|
821
|
+
return c ? 4.5 > a || !axs.utils.isLargeFont(b) && 7 > a : 3 > a || !axs.utils.isLargeFont(b) && 4.5 > a
|
822
|
+
};
|
823
|
+
axs.utils.hasLabel = function(a) {
|
824
|
+
var b = a.tagName.toLowerCase(), c = a.type ? a.type.toLowerCase() : "";
|
825
|
+
if(a.hasAttribute("aria-label") || a.hasAttribute("title") || "img" == b && a.hasAttribute("alt") || "input" == b && "image" == c && a.hasAttribute("alt") || "input" == b && ("submit" == c || "reset" == c) || a.hasAttribute("aria-labelledby") || axs.utils.isNativeTextElement(a) && a.hasAttribute("placeholder") || a.hasAttribute("id") && 0 < document.querySelectorAll("label[for=" + a.id + "]").length) {
|
826
|
+
return!0
|
827
|
+
}
|
828
|
+
for(b = a.parentElement;b;) {
|
829
|
+
if("label" == b.tagName.toLowerCase() && b.control == a) {
|
830
|
+
return!0
|
831
|
+
}
|
832
|
+
b = b.parentElement
|
833
|
+
}
|
834
|
+
return!1
|
835
|
+
};
|
836
|
+
axs.utils.isElementHidden = function(a) {
|
837
|
+
if(!(a instanceof a.ownerDocument.defaultView.HTMLElement)) {
|
838
|
+
return!1
|
839
|
+
}
|
840
|
+
if(a.hasAttribute("chromevoxignoreariahidden")) {
|
841
|
+
var b = !0
|
842
|
+
}
|
843
|
+
var c = window.getComputedStyle(a, null);
|
844
|
+
return"none" == c.display || "hidden" == c.visibility ? !0 : a.hasAttribute("aria-hidden") && "true" == a.getAttribute("aria-hidden").toLowerCase() ? !b : !1
|
845
|
+
};
|
846
|
+
axs.utils.isElementOrAncestorHidden = function(a) {
|
847
|
+
return axs.utils.isElementHidden(a) ? !0 : a.parentElement ? axs.utils.isElementOrAncestorHidden(a.parentElement) : !1
|
848
|
+
};
|
849
|
+
axs.utils.isInlineElement = function(a) {
|
850
|
+
a = a.tagName.toUpperCase();
|
851
|
+
return axs.constants.InlineElements[a]
|
852
|
+
};
|
853
|
+
axs.utils.getRoles = function(a) {
|
854
|
+
if(!a.hasAttribute("role")) {
|
855
|
+
return!1
|
856
|
+
}
|
857
|
+
a = a.getAttribute("role").split(" ");
|
858
|
+
for(var b = [], c = !0, d = 0;d < a.length;d++) {
|
859
|
+
var e = a[d];
|
860
|
+
axs.constants.ARIA_ROLES[e] ? b.push({name:e, details:axs.constants.ARIA_ROLES[e], valid:!0}) : (b.push({name:e, valid:!1}), c = !1)
|
861
|
+
}
|
862
|
+
return{roles:b, valid:c}
|
863
|
+
};
|
864
|
+
axs.utils.getAriaPropertyValue = function(a, b, c) {
|
865
|
+
var d = a.replace(/^aria-/, ""), e = axs.constants.ARIA_PROPERTIES[d], d = {name:a, rawValue:b};
|
866
|
+
if(!e) {
|
867
|
+
return d.valid = !1, d.reason = '"' + a + '" is not a valid ARIA property', d
|
868
|
+
}
|
869
|
+
e = e.valueType;
|
870
|
+
if(!e) {
|
871
|
+
return d.valid = !1, d.reason = '"' + a + '" is not a valid ARIA property', d
|
872
|
+
}
|
873
|
+
switch(e) {
|
874
|
+
case "idref":
|
875
|
+
a = axs.utils.isValidIDRefValue(b, c), d.valid = a.valid, d.reason = a.reason, d.idref = a.idref;
|
876
|
+
case "idref_list":
|
877
|
+
a = b.split(/\s+/);
|
878
|
+
d.valid = !0;
|
879
|
+
for(b = 0;b < a.length;b++) {
|
880
|
+
e = axs.utils.isValidIDRefValue(a[b], c), e.valid || (d.valid = !1), d.values ? d.values.push(e) : d.values = [e]
|
881
|
+
}
|
882
|
+
return d;
|
883
|
+
case "integer":
|
884
|
+
c = axs.utils.isValidNumber(b);
|
885
|
+
if(!c.valid) {
|
886
|
+
return d.valid = !1, d.reason = c.reason, d
|
887
|
+
}
|
888
|
+
Math.floor(c.value) != c.value ? (d.valid = !1, d.reason = "" + b + " is not a whole integer") : (d.valid = !0, d.value = c.value);
|
889
|
+
return d;
|
890
|
+
case "number":
|
891
|
+
c = axs.utils.isValidNumber(b), c.valid && (d.valid = !0, d.value = c.value);
|
892
|
+
case "string":
|
893
|
+
return d.valid = !0, d.value = b, d;
|
894
|
+
case "token":
|
895
|
+
return c = axs.utils.isValidTokenValue(a, b.toLowerCase()), c.valid ? (d.valid = !0, d.value = c.value) : (d.valid = !1, d.value = b, d.reason = c.reason), d;
|
896
|
+
case "token_list":
|
897
|
+
e = b.split(/\s+/);
|
898
|
+
d.valid = !0;
|
899
|
+
for(b = 0;b < e.length;b++) {
|
900
|
+
c = axs.utils.isValidTokenValue(a, e[b].toLowerCase()), c.valid || (d.valid = !1, d.reason ? (d.reason = [d.reason], d.reason.push(c.reason)) : (d.reason = c.reason, d.possibleValues = c.possibleValues)), d.values ? d.values.push(c.value) : d.values = [c.value]
|
901
|
+
}
|
902
|
+
return d;
|
903
|
+
case "tristate":
|
904
|
+
return c = axs.utils.isPossibleValue(b.toLowerCase(), axs.constants.MIXED_VALUES, a), c.valid ? (d.valid = !0, d.value = c.value) : (d.valid = !1, d.value = b, d.reason = c.reason), d;
|
905
|
+
case "boolean":
|
906
|
+
return c = axs.utils.isValidBoolean(b), c.valid ? (d.valid = !0, d.value = c.value) : (d.valid = !1, d.value = b, d.reason = c.reason), d
|
907
|
+
}
|
908
|
+
d.valid = !1;
|
909
|
+
d.reason = "Not a valid ARIA property";
|
910
|
+
return d
|
911
|
+
};
|
912
|
+
axs.utils.isValidTokenValue = function(a, b) {
|
913
|
+
var c = a.replace(/^aria-/, "");
|
914
|
+
return axs.utils.isPossibleValue(b, axs.constants.ARIA_PROPERTIES[c].valuesSet, a)
|
915
|
+
};
|
916
|
+
axs.utils.isPossibleValue = function(a, b, c) {
|
917
|
+
return b[a] ? {valid:!0, value:a} : {valid:!1, value:a, reason:'"' + a + '" is not a valid value for ' + c, possibleValues:Object.keys(b)}
|
918
|
+
};
|
919
|
+
axs.utils.isValidBoolean = function(a) {
|
920
|
+
try {
|
921
|
+
var b = JSON.parse(a)
|
922
|
+
}catch(c) {
|
923
|
+
b = ""
|
924
|
+
}
|
925
|
+
return"boolean" != typeof b ? {valid:!1, value:a, reason:'"' + a + '" is not a true/false value'} : {valid:!0, value:b}
|
926
|
+
};
|
927
|
+
axs.utils.isValidIDRefValue = function(a, b) {
|
928
|
+
return b.ownerDocument.getElementById(a) ? {valid:!0, idref:a} : {valid:!1, idref:a, reason:'No element with ID "' + a + '"'}
|
929
|
+
};
|
930
|
+
axs.utils.isValidNumber = function(a) {
|
931
|
+
var b = JSON.parse(a);
|
932
|
+
return"number" != typeof b ? {valid:!1, value:a, reason:'"' + a + '" is not a number'} : {valid:!0, value:b}
|
933
|
+
};
|
934
|
+
axs.utils.isElementImplicitlyFocusable = function(a) {
|
935
|
+
var b = a.ownerDocument.defaultView;
|
936
|
+
return a instanceof b.HTMLAnchorElement || a instanceof b.HTMLAreaElement ? a.hasAttribute("href") : a instanceof b.HTMLInputElement || a instanceof b.HTMLSelectElement || a instanceof b.HTMLTextAreaElement || a instanceof b.HTMLButtonElement || a instanceof b.HTMLIFrameElement ? !a.disabled : !1
|
937
|
+
};
|
938
|
+
axs.utils.values = function(a) {
|
939
|
+
var b = [], c;
|
940
|
+
for(c in a) {
|
941
|
+
a.hasOwnProperty(c) && "function" != typeof a[c] && b.push(a[c])
|
942
|
+
}
|
943
|
+
return b
|
944
|
+
};
|
945
|
+
axs.utils.namedValues = function(a) {
|
946
|
+
var b = {}, c;
|
947
|
+
for(c in a) {
|
948
|
+
a.hasOwnProperty(c) && "function" != typeof a[c] && (b[c] = a[c])
|
949
|
+
}
|
950
|
+
return b
|
951
|
+
};
|
952
|
+
axs.utils.getQuerySelectorText = function(a) {
|
953
|
+
if(null == a || "HTML" == a.tagName) {
|
954
|
+
return"html"
|
955
|
+
}
|
956
|
+
if("BODY" == a.tagName) {
|
957
|
+
return"body"
|
958
|
+
}
|
959
|
+
if(a.hasAttribute) {
|
960
|
+
if(a.id) {
|
961
|
+
return"#" + a.id
|
962
|
+
}
|
963
|
+
if(a.className) {
|
964
|
+
for(var b = "", c = 0;c < a.classList.length;c++) {
|
965
|
+
b += "." + a.classList[c]
|
966
|
+
}
|
967
|
+
var d = 0;
|
968
|
+
if(a.parentNode) {
|
969
|
+
for(c = 0;c < a.parentNode.children.length;c++) {
|
970
|
+
var e = a.parentNode.children[c];
|
971
|
+
axs.browserUtils.matchSelector(e, b) && d++;
|
972
|
+
if(e === a) {
|
973
|
+
break
|
974
|
+
}
|
975
|
+
}
|
976
|
+
}else {
|
977
|
+
d = 1
|
978
|
+
}
|
979
|
+
return 1 == d ? axs.utils.getQuerySelectorText(a.parentNode) + " > " + b : axs.utils.getQuerySelectorText(a.parentNode) + " > " + b + ":nth-of-type(" + d + ")"
|
980
|
+
}
|
981
|
+
if(a.parentNode) {
|
982
|
+
b = a.parentNode.children;
|
983
|
+
d = 1;
|
984
|
+
for(c = 0;b[c] !== a;) {
|
985
|
+
b[c].tagName == a.tagName && d++, c++
|
986
|
+
}
|
987
|
+
c = "";
|
988
|
+
"BODY" != a.parentNode.tagName && (c = axs.utils.getQuerySelectorText(a.parentNode) + " > ");
|
989
|
+
return 1 == d ? c + a.tagName : c + a.tagName + ":nth-of-type(" + d + ")"
|
990
|
+
}
|
991
|
+
}else {
|
992
|
+
if(a.selectorText) {
|
993
|
+
return a.selectorText
|
994
|
+
}
|
995
|
+
}
|
996
|
+
return""
|
997
|
+
};
|
998
|
+
axs.AuditRule = function(a) {
|
999
|
+
for(var b = !0, c = [], d = 0;d < axs.AuditRule.requiredFields.length;d++) {
|
1000
|
+
var e = axs.AuditRule.requiredFields[d];
|
1001
|
+
e in a || (b = !1, c.push(e))
|
1002
|
+
}
|
1003
|
+
if(!b) {
|
1004
|
+
throw"Invalid spec; the following fields were not specified: " + c.join(", ") + "\n" + JSON.stringify(a);
|
1005
|
+
}
|
1006
|
+
this.name = a.name;
|
1007
|
+
this.severity = a.severity;
|
1008
|
+
this.relevantNodesSelector_ = a.relevantNodesSelector;
|
1009
|
+
this.test_ = a.test;
|
1010
|
+
this.code = a.code;
|
1011
|
+
this.heading = a.heading || "";
|
1012
|
+
this.url = a.url || "";
|
1013
|
+
this.requiresConsoleAPI = !!a.opt_requiresConsoleAPI
|
1014
|
+
};
|
1015
|
+
axs.AuditRule.requiredFields = ["name", "severity", "relevantNodesSelector", "test", "code"];
|
1016
|
+
axs.AuditRule.NOT_APPLICABLE = {result:axs.constants.AuditResult.NA};
|
1017
|
+
axs.AuditRule.prototype.addNode = function(a, b) {
|
1018
|
+
a.push(b)
|
1019
|
+
};
|
1020
|
+
axs.AuditRule.prototype.run = function(a, b) {
|
1021
|
+
function c(a) {
|
1022
|
+
for(var b = 0;b < d.length;b++) {
|
1023
|
+
if(axs.browserUtils.matchSelector(a, d[b])) {
|
1024
|
+
return!0
|
1025
|
+
}
|
1026
|
+
}
|
1027
|
+
return!1
|
1028
|
+
}
|
1029
|
+
var d = a || [], e = this.relevantNodesSelector_(b || document), f = [];
|
1030
|
+
if(e instanceof XPathResult) {
|
1031
|
+
if(e.resultType == XPathResult.ORDERED_NODE_SNAPSHOT_TYPE) {
|
1032
|
+
if(!e.snapshotLength) {
|
1033
|
+
return axs.AuditRule.NOT_APPLICABLE
|
1034
|
+
}
|
1035
|
+
for(var g = 0;g < e.snapshotLength;g++) {
|
1036
|
+
var h = e.snapshotItem(g);
|
1037
|
+
this.test_(h) && !c(h) && this.addNode(f, h)
|
1038
|
+
}
|
1039
|
+
}else {
|
1040
|
+
return console.warn("Unknown XPath result type", e), null
|
1041
|
+
}
|
1042
|
+
}else {
|
1043
|
+
if(!e.length) {
|
1044
|
+
return{result:axs.constants.AuditResult.NA}
|
1045
|
+
}
|
1046
|
+
for(g = 0;g < e.length;g++) {
|
1047
|
+
h = e[g], this.test_(h) && !c(h) && this.addNode(f, h)
|
1048
|
+
}
|
1049
|
+
}
|
1050
|
+
return{result:f.length ? axs.constants.AuditResult.FAIL : axs.constants.AuditResult.PASS, elements:f}
|
1051
|
+
};
|
1052
|
+
axs.AuditRule.specs = {};
|
1053
|
+
axs.AuditRule.specs.audioWithoutControls = {name:"audioWithoutControls", heading:"Audio elements should have controls", url:"", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
|
1054
|
+
return a.querySelectorAll("audio[autoplay]")
|
1055
|
+
}, test:function(a) {
|
1056
|
+
return!a.querySelectorAll("[controls]").length && 3 < a.duration
|
1057
|
+
}, code:"AX_AUDIO_01"};
|
1058
|
+
axs.AuditRule.specs.linkWithUnclearPurpose = {name:"linkWithUnclearPurpose", heading:"The purpose of each link should be clear from the link text", url:"", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
|
1059
|
+
return a.querySelectorAll("a")
|
1060
|
+
}, test:function(a) {
|
1061
|
+
return/^\s*click\s*here\s*[^a-z]?$/i.test(a.textContent)
|
1062
|
+
}, code:"AX_TITLE_01"};
|
1063
|
+
axs.AuditRule.specs.pageWithoutTitle = {name:"pageWithoutTitle", heading:"The web page should have a title that describes topic or purpose", url:"", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
|
1064
|
+
return a
|
1065
|
+
}, test:function(a) {
|
1066
|
+
a = a.querySelector("head");
|
1067
|
+
if(!a) {
|
1068
|
+
return!0
|
1069
|
+
}
|
1070
|
+
a = a.querySelector("title");
|
1071
|
+
return!a.length || !a[0].textContent
|
1072
|
+
}, code:"AX_TITLE_01"};
|
1073
|
+
axs.AuditRules = {};
|
1074
|
+
axs.AuditRules.getRule = function(a) {
|
1075
|
+
if(!axs.AuditRules.rules) {
|
1076
|
+
axs.AuditRules.rules = {};
|
1077
|
+
for(var b in axs.AuditRule.specs) {
|
1078
|
+
var c = axs.AuditRule.specs[b], d = new axs.AuditRule(c);
|
1079
|
+
axs.AuditRules.rules[c.name] = d
|
1080
|
+
}
|
1081
|
+
}
|
1082
|
+
return axs.AuditRules.rules[a]
|
1083
|
+
};
|
1084
|
+
axs.AuditRule.specs.badAriaAttributeValue = {name:"badAriaAttributeValue", heading:"ARIA state and property values must be valid", url:"", severity:axs.constants.Severity.SEVERE, relevantNodesSelector:function(a) {
|
1085
|
+
var b = "", c;
|
1086
|
+
for(c in axs.constants.ARIA_PROPERTIES) {
|
1087
|
+
b += "[aria-" + c + "],"
|
1088
|
+
}
|
1089
|
+
b = b.substring(0, b.length - 1);
|
1090
|
+
return a.querySelectorAll(b)
|
1091
|
+
}, test:function(a) {
|
1092
|
+
for(var b in axs.constants.ARIA_PROPERTIES) {
|
1093
|
+
var c = "aria-" + b;
|
1094
|
+
if(a.hasAttribute(c)) {
|
1095
|
+
var d = a.getAttribute(c);
|
1096
|
+
if(!axs.utils.getAriaPropertyValue(c, d, a).valid) {
|
1097
|
+
return!0
|
1098
|
+
}
|
1099
|
+
}
|
1100
|
+
}
|
1101
|
+
return!1
|
1102
|
+
}, code:"AX_ARIA_04"};
|
1103
|
+
axs.AuditRule.specs.badAriaRole = {name:"badAriaRole", heading:"Elements with ARIA roles must use a valid, non-abstract ARIA role", url:"https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules#AX_ARIA_01:_Elements_with_ARIA_roles_must_use_a_valid,_non-abstr", severity:axs.constants.Severity.SEVERE, relevantNodesSelector:function(a) {
|
1104
|
+
return a.querySelectorAll("[role]")
|
1105
|
+
}, test:function(a) {
|
1106
|
+
return!axs.utils.getRoles(a).valid
|
1107
|
+
}, code:"AX_ARIA_01"};
|
1108
|
+
axs.AuditRule.specs.controlsWithoutLabel = {name:"controlsWithoutLabel", heading:"Controls and media elements should have labels", url:"https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules#AX_TEXT_01:_Controls_and_media_elements_should_have_labels", severity:axs.constants.Severity.SEVERE, relevantNodesSelector:function(a) {
|
1109
|
+
return a.querySelectorAll('input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), video:not([disabled])')
|
1110
|
+
}, test:function(a) {
|
1111
|
+
return axs.utils.isElementOrAncestorHidden(a) || "button" == a.tagName.toLowerCase() && a.textContent.replace(/^\s+|\s+$/g, "").length ? !1 : axs.utils.hasLabel(a) ? !1 : !0
|
1112
|
+
}, code:"AX_TEXT_01", ruleName:"Controls and media elements should have labels"};
|
1113
|
+
axs.AuditRule.specs.focusableElementNotVisibleAndNotAriaHidden = {name:"focusableElementNotVisibleAndNotAriaHidden", heading:"These elements are focusable but either invisible or obscured by another element", url:"https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules#AX_FOCUS_01:_These_elements_are_focusable_but_either_invisible_o", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
|
1114
|
+
return a.querySelectorAll(axs.utils.FOCUSABLE_ELEMENTS_SELECTOR)
|
1115
|
+
}, test:function(a) {
|
1116
|
+
return axs.utils.isElementOrAncestorHidden(a) ? !1 : !axs.utils.elementIsVisible(a)
|
1117
|
+
}, code:"AX_FOCUS_01"};
|
1118
|
+
axs.AuditRule.specs.imagesWithoutAltText = {name:"imagesWithoutAltText", heading:"Images should have an alt attribute", url:"https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules#AX_TEXT_02:_Images_should_have_an_alt_attribute,_unless_they_hav", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
|
1119
|
+
a = a.querySelectorAll("img");
|
1120
|
+
for(var b = [], c = 0;c < a.length;c++) {
|
1121
|
+
var d = a[c];
|
1122
|
+
axs.utils.isElementOrAncestorHidden(d) || b.push(d)
|
1123
|
+
}
|
1124
|
+
return b
|
1125
|
+
}, test:function(a) {
|
1126
|
+
return!a.hasAttribute("alt") && "presentation" != a.getAttribute("role")
|
1127
|
+
}, code:"AX_TEXT_02"};
|
1128
|
+
axs.AuditRule.specs.lowContrastElements = {name:"lowContrastElements", heading:"Text elements should have a reasonable contrast ratio", url:"https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules#AX_COLOR_01:_Text_elements_should_have_a_reasonable_contrast_rat", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
|
1129
|
+
return document.evaluate('/html/body//text()[normalize-space(.)!=""]/parent::*[name()!="script"]', a, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
|
1130
|
+
}, test:function(a) {
|
1131
|
+
var b = window.getComputedStyle(a, null);
|
1132
|
+
return(a = axs.utils.getContrastRatioForElementWithComputedStyle(b, a)) && axs.utils.isLowContrast(a, b)
|
1133
|
+
}, code:"AX_COLOR_01"};
|
1134
|
+
axs.AuditRule.specs.elementsWithMeaningfulBackgroundImage = {name:"elementsWithMeaningfulBackgroundImage", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
|
1135
|
+
a = a.querySelectorAll("*");
|
1136
|
+
for(var b = [], c = 0;c < a.length;c++) {
|
1137
|
+
var d = a[c];
|
1138
|
+
axs.utils.isElementOrAncestorHidden(d) || b.push(d)
|
1139
|
+
}
|
1140
|
+
return b
|
1141
|
+
}, heading:"Meaningful images should not be used in element backgrounds", url:"https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules?ts=1368336558&updated=AuditRules#AX_IMAGE_01:_Meaningful_images_should_not_be_used_in_element_bac", test:function(a) {
|
1142
|
+
if(a.textContent && 0 < a.textContent.length) {
|
1143
|
+
return!1
|
1144
|
+
}
|
1145
|
+
a = window.getComputedStyle(a, null);
|
1146
|
+
var b = a.backgroundImage;
|
1147
|
+
if(!b || "undefined" === b || "none" === b) {
|
1148
|
+
return!1
|
1149
|
+
}
|
1150
|
+
b = parseInt(a.width, 10);
|
1151
|
+
a = parseInt(a.height, 10);
|
1152
|
+
return 150 > b && 150 > a
|
1153
|
+
}, code:"AX_IMAGE_01"};
|
1154
|
+
axs.AuditRule.specs.nonExistentAriaLabelledbyElement = {name:"nonExistentAriaLabelledbyElement", heading:"aria-labelledby attributes should refer to an element which exists in the DOM", url:"https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules#AX_ARIA_02:__aria-labelledby_attributes_should_refer_to_an_eleme", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
|
1155
|
+
return a.querySelectorAll("[aria-labelledby]")
|
1156
|
+
}, test:function(a) {
|
1157
|
+
a = a.getAttribute("aria-labelledby").split(/\s+/);
|
1158
|
+
for(var b = 0;b < a.length;b++) {
|
1159
|
+
if(!document.getElementById(a[b])) {
|
1160
|
+
return!0
|
1161
|
+
}
|
1162
|
+
}
|
1163
|
+
return!1
|
1164
|
+
}, code:"AX_ARIA_02"};
|
1165
|
+
axs.AuditRule.specs.requiredAriaAttributeMissing = {name:"requiredAriaAttributeMissing", heading:"Elements with ARIA roles must have all required attributes for that role", url:"", severity:axs.constants.Severity.SEVERE, relevantNodesSelector:function(a) {
|
1166
|
+
return a.querySelectorAll("[role]")
|
1167
|
+
}, test:function(a) {
|
1168
|
+
var b = axs.utils.getRoles(a);
|
1169
|
+
if(!b.valid) {
|
1170
|
+
return!1
|
1171
|
+
}
|
1172
|
+
for(var c = 0;c < b.roles.length;c++) {
|
1173
|
+
var d = b.roles[c].details.requiredPropertiesSet, e;
|
1174
|
+
for(e in d) {
|
1175
|
+
if(d = e.replace(/^aria-/, ""), !("defaultValue" in axs.constants.ARIA_PROPERTIES[d] || a.hasAttribute(e))) {
|
1176
|
+
return!0
|
1177
|
+
}
|
1178
|
+
}
|
1179
|
+
}
|
1180
|
+
}, code:"AX_ARIA_03"};
|
1181
|
+
axs.AuditRule.specs.unfocusableElementsWithOnClick = {name:"unfocusableElementsWithOnClick", heading:"Elements with onclick handlers must be focusable", url:"https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules#AX_FOCUS_02:_Elements_with_onclick_handlers_must_be_focusable", severity:axs.constants.Severity.WARNING, opt_requiresConsoleAPI:!0, relevantNodesSelector:function(a) {
|
1182
|
+
a = a.querySelectorAll("*");
|
1183
|
+
for(var b = [], c = 0;c < a.length;c++) {
|
1184
|
+
var d = a[c];
|
1185
|
+
d instanceof d.ownerDocument.defaultView.HTMLBodyElement || axs.utils.isElementOrAncestorHidden(d) || "click" in getEventListeners(d) && b.push(d)
|
1186
|
+
}
|
1187
|
+
return b
|
1188
|
+
}, test:function(a) {
|
1189
|
+
return!a.hasAttribute("tabindex") && !axs.utils.isElementImplicitlyFocusable(a)
|
1190
|
+
}, code:"AX_FOCUS_02"};
|
1191
|
+
axs.AuditRule.specs.videoWithoutCaptions = {name:"videoWithoutCaptions", heading:"Video elements should use <track> elements to provide captions", url:"https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules#AX_VIDEO_01:_Video_elements_should_use_<track>_elements_to", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
|
1192
|
+
return a.querySelectorAll("video")
|
1193
|
+
}, test:function(a) {
|
1194
|
+
return!a.querySelectorAll("track[kind=captions]").length
|
1195
|
+
}, code:"AX_VIDEO_01"};
|
1196
|
+
axs.Audit = {};
|
1197
|
+
axs.AuditConfiguration = function() {
|
1198
|
+
this.rules_ = {};
|
1199
|
+
this.auditRulesToIgnore = this.auditRulesToRun = this.scope = null;
|
1200
|
+
this.withConsoleApi = !1;
|
1201
|
+
goog.exportProperty(this, "scope", this.scope);
|
1202
|
+
goog.exportProperty(this, "auditRulesToRun", this.auditRulesToRun);
|
1203
|
+
goog.exportProperty(this, "auditRulesToIgnore", this.auditRulesToIgnore);
|
1204
|
+
goog.exportProperty(this, "withConsoleApi", this.withConsoleApi)
|
1205
|
+
};
|
1206
|
+
goog.exportSymbol("axs.AuditConfiguration", axs.AuditConfiguration);
|
1207
|
+
axs.AuditConfiguration.prototype = {ignoreSelectors:function(a, b) {
|
1208
|
+
a in this.rules_ || (this.rules_[a] = {});
|
1209
|
+
"ignore" in this.rules_[a] || (this.rules_[a].ignore = []);
|
1210
|
+
Array.prototype.push.call(this.rules_[a].ignore, b)
|
1211
|
+
}, getIgnoreSelectors:function(a) {
|
1212
|
+
return a in this.rules_ && "ignore" in this.rules_[a] ? this.rules_[a].ignore : []
|
1213
|
+
}};
|
1214
|
+
goog.exportProperty(axs.AuditConfiguration.prototype, "ignoreSelectors", axs.AuditConfiguration.prototype.ignoreSelectors);
|
1215
|
+
goog.exportProperty(axs.AuditConfiguration.prototype, "getIgnoreSelectors", axs.AuditConfiguration.prototype.getIgnoreSelectors);
|
1216
|
+
axs.Audit.run = function(a) {
|
1217
|
+
a = a || new axs.AuditConfiguration;
|
1218
|
+
var b = a.withConsoleApi, c = [], d;
|
1219
|
+
d = a.auditRulesToRun && 0 < a.auditRulesToRun.length ? a.auditRulesToRun : Object.keys(axs.AuditRule.specs);
|
1220
|
+
if(a.auditRulesToIgnore) {
|
1221
|
+
for(var e = 0;e < a.auditRulesToIgnore.length;e++) {
|
1222
|
+
var f = a.auditRulesToIgnore[e];
|
1223
|
+
0 > d.indexOf(f) || d.splice(d.indexOf(f), 1)
|
1224
|
+
}
|
1225
|
+
}
|
1226
|
+
for(e = 0;e < d.length;e++) {
|
1227
|
+
if((f = axs.AuditRules.getRule(d[e])) && !f.disabled && (b || !f.requiresConsoleAPI)) {
|
1228
|
+
var g = [], h = a.getIgnoreSelectors(f.name);
|
1229
|
+
(0 < h.length || a.scope) && g.push(h);
|
1230
|
+
a.scope && g.push(a.scope);
|
1231
|
+
g = f.run.apply(f, g);
|
1232
|
+
g.rule = axs.utils.namedValues(f);
|
1233
|
+
c.push(g)
|
1234
|
+
}
|
1235
|
+
}
|
1236
|
+
return c
|
1237
|
+
};
|
1238
|
+
goog.exportSymbol("axs.Audit.run", axs.Audit.run);
|
1239
|
+
axs.Audit.auditResults = function(a) {
|
1240
|
+
for(var b = new axs.AuditResults, c = 0;c < a.length;c++) {
|
1241
|
+
var d = a[c];
|
1242
|
+
d.result == axs.constants.AuditResult.FAIL && (d.rule.severity == axs.constants.Severity.SEVERE ? b.addError(axs.Audit.accessibilityErrorMessage(d)) : b.addWarning(axs.Audit.accessibilityErrorMessage(d)))
|
1243
|
+
}
|
1244
|
+
return b
|
1245
|
+
};
|
1246
|
+
goog.exportSymbol("axs.Audit.auditResults", axs.Audit.auditResults);
|
1247
|
+
axs.Audit.createReport = function(a, b) {
|
1248
|
+
var c;
|
1249
|
+
c = "*** Begin accessibility audit results ***\nAn accessibility audit found " + axs.Audit.auditResults(a).toString();
|
1250
|
+
b && (c += "\nFor more information, please see ", c += b);
|
1251
|
+
return c += "\n*** End accessibility audit results ***"
|
1252
|
+
};
|
1253
|
+
goog.exportSymbol("axs.Audit.createReport", axs.Audit.createReport);
|
1254
|
+
axs.Audit.accessibilityErrorMessage = function(a) {
|
1255
|
+
for(var b = a.rule.severity == axs.constants.Severity.SEVERE ? "Error: " : "Warning: ", b = b + (a.rule.code + " (" + a.rule.heading + ") failed on the following " + (1 == a.elements.length ? "element" : "elements")), b = 1 == a.elements.length ? b + ":" : b + (" (1 - " + Math.min(5, a.elements.length) + " of " + a.elements.length + "):"), c = Math.min(a.elements.length, 5), d = 0;d < c;d++) {
|
1256
|
+
var e = a.elements[d], b = b + "\n";
|
1257
|
+
try {
|
1258
|
+
b += axs.utils.getQuerySelectorText(e)
|
1259
|
+
}catch(f) {
|
1260
|
+
b += " tagName:" + e.tagName, b += " id:" + e.id
|
1261
|
+
}
|
1262
|
+
}
|
1263
|
+
"" != a.rule.url && (b += "\nSee " + a.rule.url + " for more information.");
|
1264
|
+
return b
|
1265
|
+
};
|
1266
|
+
goog.exportSymbol("axs.Audit.accessibilityErrorMessage", axs.Audit.accessibilityErrorMessage);
|
1267
|
+
axs.content = {};
|
1268
|
+
axs.content.auditResultNodes || (axs.content.auditResultNodes = {});
|
1269
|
+
axs.content.lastNodeId || (axs.content.lastNodeId = 0);
|
1270
|
+
axs.content.convertNodeToResult = function(a) {
|
1271
|
+
var b = "" + axs.content.lastNodeId++;
|
1272
|
+
axs.content.auditResultNodes[b] = a;
|
1273
|
+
return b
|
1274
|
+
};
|
1275
|
+
axs.content.getResultNode = function(a) {
|
1276
|
+
var b = axs.content.auditResultNodes[a];
|
1277
|
+
delete axs.content.auditResultNodes[a];
|
1278
|
+
return b
|
1279
|
+
};
|
1280
|
+
axs.properties = {};
|
1281
|
+
axs.properties.TEXT_CONTENT_XPATH = 'text()[normalize-space(.)!=""]/parent::*[name()!="script"]';
|
1282
|
+
axs.properties.getFocusProperties = function(a) {
|
1283
|
+
a = a.getAttribute("tabindex");
|
1284
|
+
return void 0 != a ? {tabindex:{value:a, valid:!0}} : null
|
1285
|
+
};
|
1286
|
+
axs.properties.getColorProperties = function(a) {
|
1287
|
+
var b = {};
|
1288
|
+
b.contrastRatio = axs.properties.getContrastRatioProperties(a);
|
1289
|
+
return b.contrastRatio ? b : null
|
1290
|
+
};
|
1291
|
+
axs.properties.getContrastRatioProperties = function(a) {
|
1292
|
+
var b = document.evaluate(axs.properties.TEXT_CONTENT_XPATH, a, null, XPathResult.ANY_TYPE, null).iterateNext();
|
1293
|
+
if(!b || b != a) {
|
1294
|
+
return null
|
1295
|
+
}
|
1296
|
+
var b = {}, c = window.getComputedStyle(a, null), d = axs.utils.getBgColor(c, a);
|
1297
|
+
if(!d) {
|
1298
|
+
return null
|
1299
|
+
}
|
1300
|
+
b.backgroundColor = axs.utils.colorToString(d);
|
1301
|
+
var e = axs.utils.getFgColor(c, d);
|
1302
|
+
b.foregroundColor = axs.utils.colorToString(e);
|
1303
|
+
a = axs.utils.getContrastRatioForElementWithComputedStyle(c, a);
|
1304
|
+
if(!a) {
|
1305
|
+
return null
|
1306
|
+
}
|
1307
|
+
b.value = a.toFixed(2);
|
1308
|
+
axs.utils.isLowContrast(a, c) && (b.alert = !0);
|
1309
|
+
(a = axs.utils.suggestColors(d, e, a, c)) && Object.keys(a).length && (b.suggestedColors = a);
|
1310
|
+
return b
|
1311
|
+
};
|
1312
|
+
axs.properties.findTextAlternatives = function(a, b, c) {
|
1313
|
+
var d = c || !1;
|
1314
|
+
c = axs.utils.asElement(a);
|
1315
|
+
if(!c || !d && axs.utils.isElementOrAncestorHidden(c)) {
|
1316
|
+
return null
|
1317
|
+
}
|
1318
|
+
if(a.nodeType == Node.TEXT_NODE) {
|
1319
|
+
return c = {type:"text"}, c.text = a.textContent, c.lastWord = axs.properties.getLastWord(c.text), b.content = c, a.textContent
|
1320
|
+
}
|
1321
|
+
a = null;
|
1322
|
+
d || (a = axs.properties.getTextFromAriaLabelledby(c, b));
|
1323
|
+
if(c.hasAttribute("aria-label")) {
|
1324
|
+
var e = {type:"text"};
|
1325
|
+
e.text = c.getAttribute("aria-label");
|
1326
|
+
e.lastWord = axs.properties.getLastWord(e.text);
|
1327
|
+
a ? e.unused = !0 : d && axs.utils.elementIsHtmlControl(c) || (a = e.text);
|
1328
|
+
b.ariaLabel = e
|
1329
|
+
}
|
1330
|
+
c.hasAttribute("role") && "presentation" == c.getAttribute("role") || (a = axs.properties.getTextFromHostLangaugeAttributes(c, b, a));
|
1331
|
+
if(d && axs.utils.elementIsHtmlControl(c)) {
|
1332
|
+
e = c.ownerDocument.defaultView;
|
1333
|
+
if(c instanceof e.HTMLInputElement) {
|
1334
|
+
var f = c;
|
1335
|
+
"text" == f.type && f.value && 0 < f.value.length && (b.controlValue = {text:f.value});
|
1336
|
+
"range" == f.type && (b.controlValue = {text:f.value})
|
1337
|
+
}
|
1338
|
+
c instanceof e.HTMLSelectElement && (b.controlValue = {text:f.value});
|
1339
|
+
b.controlValue && (f = b.controlValue, a ? f.unused = !0 : a = f.text)
|
1340
|
+
}
|
1341
|
+
if(d && axs.utils.elementIsAriaWidget(c)) {
|
1342
|
+
d = c.getAttribute("role");
|
1343
|
+
"textbox" == d && c.textContent && 0 < c.textContent.length && (b.controlValue = {text:c.textContent});
|
1344
|
+
if("slider" == d || "spinbutton" == d) {
|
1345
|
+
c.hasAttribute("aria-valuetext") ? b.controlValue = {text:c.getAttribute("aria-valuetext")} : c.hasAttribute("aria-valuenow") && (b.controlValue = {value:c.getAttribute("aria-valuenow"), text:"" + c.getAttribute("aria-valuenow")})
|
1346
|
+
}
|
1347
|
+
if("menu" == d) {
|
1348
|
+
for(var g = c.querySelectorAll("[role=menuitemcheckbox], [role=menuitemradio]"), f = [], e = 0;e < g.length;e++) {
|
1349
|
+
"true" == g[e].getAttribute("aria-checked") && f.push(g[e])
|
1350
|
+
}
|
1351
|
+
if(0 < f.length) {
|
1352
|
+
g = "";
|
1353
|
+
for(e = 0;e < f.length;e++) {
|
1354
|
+
g += axs.properties.findTextAlternatives(f[e], {}, !0), e < f.length - 1 && (g += ", ")
|
1355
|
+
}
|
1356
|
+
b.controlValue = {text:g}
|
1357
|
+
}
|
1358
|
+
}
|
1359
|
+
if("combobox" == d || "select" == d) {
|
1360
|
+
b.controlValue = {text:"TODO"}
|
1361
|
+
}
|
1362
|
+
b.controlValue && (f = b.controlValue, a ? f.unused = !0 : a = f.text)
|
1363
|
+
}
|
1364
|
+
if(d = axs.properties.getTextFromDescendantContent(c)) {
|
1365
|
+
f = {type:"text"}, f.text = d, f.lastWord = axs.properties.getLastWord(f.text), a ? f.unused = !0 : a = d, b.content = f
|
1366
|
+
}
|
1367
|
+
c.hasAttribute("title") && (d = {type:"string", valid:!0}, d.text = c.getAttribute("title"), d.lastWord = axs.properties.getLastWord(d.lastWord), a ? d.unused = !0 : a = d.text, b.title = d);
|
1368
|
+
return 0 == Object.keys(b).length && null == a ? null : a
|
1369
|
+
};
|
1370
|
+
axs.properties.getTextFromDescendantContent = function(a) {
|
1371
|
+
if(a.hasAttribute("role")) {
|
1372
|
+
var b = a.getAttribute("role");
|
1373
|
+
if((b = axs.constants.ARIA_ROLES[b]) && (!b.namefrom || 0 > b.namefrom.indexOf("contents"))) {
|
1374
|
+
return null
|
1375
|
+
}
|
1376
|
+
}
|
1377
|
+
a = a.childNodes;
|
1378
|
+
for(var b = [], c = 0;c < a.length;c++) {
|
1379
|
+
var d = axs.properties.findTextAlternatives(a[c], {}, !0);
|
1380
|
+
d && 0 < d.trim().length && b.push(d.trim())
|
1381
|
+
}
|
1382
|
+
return b.length ? b.join(" ") : null
|
1383
|
+
};
|
1384
|
+
axs.properties.getTextFromAriaLabelledby = function(a, b) {
|
1385
|
+
var c = null;
|
1386
|
+
if(!a.hasAttribute("aria-labelledby")) {
|
1387
|
+
return c
|
1388
|
+
}
|
1389
|
+
for(var d = a.getAttribute("aria-labelledby").split(/\s+/), e = {valid:!0}, f = [], g = [], h = 0;h < d.length;h++) {
|
1390
|
+
var k = {type:"element"}, m = d[h];
|
1391
|
+
k.value = m;
|
1392
|
+
var l = document.getElementById(m);
|
1393
|
+
l ? (k.valid = !0, k.text = axs.properties.findTextAlternatives(l, {}, !0), k.lastWord = axs.properties.getLastWord(k.text), f.push(l.textContent.trim()), k.element = l) : (k.valid = !1, e.valid = !1, k.errorMessage = {messageKey:"noElementWithId", args:[m]});
|
1394
|
+
g.push(k)
|
1395
|
+
}
|
1396
|
+
0 < g.length && (g[g.length - 1].last = !0, e.values = g, e.text = f.join(" "), e.lastWord = axs.properties.getLastWord(e.text), c = e.text, b.ariaLabelledby = e);
|
1397
|
+
return c
|
1398
|
+
};
|
1399
|
+
axs.properties.getTextFromHostLangaugeAttributes = function(a, b, c) {
|
1400
|
+
if(axs.browserUtils.matchSelector(a, "img")) {
|
1401
|
+
if(a.hasAttribute("alt")) {
|
1402
|
+
var d = {type:"string", valid:!0};
|
1403
|
+
d.text = a.getAttribute("alt");
|
1404
|
+
c ? d.unused = !0 : c = d.text;
|
1405
|
+
b.alt = d
|
1406
|
+
}else {
|
1407
|
+
d = {valid:!1, errorMessage:"No alt value provided"}, b.alt = d, d = a.src, "string" == typeof d && (c = d.split("/").pop(), b.filename = {text:c})
|
1408
|
+
}
|
1409
|
+
}
|
1410
|
+
if(axs.browserUtils.matchSelector(a, 'input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), video:not([disabled])')) {
|
1411
|
+
if(a.hasAttribute("id")) {
|
1412
|
+
for(var d = document.querySelectorAll("label[for=" + a.id + "]"), e = {}, f = [], g = [], h = 0;h < d.length;h++) {
|
1413
|
+
var k = {type:"element"}, m = d[h], l = axs.properties.findTextAlternatives(m, {}, !0);
|
1414
|
+
l && 0 < l.trim().length && (k.text = l.trim(), g.push(l.trim()));
|
1415
|
+
k.element = m;
|
1416
|
+
f.push(k)
|
1417
|
+
}
|
1418
|
+
0 < f.length && (f[f.length - 1].last = !0, e.values = f, e.text = g.join(" "), e.lastWord = axs.properties.getLastWord(e.text), c ? e.unused = !0 : c = e.text, b.labelFor = e)
|
1419
|
+
}
|
1420
|
+
d = a.parentElement;
|
1421
|
+
for(e = {};d;) {
|
1422
|
+
if("label" == d.tagName.toLowerCase() && (f = d, f.control == a)) {
|
1423
|
+
e.type = "element";
|
1424
|
+
e.text = axs.properties.findTextAlternatives(f, {}, !0);
|
1425
|
+
e.lastWord = axs.properties.getLastWord(e.text);
|
1426
|
+
e.element = f;
|
1427
|
+
break
|
1428
|
+
}
|
1429
|
+
d = d.parentElement
|
1430
|
+
}
|
1431
|
+
e.text && (c ? e.unused = !0 : c = e.text, b.labelWrapped = e);
|
1432
|
+
Object.keys(b).length || (b.noLabel = !0)
|
1433
|
+
}
|
1434
|
+
return c
|
1435
|
+
};
|
1436
|
+
axs.properties.getLastWord = function(a) {
|
1437
|
+
if(!a) {
|
1438
|
+
return null
|
1439
|
+
}
|
1440
|
+
var b = a.lastIndexOf(" ") + 1, c = a.length - 10;
|
1441
|
+
return a.substring(b > c ? b : c)
|
1442
|
+
};
|
1443
|
+
axs.properties.getTextProperties = function(a) {
|
1444
|
+
var b = {};
|
1445
|
+
a = axs.properties.findTextAlternatives(a, b);
|
1446
|
+
if(0 == Object.keys(b).length) {
|
1447
|
+
if(!a) {
|
1448
|
+
return null
|
1449
|
+
}
|
1450
|
+
b.hasProperties = !1
|
1451
|
+
}else {
|
1452
|
+
b.hasProperties = !0
|
1453
|
+
}
|
1454
|
+
b.computedText = a;
|
1455
|
+
b.lastWord = axs.properties.getLastWord(a);
|
1456
|
+
return b
|
1457
|
+
};
|
1458
|
+
axs.properties.getAriaProperties = function(a) {
|
1459
|
+
console.log("getAriaProperties", a);
|
1460
|
+
var b = {}, c = axs.properties.getGlobalAriaProperties(a), d;
|
1461
|
+
for(d in axs.constants.ARIA_PROPERTIES) {
|
1462
|
+
var e = "aria-" + d;
|
1463
|
+
if(a.hasAttribute(e)) {
|
1464
|
+
var f = a.getAttribute(e);
|
1465
|
+
c[e] = axs.utils.getAriaPropertyValue(e, f, a)
|
1466
|
+
}
|
1467
|
+
}
|
1468
|
+
console.log("statesAndProperties", c);
|
1469
|
+
0 < Object.keys(c).length && (b.properties = axs.utils.values(c));
|
1470
|
+
f = axs.utils.getRoles(a);
|
1471
|
+
if(!f) {
|
1472
|
+
return Object.keys(b).length ? b : null
|
1473
|
+
}
|
1474
|
+
b.roles = f;
|
1475
|
+
if(!f.valid || !f.roles) {
|
1476
|
+
return b
|
1477
|
+
}
|
1478
|
+
for(var e = f.roles, g = 0;g < e.length;g++) {
|
1479
|
+
var h = e[g];
|
1480
|
+
if(h.details && h.details.propertiesSet) {
|
1481
|
+
for(d in h.details.propertiesSet) {
|
1482
|
+
d in c || (a.hasAttribute(d) ? (f = a.getAttribute(d), c[d] = axs.utils.getAriaPropertyValue(d, f, a), "values" in c[d] && (f = c[d].values, f[f.length - 1].isLast = !0)) : h.details.requiredPropertiesSet[d] && (c[d] = {name:d, valid:!1, reason:"Required property not set"}))
|
1483
|
+
}
|
1484
|
+
}
|
1485
|
+
}
|
1486
|
+
0 < Object.keys(c).length && (b.properties = axs.utils.values(c));
|
1487
|
+
return 0 < Object.keys(b).length ? b : null
|
1488
|
+
};
|
1489
|
+
axs.properties.getGlobalAriaProperties = function(a) {
|
1490
|
+
for(var b = {}, c = 0;c < axs.constants.GLOBAL_PROPERTIES.length;c++) {
|
1491
|
+
var d = axs.constants.GLOBAL_PROPERTIES[c];
|
1492
|
+
if(a.hasAttribute(d)) {
|
1493
|
+
var e = a.getAttribute(d);
|
1494
|
+
b[d] = axs.utils.getAriaPropertyValue(d, e, a)
|
1495
|
+
}
|
1496
|
+
}
|
1497
|
+
return b
|
1498
|
+
};
|
1499
|
+
axs.properties.getVideoProperties = function(a) {
|
1500
|
+
if(!axs.browserUtils.matchSelector(a, "video")) {
|
1501
|
+
return null
|
1502
|
+
}
|
1503
|
+
var b = {};
|
1504
|
+
b.captionTracks = axs.properties.getTrackElements(a, "captions");
|
1505
|
+
b.descriptionTracks = axs.properties.getTrackElements(a, "descriptions");
|
1506
|
+
b.chapterTracks = axs.properties.getTrackElements(a, "chapters");
|
1507
|
+
return b
|
1508
|
+
};
|
1509
|
+
axs.properties.getTrackElements = function(a, b) {
|
1510
|
+
var c = a.querySelectorAll("track[kind=" + b + "]"), d = {};
|
1511
|
+
if(!c.length) {
|
1512
|
+
return d.valid = !1, d.reason = {messageKey:"noTracksProvided", args:[[b]]}, d
|
1513
|
+
}
|
1514
|
+
d.valid = !0;
|
1515
|
+
for(var e = [], f = 0;f < c.length;f++) {
|
1516
|
+
var g = {}, h = c[f].getAttribute("src"), k = c[f].getAttribute("srcLang"), m = c[f].getAttribute("label");
|
1517
|
+
h ? (g.valid = !0, g.src = h) : (g.valid = !1, g.reason = {messageKey:"noSrcProvided"});
|
1518
|
+
h = "";
|
1519
|
+
m && (h += m, k && (h += " "));
|
1520
|
+
k && (h += "(" + k + ")");
|
1521
|
+
"" == h && (h = "[[object Object]]");
|
1522
|
+
g.name = h;
|
1523
|
+
e.push(g)
|
1524
|
+
}
|
1525
|
+
d.values = e;
|
1526
|
+
return d
|
1527
|
+
};
|
1528
|
+
axs.properties.getAllProperties = function(a) {
|
1529
|
+
var b = axs.utils.asElement(a);
|
1530
|
+
if(!b) {
|
1531
|
+
return{}
|
1532
|
+
}
|
1533
|
+
var c = {};
|
1534
|
+
c.ariaProperties = axs.properties.getAriaProperties(b);
|
1535
|
+
c.colorProperties = axs.properties.getColorProperties(b);
|
1536
|
+
c.focusProperties = axs.properties.getFocusProperties(b);
|
1537
|
+
c.textProperties = axs.properties.getTextProperties(a);
|
1538
|
+
c.videoProperties = axs.properties.getVideoProperties(b);
|
1539
|
+
return c
|
1540
|
+
};
|
1541
|
+
axs.AuditRule.specs.mainRoleOnInappropriateElement = {name:"mainRoleOnInappropriateElement", heading:"role=main should only appear on significant elements", url:"", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
|
1542
|
+
return a.querySelectorAll("[role~=main]")
|
1543
|
+
}, test:function(a) {
|
1544
|
+
return axs.utils.isInlineElement(a) || 50 > axs.properties.findTextAlternatives(a, {}).length ? !0 : !1
|
1545
|
+
}, code:"AX_ARIA_04"};
|
1546
|
+
|