lib/capybara/accessible/axs_testing.js in capybara-accessible-0.0.2 vs lib/capybara/accessible/axs_testing.js in capybara-accessible-0.1.0
- old
+ new
@@ -1,5 +1,393 @@
+var COMPILED = !0, goog = goog || {};
+goog.global = this;
+goog.exportPath_ = function(a, b, c) {
+ a = a.split(".");
+ c = c || goog.global;
+ a[0] in c || !c.execScript || c.execScript("var " + a[0]);
+ for(var d;a.length && (d = a.shift());) {
+ a.length || void 0 === b ? c = c[d] ? c[d] : c[d] = {} : c[d] = b
+ }
+};
+goog.define = function(a, b) {
+ var c = b;
+ COMPILED || goog.global.CLOSURE_DEFINES && Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES, a) && (c = goog.global.CLOSURE_DEFINES[a]);
+ goog.exportPath_(a, c)
+};
+goog.DEBUG = !0;
+goog.LOCALE = "en";
+goog.TRUSTED_SITE = !0;
+goog.provide = function(a) {
+ if(!COMPILED) {
+ if(goog.isProvided_(a)) {
+ throw Error('Namespace "' + a + '" already declared.');
+ }
+ delete goog.implicitNamespaces_[a];
+ for(var b = a;(b = b.substring(0, b.lastIndexOf("."))) && !goog.getObjectByName(b);) {
+ goog.implicitNamespaces_[b] = !0
+ }
+ }
+ goog.exportPath_(a)
+};
+goog.setTestOnly = function(a) {
+ if(COMPILED && !goog.DEBUG) {
+ throw a = a || "", Error("Importing test-only code into non-debug environment" + a ? ": " + a : ".");
+ }
+};
+COMPILED || (goog.isProvided_ = function(a) {
+ return!goog.implicitNamespaces_[a] && !!goog.getObjectByName(a)
+}, goog.implicitNamespaces_ = {});
+goog.getObjectByName = function(a, b) {
+ for(var c = a.split("."), d = b || goog.global, e;e = c.shift();) {
+ if(goog.isDefAndNotNull(d[e])) {
+ d = d[e]
+ }else {
+ return null
+ }
+ }
+ return d
+};
+goog.globalize = function(a, b) {
+ var c = b || goog.global, d;
+ for(d in a) {
+ c[d] = a[d]
+ }
+};
+goog.addDependency = function(a, b, c) {
+ if(goog.DEPENDENCIES_ENABLED) {
+ var d;
+ a = a.replace(/\\/g, "/");
+ for(var e = goog.dependencies_, f = 0;d = b[f];f++) {
+ e.nameToPath[d] = a, a in e.pathToNames || (e.pathToNames[a] = {}), e.pathToNames[a][d] = !0
+ }
+ for(d = 0;b = c[d];d++) {
+ a in e.requires || (e.requires[a] = {}), e.requires[a][b] = !0
+ }
+ }
+};
+goog.ENABLE_DEBUG_LOADER = !0;
+goog.require = function(a) {
+ if(!COMPILED && !goog.isProvided_(a)) {
+ if(goog.ENABLE_DEBUG_LOADER) {
+ var b = goog.getPathFromDeps_(a);
+ if(b) {
+ goog.included_[b] = !0;
+ goog.writeScripts_();
+ return
+ }
+ }
+ a = "goog.require could not find: " + a;
+ goog.global.console && goog.global.console.error(a);
+ throw Error(a);
+ }
+};
+goog.basePath = "";
+goog.nullFunction = function() {
+};
+goog.identityFunction = function(a, b) {
+ return a
+};
+goog.abstractMethod = function() {
+ throw Error("unimplemented abstract method");
+};
+goog.addSingletonGetter = function(a) {
+ a.getInstance = function() {
+ if(a.instance_) {
+ return a.instance_
+ }
+ goog.DEBUG && (goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = a);
+ return a.instance_ = new a
+ }
+};
+goog.instantiatedSingletons_ = [];
+goog.DEPENDENCIES_ENABLED = !COMPILED && goog.ENABLE_DEBUG_LOADER;
+goog.DEPENDENCIES_ENABLED && (goog.included_ = {}, goog.dependencies_ = {pathToNames:{}, nameToPath:{}, requires:{}, visited:{}, written:{}}, goog.inHtmlDocument_ = function() {
+ var a = goog.global.document;
+ return"undefined" != typeof a && "write" in a
+}, goog.findBasePath_ = function() {
+ if(goog.global.CLOSURE_BASE_PATH) {
+ goog.basePath = goog.global.CLOSURE_BASE_PATH
+ }else {
+ if(goog.inHtmlDocument_()) {
+ for(var a = goog.global.document.getElementsByTagName("script"), b = a.length - 1;0 <= b;--b) {
+ var c = a[b].src, d = c.lastIndexOf("?"), d = -1 == d ? c.length : d;
+ if("base.js" == c.substr(d - 7, 7)) {
+ goog.basePath = c.substr(0, d - 7);
+ break
+ }
+ }
+ }
+ }
+}, goog.importScript_ = function(a) {
+ var b = goog.global.CLOSURE_IMPORT_SCRIPT || goog.writeScriptTag_;
+ !goog.dependencies_.written[a] && b(a) && (goog.dependencies_.written[a] = !0)
+}, goog.writeScriptTag_ = function(a) {
+ if(goog.inHtmlDocument_()) {
+ var b = goog.global.document;
+ if("complete" == b.readyState) {
+ if(/\bdeps.js$/.test(a)) {
+ return!1
+ }
+ throw Error('Cannot write "' + a + '" after document load');
+ }
+ b.write('<script type="text/javascript" src="' + a + '">\x3c/script>');
+ return!0
+ }
+ return!1
+}, goog.writeScripts_ = function() {
+ function a(e) {
+ if(!(e in d.written)) {
+ if(!(e in d.visited) && (d.visited[e] = !0, e in d.requires)) {
+ for(var g in d.requires[e]) {
+ if(!goog.isProvided_(g)) {
+ if(g in d.nameToPath) {
+ a(d.nameToPath[g])
+ }else {
+ throw Error("Undefined nameToPath for " + g);
+ }
+ }
+ }
+ }
+ e in c || (c[e] = !0, b.push(e))
+ }
+ }
+ var b = [], c = {}, d = goog.dependencies_, e;
+ for(e in goog.included_) {
+ d.written[e] || a(e)
+ }
+ for(e = 0;e < b.length;e++) {
+ if(b[e]) {
+ goog.importScript_(goog.basePath + b[e])
+ }else {
+ throw Error("Undefined script input");
+ }
+ }
+}, goog.getPathFromDeps_ = function(a) {
+ return a in goog.dependencies_.nameToPath ? goog.dependencies_.nameToPath[a] : null
+}, goog.findBasePath_(), goog.global.CLOSURE_NO_DEPS || goog.importScript_(goog.basePath + "deps.js"));
+goog.typeOf = function(a) {
+ var b = typeof a;
+ if("object" == b) {
+ if(a) {
+ if(a instanceof Array) {
+ return"array"
+ }
+ if(a instanceof Object) {
+ return b
+ }
+ var c = Object.prototype.toString.call(a);
+ if("[object Window]" == c) {
+ return"object"
+ }
+ if("[object Array]" == c || "number" == typeof a.length && "undefined" != typeof a.splice && "undefined" != typeof a.propertyIsEnumerable && !a.propertyIsEnumerable("splice")) {
+ return"array"
+ }
+ if("[object Function]" == c || "undefined" != typeof a.call && "undefined" != typeof a.propertyIsEnumerable && !a.propertyIsEnumerable("call")) {
+ return"function"
+ }
+ }else {
+ return"null"
+ }
+ }else {
+ if("function" == b && "undefined" == typeof a.call) {
+ return"object"
+ }
+ }
+ return b
+};
+goog.isDef = function(a) {
+ return void 0 !== a
+};
+goog.isNull = function(a) {
+ return null === a
+};
+goog.isDefAndNotNull = function(a) {
+ return null != a
+};
+goog.isArray = function(a) {
+ return"array" == goog.typeOf(a)
+};
+goog.isArrayLike = function(a) {
+ var b = goog.typeOf(a);
+ return"array" == b || "object" == b && "number" == typeof a.length
+};
+goog.isDateLike = function(a) {
+ return goog.isObject(a) && "function" == typeof a.getFullYear
+};
+goog.isString = function(a) {
+ return"string" == typeof a
+};
+goog.isBoolean = function(a) {
+ return"boolean" == typeof a
+};
+goog.isNumber = function(a) {
+ return"number" == typeof a
+};
+goog.isFunction = function(a) {
+ return"function" == goog.typeOf(a)
+};
+goog.isObject = function(a) {
+ var b = typeof a;
+ return"object" == b && null != a || "function" == b
+};
+goog.getUid = function(a) {
+ return a[goog.UID_PROPERTY_] || (a[goog.UID_PROPERTY_] = ++goog.uidCounter_)
+};
+goog.removeUid = function(a) {
+ "removeAttribute" in a && a.removeAttribute(goog.UID_PROPERTY_);
+ try {
+ delete a[goog.UID_PROPERTY_]
+ }catch(b) {
+ }
+};
+goog.UID_PROPERTY_ = "closure_uid_" + (1E9 * Math.random() >>> 0);
+goog.uidCounter_ = 0;
+goog.getHashCode = goog.getUid;
+goog.removeHashCode = goog.removeUid;
+goog.cloneObject = function(a) {
+ var b = goog.typeOf(a);
+ if("object" == b || "array" == b) {
+ if(a.clone) {
+ return a.clone()
+ }
+ var b = "array" == b ? [] : {}, c;
+ for(c in a) {
+ b[c] = goog.cloneObject(a[c])
+ }
+ return b
+ }
+ return a
+};
+goog.bindNative_ = function(a, b, c) {
+ return a.call.apply(a.bind, arguments)
+};
+goog.bindJs_ = function(a, b, c) {
+ if(!a) {
+ throw Error();
+ }
+ if(2 < arguments.length) {
+ var d = Array.prototype.slice.call(arguments, 2);
+ return function() {
+ var c = Array.prototype.slice.call(arguments);
+ Array.prototype.unshift.apply(c, d);
+ return a.apply(b, c)
+ }
+ }
+ return function() {
+ return a.apply(b, arguments)
+ }
+};
+goog.bind = function(a, b, c) {
+ Function.prototype.bind && -1 != Function.prototype.bind.toString().indexOf("native code") ? goog.bind = goog.bindNative_ : goog.bind = goog.bindJs_;
+ return goog.bind.apply(null, arguments)
+};
+goog.partial = function(a, b) {
+ var c = Array.prototype.slice.call(arguments, 1);
+ return function() {
+ var b = Array.prototype.slice.call(arguments);
+ b.unshift.apply(b, c);
+ return a.apply(this, b)
+ }
+};
+goog.mixin = function(a, b) {
+ for(var c in b) {
+ a[c] = b[c]
+ }
+};
+goog.now = goog.TRUSTED_SITE && Date.now || function() {
+ return+new Date
+};
+goog.globalEval = function(a) {
+ if(goog.global.execScript) {
+ goog.global.execScript(a, "JavaScript")
+ }else {
+ if(goog.global.eval) {
+ 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_) {
+ goog.global.eval(a)
+ }else {
+ var b = goog.global.document, c = b.createElement("script");
+ c.type = "text/javascript";
+ c.defer = !1;
+ c.appendChild(b.createTextNode(a));
+ b.body.appendChild(c);
+ b.body.removeChild(c)
+ }
+ }else {
+ throw Error("goog.globalEval not available");
+ }
+ }
+};
+goog.evalWorksForGlobals_ = null;
+goog.getCssName = function(a, b) {
+ var c = function(a) {
+ return goog.cssNameMapping_[a] || a
+ }, d = function(a) {
+ a = a.split("-");
+ for(var b = [], d = 0;d < a.length;d++) {
+ b.push(c(a[d]))
+ }
+ return b.join("-")
+ }, d = goog.cssNameMapping_ ? "BY_WHOLE" == goog.cssNameMappingStyle_ ? c : d : function(a) {
+ return a
+ };
+ return b ? a + "-" + d(b) : d(a)
+};
+goog.setCssNameMapping = function(a, b) {
+ goog.cssNameMapping_ = a;
+ goog.cssNameMappingStyle_ = b
+};
+!COMPILED && goog.global.CLOSURE_CSS_NAME_MAPPING && (goog.cssNameMapping_ = goog.global.CLOSURE_CSS_NAME_MAPPING);
+goog.getMsg = function(a, b) {
+ var c = b || {}, d;
+ for(d in c) {
+ var e = ("" + c[d]).replace(/\$/g, "$$$$");
+ a = a.replace(RegExp("\\{\\$" + d + "\\}", "gi"), e)
+ }
+ return a
+};
+goog.getMsgWithFallback = function(a, b) {
+ return a
+};
+goog.exportSymbol = function(a, b, c) {
+ goog.exportPath_(a, b, c)
+};
+goog.exportProperty = function(a, b, c) {
+ a[b] = c
+};
+goog.inherits = function(a, b) {
+ function c() {
+ }
+ c.prototype = b.prototype;
+ a.superClass_ = b.prototype;
+ a.prototype = new c;
+ a.prototype.constructor = a
+};
+goog.base = function(a, b, c) {
+ var d = arguments.callee.caller;
+ if(goog.DEBUG && !d) {
+ 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");
+ }
+ if(d.superClass_) {
+ return d.superClass_.constructor.apply(a, Array.prototype.slice.call(arguments, 1))
+ }
+ for(var e = Array.prototype.slice.call(arguments, 2), f = !1, g = a.constructor;g;g = g.superClass_ && g.superClass_.constructor) {
+ if(g.prototype[b] === d) {
+ f = !0
+ }else {
+ if(f) {
+ return g.prototype[b].apply(a, e)
+ }
+ }
+ }
+ if(a[b] === d) {
+ return a.constructor.prototype[b].apply(a, e)
+ }
+ throw Error("goog.base called from a method of one name to a method of a different name");
+};
+goog.scope = function(a) {
+ a.call(goog.global)
+};
var axs = {};
axs.constants = {};
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",
"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"],
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"],
@@ -31,12 +419,11 @@
for(var e = 0;e < d.length;e++) {
c[d[e]] = !0
}
}
if(a.parent) {
- a = a.parent;
- for(d = 0;d < a.length;d++) {
+ for(a = a.parent, d = 0;d < a.length;d++) {
axs.constants.addAllPropertiesToSet_(axs.constants.ARIA_ROLES[a[d]], b, c)
}
}
};
for(var roleName in axs.constants.ARIA_ROLES) {
@@ -102,11 +489,11 @@
return"0" == a.style.opacity
};
axs.utils.elementHasZeroArea = function(a) {
a = a.getBoundingClientRect();
var b = a.top - a.bottom;
- return!(a.right - a.left) || !b ? !0 : !1
+ return a.right - a.left && b ? !1 : !0
};
axs.utils.elementIsOutsideScrollArea = function(a) {
a = a.getBoundingClientRect();
var b = document.body.scrollWidth, c = document.body.scrollTop, d = document.body.scrollLeft;
return a.top >= document.body.scrollHeight || a.bottom <= -c || a.left >= b || a.right <= -d ? !0 : !1
@@ -117,22 +504,18 @@
}
if(axs.utils.elementHasZeroArea(a)) {
return null
}
var c = a.getBoundingClientRect(), c = document.elementFromPoint((c.left + c.right) / 2, (c.top + c.bottom) / 2);
- return null != c && c != a && !b(c, a) ? c : null
+ return null == c || c == a || b(c, a) ? null : c
};
axs.utils.elementIsHtmlControl = function(a) {
- return a instanceof HTMLButtonElement || a instanceof HTMLInputElement || a instanceof HTMLSelectElement || a instanceof HTMLTextAreaElement ? !0 : !1
+ var b = a.ownerDocument.defaultView;
+ return a instanceof b.HTMLButtonElement || a instanceof b.HTMLInputElement || a instanceof b.HTMLSelectElement || a instanceof b.HTMLTextAreaElement ? !0 : !1
};
axs.utils.elementIsAriaWidget = function(a) {
- if(a.hasAttribute("role") && (a = a.getAttribute("role"))) {
- if((a = axs.constants.ARIA_ROLES[a]) && "widget" in a.allParentRolesSet) {
- return!0
- }
- }
- return!1
+ return a.hasAttribute("role") && (a = a.getAttribute("role")) && (a = axs.constants.ARIA_ROLES[a]) && "widget" in a.allParentRolesSet ? !0 : !1
};
axs.utils.elementIsVisible = function(a) {
if(axs.utils.elementIsTransparent(a) || axs.utils.elementHasZeroArea(a) || axs.utils.elementIsOutsideScrollArea(a)) {
return!1
}
@@ -176,15 +559,13 @@
var f = window.getComputedStyle(d, null);
if(f) {
if(f.backgroundImage && "none" != f.backgroundImage) {
return null
}
- if((f = axs.utils.parseColor(f.backgroundColor)) && 0 != f.alpha) {
- if(e.push(f), 1 == f.alpha) {
- c = null;
- break
- }
+ if((f = axs.utils.parseColor(f.backgroundColor)) && 0 != f.alpha && (e.push(f), 1 == f.alpha)) {
+ c = null;
+ break
}
}
}
c || e.push(new axs.utils.Color(255, 255, 255, 1));
for(d = e.pop();e.length;) {
@@ -237,11 +618,11 @@
var c = axs.utils.getBgColor(a, b);
if(!c) {
return null
}
var d = axs.utils.getFgColor(a, c);
- return!d ? null : axs.utils.calculateContrastRatio(d, c)
+ return d ? axs.utils.calculateContrastRatio(d, c) : null
};
axs.utils.isNativeTextElement = function(a) {
var b = a.tagName.toLowerCase();
a = a.type ? a.type.toLowerCase() : "";
if("textarea" == b) {
@@ -286,11 +667,11 @@
b = b.parentElement
}
return!1
};
axs.utils.isElementHidden = function(a) {
- if(!(a instanceof HTMLElement)) {
+ if(!(a instanceof a.ownerDocument.defaultView.HTMLElement)) {
return!1
}
if(a.hasAttribute("chromevoxignoreariahidden")) {
var b = !0
}
@@ -358,29 +739,30 @@
axs.utils.isValidTokenValue = function(a, b) {
var c = a.replace(/^aria-/, "");
return axs.utils.isPossibleValue(b, axs.constants.ARIA_PROPERTIES[c].valuesSet, a)
};
axs.utils.isPossibleValue = function(a, b, c) {
- return!b[a] ? {valid:!1, value:a, reason:'"' + a + '" is not a valid value for ' + c, possibleValues:Object.keys(b)} : {valid:!0, value:a}
+ return b[a] ? {valid:!0, value:a} : {valid:!1, value:a, reason:'"' + a + '" is not a valid value for ' + c, possibleValues:Object.keys(b)}
};
axs.utils.isValidBoolean = function(a) {
try {
var b = JSON.parse(a)
}catch(c) {
b = ""
}
return"boolean" != typeof b ? {valid:!1, value:a, reason:'"' + a + '" is not a true/false value'} : {valid:!0, value:b}
};
axs.utils.isValidIDRefValue = function(a, b) {
- return!b.ownerDocument.getElementById(a) ? {valid:!1, idref:a, reason:'No element with ID "' + a + '"'} : {valid:!0, idref:a}
+ return b.ownerDocument.getElementById(a) ? {valid:!0, idref:a} : {valid:!1, idref:a, reason:'No element with ID "' + a + '"'}
};
axs.utils.isValidNumber = function(a) {
var b = JSON.parse(a);
return"number" != typeof b ? {valid:!1, value:a, reason:'"' + a + '" is not a number'} : {valid:!0, value:b}
};
axs.utils.isElementImplicitlyFocusable = function(a) {
- return a instanceof HTMLAnchorElement || a instanceof HTMLAreaElement ? a.hasAttribute("href") : a instanceof HTMLInputElement || a instanceof HTMLSelectElement || a instanceof HTMLTextAreaElement || a instanceof HTMLButtonElement || a instanceof HTMLIFrameElement ? !a.disabled : !1
+ var b = a.ownerDocument.defaultView;
+ 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
};
axs.utils.values = function(a) {
var b = [], c;
for(c in a) {
a.hasOwnProperty(c) && "function" != typeof a[c] && b.push(a[c])
@@ -411,11 +793,11 @@
}
var d = 0;
if(a.parentNode) {
for(c = 0;c < a.parentNode.children.length;c++) {
var e = a.parentNode.children[c];
- e.webkitMatchesSelector(b) && d++;
+ axs.browserUtils.matchSelector(e, b) && d++;
if(e === a) {
break
}
}
}else {
@@ -463,11 +845,11 @@
a.push(b)
};
axs.AuditRule.prototype.run = function(a, b) {
function c(a) {
for(var b = 0;b < d.length;b++) {
- if(a.webkitMatchesSelector(d[b])) {
+ if(axs.browserUtils.matchSelector(a, d[b])) {
return!0
}
}
return!1
}
@@ -508,51 +890,66 @@
};
axs.AuditResults = function() {
this.errors_ = [];
this.warnings_ = []
};
+goog.exportSymbol("axs.AuditResults", axs.AuditResults);
axs.AuditResults.prototype.addError = function(a) {
"" != a && this.errors_.push(a)
};
+goog.exportProperty(axs.AuditResults.prototype, "addError", axs.AuditResults.prototype.addError);
axs.AuditResults.prototype.addWarning = function(a) {
"" != a && this.warnings_.push(a)
};
+goog.exportProperty(axs.AuditResults.prototype, "addWarning", axs.AuditResults.prototype.addWarning);
axs.AuditResults.prototype.numErrors = function() {
return this.errors_.length
};
+goog.exportProperty(axs.AuditResults.prototype, "numErrors", axs.AuditResults.prototype.numErrors);
axs.AuditResults.prototype.numWarnings = function() {
return this.warnings_.length
};
+goog.exportProperty(axs.AuditResults.prototype, "numWarnings", axs.AuditResults.prototype.numWarnings);
axs.AuditResults.prototype.getErrors = function() {
return this.errors_
};
+goog.exportProperty(axs.AuditResults.prototype, "getErrors", axs.AuditResults.prototype.getErrors);
axs.AuditResults.prototype.getWarnings = function() {
return this.warnings_
};
+goog.exportProperty(axs.AuditResults.prototype, "getWarnings", axs.AuditResults.prototype.getWarnings);
axs.AuditResults.prototype.toString = function() {
for(var a = "", b = 0;b < this.errors_.length;b++) {
0 == b && (a += "\nErrors:\n");
var c = this.errors_[b], a = a + (c + "\n\n")
}
for(b = 0;b < this.warnings_.length;b++) {
0 == b && (a += "\nWarnings:\n"), c = this.warnings_[b], a += c + "\n\n"
}
return a
};
+goog.exportProperty(axs.AuditResults.prototype, "toString", axs.AuditResults.prototype.toString);
axs.Audit = {};
axs.AuditConfiguration = function() {
this.rules_ = {};
this.auditRulesToIgnore = this.auditRulesToRun = this.scope = null;
- this.withConsoleApi = !1
+ this.withConsoleApi = !1;
+ goog.exportProperty(this, "scope", this.scope);
+ goog.exportProperty(this, "auditRulesToRun", this.auditRulesToRun);
+ goog.exportProperty(this, "auditRulesToIgnore", this.auditRulesToIgnore);
+ goog.exportProperty(this, "withConsoleApi", this.withConsoleApi)
};
+goog.exportSymbol("axs.AuditConfiguration", axs.AuditConfiguration);
axs.AuditConfiguration.prototype = {ignoreSelectors:function(a, b) {
a in this.rules_ || (this.rules_[a] = {});
"ignore" in this.rules_[a] || (this.rules_[a].ignore = []);
Array.prototype.push.call(this.rules_[a].ignore, b)
}, getIgnoreSelectors:function(a) {
return a in this.rules_ && "ignore" in this.rules_[a] ? this.rules_[a].ignore : []
}};
+goog.exportProperty(axs.AuditConfiguration.prototype, "ignoreSelectors", axs.AuditConfiguration.prototype.ignoreSelectors);
+goog.exportProperty(axs.AuditConfiguration.prototype, "getIgnoreSelectors", axs.AuditConfiguration.prototype.getIgnoreSelectors);
axs.Audit.run = function(a) {
a = a || new axs.AuditConfiguration;
var b = a.withConsoleApi, c = [], d;
d = a.auditRulesToRun && 0 < a.auditRulesToRun.length ? a.auditRulesToRun : Object.keys(axs.AuditRule.specs);
if(a.auditRulesToIgnore) {
@@ -571,23 +968,26 @@
c.push(g)
}
}
return c
};
+goog.exportSymbol("axs.Audit.run", axs.Audit.run);
axs.Audit.auditResults = function(a) {
for(var b = new axs.AuditResults, c = 0;c < a.length;c++) {
var d = a[c];
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)))
}
return b
};
+goog.exportSymbol("axs.Audit.auditResults", axs.Audit.auditResults);
axs.Audit.createReport = function(a, b) {
var c;
c = "*** Begin accessibility audit results ***\nAn accessibility audit found " + axs.Audit.auditResults(a).toString();
b && (c += "\nFor more information, please see ", c += b);
return c += "\n*** End accessibility audit results ***"
};
+goog.exportSymbol("axs.Audit.createReport", axs.Audit.createReport);
axs.Audit.accessibilityErrorMessage = function(a) {
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++) {
var e = a.elements[d], b = b + "\n";
try {
b += axs.utils.getQuerySelectorText(e)
@@ -596,10 +996,15 @@
}
}
"" != a.rule.url && (b += "\nSee " + a.rule.url + " for more information.");
return b
};
+goog.exportSymbol("axs.Audit.accessibilityErrorMessage", axs.Audit.accessibilityErrorMessage);
+axs.browserUtils = {};
+axs.browserUtils.matchSelector = function(a, b) {
+ return a.webkitMatchesSelector ? a.webkitMatchesSelector(b) : a.mozMatchesSelector(b)
+};
axs.AuditRule.specs.audioWithoutControls = {name:"audioWithoutControls", heading:"Audio elements should have controls", url:"", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
return a.querySelectorAll("audio[autoplay]")
}, test:function(a) {
return!a.querySelectorAll("[controls]").length && 3 < a.duration
}, code:"AX_AUDIO_01"};
@@ -628,11 +1033,11 @@
return!axs.utils.getRole(a).valid
}, code:"AX_ARIA_01"};
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) {
return a.querySelectorAll('input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), video:not([disabled])')
}, test:function(a) {
- return axs.utils.isElementOrAncestorHidden(a) || "button" == a.tagName.toLowerCase() && a.textContent.replace(/^\s+|\s+$/g, "").length ? !1 : !axs.utils.hasLabel(a) ? !0 : !1
+ return axs.utils.isElementOrAncestorHidden(a) || "button" == a.tagName.toLowerCase() && a.textContent.replace(/^\s+|\s+$/g, "").length ? !1 : axs.utils.hasLabel(a) ? !1 : !0
}, code:"AX_TEXT_01", ruleName:"Controls and media elements should have labels"};
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) {
return a.querySelectorAll(axs.utils.FOCUSABLE_ELEMENTS_SELECTOR)
}, test:function(a) {
return axs.utils.isElementOrAncestorHidden(a) ? !1 : !axs.utils.elementIsVisible(a)
@@ -656,10 +1061,30 @@
return document.evaluate('/html/body//text()[normalize-space(.)!=""]/parent::*[name()!="script"]', a, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
}, test:function(a) {
var b = window.getComputedStyle(a, null);
return(a = axs.utils.getContrastRatioForElementWithComputedStyle(b, a)) && axs.utils.isLowContrast(a, b)
}, code:"AX_COLOR_01"};
+axs.AuditRule.specs.elementsWithMeaningfulBackgroundImage = {name:"elementsWithMeaningfulBackgroundImage", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
+ a = a.querySelectorAll("*");
+ for(var b = [], c = 0;c < a.length;c++) {
+ var d = a[c];
+ axs.utils.isElementOrAncestorHidden(d) || b.push(d)
+ }
+ return b
+}, 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) {
+ if(a.textContent && 0 < a.textContent.length) {
+ return!1
+ }
+ a = window.getComputedStyle(a, null);
+ var b = a.backgroundImage;
+ if(!b || "undefined" === b || "none" === b) {
+ return!1
+ }
+ b = parseInt(a.width, 10);
+ a = parseInt(a.height, 10);
+ return 150 > b && 150 > a
+}, code:"AX_IMAGE_01"};
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) {
return a.querySelectorAll("[aria-labelledby]")
}, test:function(a) {
a = a.getAttribute("aria-labelledby").split(/\s+/);
for(var b = 0;b < a.length;b++) {
@@ -667,11 +1092,11 @@
return!0
}
}
return!1
}, code:"AX_ARIA_02"};
-axs.AuditRule.specs.pageWithoutTitle = {name:"pageWithoutTitle", heading:"Web pages have titles that describe topic or purpose", url:"", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
+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) {
return a
}, test:function(a) {
a = a.querySelector("head");
if(!a) {
return!0
@@ -699,10 +1124,10 @@
}, code:"AX_ARIA_03"};
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) {
a = a.querySelectorAll("*");
for(var b = [], c = 0;c < a.length;c++) {
var d = a[c];
- d instanceof HTMLBodyElement || axs.utils.isElementOrAncestorHidden(d) || "click" in getEventListeners(d) && b.push(d)
+ d instanceof d.ownerDocument.defaultView.HTMLBodyElement || axs.utils.isElementOrAncestorHidden(d) || "click" in getEventListeners(d) && b.push(d)
}
return b
}, test:function(a) {
return!a.hasAttribute("tabindex") && !axs.utils.isElementImplicitlyFocusable(a)
}, code:"AX_FOCUS_02"};