access_lint 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 055aeefa3d58a7afaf7751bdc5f0cc75da096a5e
4
- data.tar.gz: b61cf331d28cac860726a00fee4fd3c9616c17e0
3
+ metadata.gz: 61c3167df7c28d8cf3963573711fd781347ca7b3
4
+ data.tar.gz: b8250f03445261ed81b387eab7061c8aa84f5783
5
5
  SHA512:
6
- metadata.gz: 2525c9c3f57a24376933c860a8bdc3b21f05efef384cfd35e31c4fdfbee39c8279ff62785b1c6efb73b3758169f1027207317f26cb39fff137742ef01e450945
7
- data.tar.gz: fd72e8ee8da340aca4bac14b86075437c42c7170c4f23ea19933dd0283bedc988af6f69ae627b379f0c9c8fcd004b3492f892eeb0d782ebef72b7d37e7e13987
6
+ metadata.gz: 8f2af9a4ace4927f8163e84b5b4cfae2c7bf60963172f36ff558b85c7f76537c33e9ae2d53ce32d9cce35fca2805eb28df12ee031f53402c833b29891420dc8c
7
+ data.tar.gz: ec469e6b9e55c78d54d4a34805a1d4e4548f16e63f06c6f70a30e82cf277261e746458440fc36302b7a45c933db1c49c2c1816380cb9a2114277ab25cd32071e
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :development do
7
+ gem "vendorer"
7
8
  gem "rspec"
8
9
  gem "pry"
9
10
  gem "pry-stack_explorer"
data/README.md CHANGED
@@ -3,6 +3,10 @@ Command line runner for Google Accessibility Developer Tools.
3
3
 
4
4
  ## Installation
5
5
 
6
+ Install phantomjs:
7
+
8
+ $ brew install phantomjs
9
+
6
10
  Add this line to your application's Gemfile:
7
11
 
8
12
  gem 'access_lint'
@@ -11,18 +15,32 @@ And then execute:
11
15
 
12
16
  $ bundle
13
17
 
14
- Or install it yourself as:
18
+ ## Usage
15
19
 
16
- $ gem install access_lint
20
+ $ bundle exec access_lint <url-or-filename>
17
21
 
18
- ## Usage
22
+ ### Example
19
23
 
20
- $ access_lint audit http://localhost:3000/
24
+ $ bundle exec access_lint http://github.com
25
+ > *** Begin accessibility audit results ***
26
+ An accessibility audit found
27
+ Warnings:
28
+ Warning: AX_FOCUS_01 (These elements are focusable but either invisible or obscured by another element) failed on the following element:
29
+ body > .container > .site-footer > A
30
+ 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.
31
+
32
+ Warning: AX_COLOR_01 (Text elements should have a reasonable contrast ratio) failed on the following elements (1 - 5 of 15):
33
+ #site-container > .marketing-section.marketing-benefits > .container > .row > .one-third.column:nth-of-type(3) > P > A
34
+ #site-container > .marketing-section.marketing-desktop > .container > .marketing-header > .show-mac.show-linux > .text-muted
35
+ #site-container > .marketing-section.marketing-desktop > .container > .marketing-header > .show-mac.show-linux > .text-muted > A
36
+ body > .container > .site-footer > .site-footer-links.right > LI > A
37
+ body > .container > .site-footer > .site-footer-links.right > LI:nth-of-type(2) > A
38
+ 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.
21
39
 
22
- ## Contributing
23
40
 
24
- $ git submodule update --init --recursive
25
- $ rake axs:make
41
+ *** End accessibility audit results ***
42
+
43
+ ## Contributing
26
44
 
27
45
  1. Fork it
28
46
  2. Create your feature branch (`git checkout -b my-new-feature`)
data/Vendorfile ADDED
@@ -0,0 +1,6 @@
1
+ folder 'vendor/google-chrome/accessibility-developer-tools' do
2
+ from 'https://github.com/GoogleChrome/accessibility-developer-tools.git' do |checkout_location|
3
+ file 'README.md'
4
+ folder 'gen'
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module AccessLint
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -10,7 +10,7 @@ if (system.args.length !== 2) {
10
10
  url = system.args[1];
11
11
  page.open(url, function (status) {
12
12
  if (status === 'success') {
13
- page.injectJs('../vendor/google-chrome/axs_testing.js');
13
+ page.injectJs('../../google-chrome/accessibility-developer-tools/gen/axs_testing.js');
14
14
  var report = page.evaluate(function() {
15
15
  var results = axs.Audit.run();
16
16
  return axs.Audit.createReport(results);
@@ -0,0 +1,127 @@
1
+ Copyright 2013 Google Inc. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
15
+ # Accessibility Developer Tools
16
+
17
+ This is a library of accessibility-related testing and utility code.
18
+
19
+ Its main component is the accessibility audit: a collection of audit rules checking for common accessibility problems, and an API for running these rules in an HTML page.
20
+
21
+ There is also a collection of accessibility-related utility code, including but not limited to:
22
+ * contrast ratio calculation and color suggestions
23
+ * retrieving and validating ARIA attributes and states
24
+ * accessible name calculation using the algorithm at [http://www.w3.org/TR/wai-aria/roles#textalternativecomputation](http://www.w3.org/TR/wai-aria/roles#textalternativecomputation)
25
+
26
+ # Using the Audit API
27
+
28
+ ## Including the library
29
+
30
+ The simplest option is to include the generated `axs_testing.js` library on your page.
31
+
32
+ Work is underway to include the library in WebDriver and other automated testing frameworks.
33
+
34
+ ## The `axs.Audit.run()` method
35
+
36
+ Once you have included `axs_testing.js`, you can call call `axs.Audit.run()`. This returns an object in the following form:
37
+
38
+ {
39
+ /** @type {axs.constants.AuditResult} */
40
+ result, // one of PASS, FAIL or NA
41
+
42
+ /** @type {Array.<Element>} */
43
+ elements, // The elements which the rule fails on, if result == axs.constants.AuditResult.FAIL
44
+
45
+ /** @type {axs.AuditRule} */
46
+ rule // The rule which this result is for.
47
+ }
48
+
49
+ ## Using the results
50
+
51
+ ### Interpreting the result
52
+
53
+ The result may be one of three constants:
54
+ * `axs.constants.AuditResult.PASS` - This implies that there were elements on the page that may potentially have failed this audit rule, but they passed. Congratulations!
55
+ * `axs.constants.AuditResult.NA` - This implies that there were no elements on the page that may potentially have failed this audit rule. For example, an audit rule that checks video elements for subtitles would return this result if there were no video elements on the page.
56
+ * `axs.constants.AuditResult.FAIL` - This implies that there were elements on the page that did not pass this audit rule. This is the only result you will probably be interested in.
57
+
58
+ ### Creating a useful error message
59
+
60
+ The static, global `axs.Audit.createReport(results, opt_url)` may be used to create an error message using the return value of axs.Audit.run(). This will look like the following:
61
+
62
+ *** Begin accessibility audit results ***
63
+ An accessibility audit found 4 errors and 4 warnings on this page.
64
+ For more information, please see https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules
65
+
66
+ Error: badAriaAttributeValue (AX_ARIA_04) failed on the following elements (1 - 3 of 3):
67
+ DIV:nth-of-type(3) > INPUT
68
+ DIV:nth-of-type(5) > INPUT
69
+ #aria-invalid
70
+
71
+ Error: badAriaRole (AX_ARIA_01) failed on the following element:
72
+ DIV:nth-of-type(11) > SPAN
73
+
74
+ Error: controlsWithoutLabel (AX_TEXT_01) failed on the following elements (1 - 3 of 3):
75
+ DIV > INPUT
76
+ DIV:nth-of-type(12) > DIV:nth-of-type(3) > INPUT
77
+ LABEL > INPUT
78
+
79
+ Error: requiredAriaAttributeMissing (AX_ARIA_03) failed on the following element:
80
+ DIV:nth-of-type(13) > DIV:nth-of-type(11) > DIV
81
+
82
+ Warning: focusableElementNotVisibleAndNotAriaHidden (AX_FOCUS_01) failed on the following element:
83
+ #notariahidden
84
+
85
+ Warning: imagesWithoutAltText (AX_TEXT_02) failed on the following elements (1 - 2 of 2):
86
+ #deceptive-img
87
+ DIV:nth-of-type(13) > IMG
88
+
89
+ Warning: lowContrastElements (AX_COLOR_01) failed on the following elements (1 - 2 of 2):
90
+ DIV:nth-of-type(13) > DIV
91
+ DIV:nth-of-type(13) > DIV:nth-of-type(3)
92
+
93
+ Warning: nonExistentAriaLabelledbyElement (AX_ARIA_02) failed on the following elements (1 - 2 of 2):
94
+ DIV:nth-of-type(3) > INPUT
95
+ DIV:nth-of-type(5) > INPUT
96
+ *** End accessibility audit results ***
97
+
98
+ Each rule will have at most five elements listed as failures, in the form of a unique query selector for each element.
99
+
100
+ ### Configuring the Audit
101
+
102
+ If you wish to fine-tune the audit, you can create an `axs.AuditConfiguration` object, with the following options:
103
+
104
+ #### Ignore parts of the page for a particular audit rule
105
+
106
+ For example, say you have a separate high-contrast version of your page, and there is a CSS rule which causes certain elements (with class `pretty`) on the page to be low-contrast for stylistic reasons. Running the audit unmodified produces results something like
107
+
108
+ Warning: lowContrastElements (AX_COLOR_01) failed on the following elements (1 - 5 of 15):
109
+ ...
110
+
111
+ You can modify the audit to ignore the elements which are known and intended to have low contrast like this:
112
+
113
+ var configuration = new axs.AuditConfiguration();
114
+ configuration.ignoreSelectors('lowContrastElements', '.pretty');
115
+ axs.Audit.run(configuration);
116
+
117
+ The `AuditConfiguration.ignoreSelectors()` method takes a rule name, which you can find in the audit report, and a query selector string representing the parts of the page to be ignored for that audit rule. Multiple calls to `ignoreSelectors()` can be made for each audit rule, if multiple selectors need to be ignored.
118
+
119
+ #### Restrict the scope of the entire audit to a subsection of the page
120
+
121
+ You may have a part of the page which varies while other parts of the page stay constant, like a content area vs. a toolbar. In this case, running the audit on the entire page may give you spurious results in the part of the page which doesn't vary, which may drown out regressions in the main part of the page.
122
+
123
+ You can set a `scope` on the `AuditConfiguration` object like this:
124
+
125
+ var configuration = new axs.AuditConfiguration();
126
+ configuration.scope = document.querySelector('main'); // or however you wish to choose your scope element
127
+ axs.Audit.run(configuration);
@@ -3,9 +3,9 @@ goog.global = this;
3
3
  goog.exportPath_ = function(a, b, c) {
4
4
  a = a.split(".");
5
5
  c = c || goog.global;
6
- a[0] in c || !c.execScript || c.execScript("var " + a[0]);
6
+ !(a[0] in c) && c.execScript && c.execScript("var " + a[0]);
7
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
8
+ !a.length && void 0 !== b ? c[d] = b : c = c[d] ? c[d] : c[d] = {}
9
9
  }
10
10
  };
11
11
  goog.define = function(a, b) {
@@ -386,46 +386,7 @@ goog.base = function(a, b, c) {
386
386
  goog.scope = function(a) {
387
387
  a.call(goog.global)
388
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);
389
+ var axs = {};
429
390
  axs.browserUtils = {};
430
391
  axs.browserUtils.matchSelector = function(a, b) {
431
392
  return a.webkitMatchesSelector ? a.webkitMatchesSelector(b) : a.mozMatchesSelector(b)
@@ -464,7 +425,8 @@ axs.constants.addAllPropertiesToSet_ = function(a, b, c) {
464
425
  }
465
426
  }
466
427
  if(a.parent) {
467
- for(a = a.parent, d = 0;d < a.length;d++) {
428
+ a = a.parent;
429
+ for(d = 0;d < a.length;d++) {
468
430
  axs.constants.addAllPropertiesToSet_(axs.constants.ARIA_ROLES[a[d]], b, c)
469
431
  }
470
432
  }
@@ -501,15 +463,17 @@ submit:"input_type_submit", tel:"input_type_tel", text:"input_type_text", url:"i
501
463
  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
464
  axs.constants.TAG_TO_INFORMATION_TABLE_BRIEF_MSG = {BUTTON:"tag_button", SELECT:"tag_select", TEXTAREA:"tag_textarea"};
503
465
  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
466
+ (function() {
467
+ for(var a in axs.constants.ARIA_PROPERTIES) {
468
+ var b = axs.constants.ARIA_PROPERTIES[a];
469
+ if(b.values) {
470
+ for(var c = {}, d = 0;d < b.values.length;d++) {
471
+ c[b.values[d]] = !0
472
+ }
473
+ b.valuesSet = c
509
474
  }
510
- propertyDetails.valuesSet = valuesSet
511
475
  }
512
- }
476
+ })();
513
477
  axs.constants.Severity = {INFO:"Info", WARNING:"Warning", SEVERE:"Severe"};
514
478
  axs.constants.AuditResult = {PASS:"PASS", FAIL:"FAIL", NA:"NA"};
515
479
  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};
@@ -555,29 +519,34 @@ axs.utils.elementIsTransparent = function(a) {
555
519
  axs.utils.elementHasZeroArea = function(a) {
556
520
  a = a.getBoundingClientRect();
557
521
  var b = a.top - a.bottom;
558
- return a.right - a.left && b ? !1 : !0
522
+ return!(a.right - a.left) || !b ? !0 : !1
559
523
  };
560
524
  axs.utils.elementIsOutsideScrollArea = function(a) {
561
525
  a = a.getBoundingClientRect();
562
526
  var b = document.body.scrollWidth, c = document.body.scrollTop, d = document.body.scrollLeft;
563
527
  return a.top >= document.body.scrollHeight || a.bottom <= -c || a.left >= b || a.right <= -d ? !0 : !1
564
528
  };
529
+ axs.utils.isAncestor = function(a, b) {
530
+ return null == b ? !1 : b === a ? !0 : axs.utils.isAncestor(a, b.parentNode)
531
+ };
565
532
  axs.utils.overlappingElement = function(a) {
566
- function b(a, c) {
567
- return null == c ? !1 : c === a ? !0 : b(a, c.parentNode)
568
- }
569
533
  if(axs.utils.elementHasZeroArea(a)) {
570
534
  return null
571
535
  }
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
536
+ var b = a.getBoundingClientRect(), b = document.elementFromPoint((b.left + b.right) / 2, (b.top + b.bottom) / 2);
537
+ return null != b && b != a && !axs.utils.isAncestor(b, a) && !axs.utils.isAncestor(a, b) ? b : null
574
538
  };
575
539
  axs.utils.elementIsHtmlControl = function(a) {
576
540
  var b = a.ownerDocument.defaultView;
577
541
  return a instanceof b.HTMLButtonElement || a instanceof b.HTMLInputElement || a instanceof b.HTMLSelectElement || a instanceof b.HTMLTextAreaElement ? !0 : !1
578
542
  };
579
543
  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
544
+ if(a.hasAttribute("role") && (a = a.getAttribute("role"))) {
545
+ if((a = axs.constants.ARIA_ROLES[a]) && "widget" in a.allParentRolesSet) {
546
+ return!0
547
+ }
548
+ }
549
+ return!1
581
550
  };
582
551
  axs.utils.elementIsVisible = function(a) {
583
552
  if(axs.utils.elementIsTransparent(a) || axs.utils.elementHasZeroArea(a) || axs.utils.elementIsOutsideScrollArea(a)) {
@@ -619,39 +588,46 @@ axs.utils.isLargeFont = function(a) {
619
588
  };
620
589
  axs.utils.getBgColor = function(a, b) {
621
590
  var c = axs.utils.parseColor(a.backgroundColor);
622
- if(!c || a.backgroundImage && "none" != a.backgroundImage) {
591
+ if(!c) {
623
592
  return null
624
593
  }
594
+ 1 > a.opacity && (c.alpha *= a.opacity);
625
595
  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)
596
+ var d = axs.utils.getParentBgColor(b);
597
+ if(null == d) {
598
+ return null
643
599
  }
644
- c = d
600
+ c = axs.utils.flattenColors(c, d)
645
601
  }
646
602
  return c
647
603
  };
648
- axs.utils.getFgColor = function(a, b) {
649
- var c = axs.utils.parseColor(a.color);
650
- if(!c) {
604
+ axs.utils.getParentBgColor = function(a) {
605
+ var b = a;
606
+ a = [];
607
+ for(var c = null;b = b.parentElement;) {
608
+ var d = window.getComputedStyle(b, null);
609
+ if(d) {
610
+ var e = axs.utils.parseColor(d.backgroundColor);
611
+ if(e && (1 > d.opacity && (e.alpha *= d.opacity), 0 != e.alpha && (a.push(e), 1 == e.alpha))) {
612
+ c = !0;
613
+ break
614
+ }
615
+ }
616
+ }
617
+ c || a.push(new axs.utils.Color(255, 255, 255, 1));
618
+ for(b = a.pop();a.length;) {
619
+ c = a.pop(), b = axs.utils.flattenColors(c, b)
620
+ }
621
+ return b
622
+ };
623
+ axs.utils.getFgColor = function(a, b, c) {
624
+ var d = axs.utils.parseColor(a.color);
625
+ if(!d) {
651
626
  return null
652
627
  }
653
- 1 > c.alpha && (c = axs.utils.flattenColors(c, b));
654
- return c
628
+ 1 > d.alpha && (d = axs.utils.flattenColors(d, c));
629
+ 1 > a.opacity && (b = axs.utils.getParentBgColor(b), d.alpha *= a.opacity, d = axs.utils.flattenColors(d, b));
630
+ return d
655
631
  };
656
632
  axs.utils.parseColor = function(a) {
657
633
  var b = a.match(/^rgb\((\d+), (\d+), (\d+)\)$/);
@@ -663,6 +639,7 @@ axs.utils.parseColor = function(a) {
663
639
  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
640
  };
665
641
  axs.utils.colorChannelToString = function(a) {
642
+ a = Math.round(a);
666
643
  return 15 >= a ? "0" + a.toString(16) : a.toString(16)
667
644
  };
668
645
  axs.utils.colorToString = function(a) {
@@ -699,7 +676,7 @@ axs.utils.suggestColors = function(a, b, c, d) {
699
676
  };
700
677
  axs.utils.flattenColors = function(a, b) {
701
678
  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)
679
+ 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, a.alpha + b.alpha * (1 - a.alpha))
703
680
  };
704
681
  axs.utils.calculateLuminance = function(a) {
705
682
  return axs.utils.toYCC(a)[0]
@@ -777,15 +754,15 @@ axs.utils.getContrastRatioForElement = function(a) {
777
754
  return axs.utils.getContrastRatioForElementWithComputedStyle(b, a)
778
755
  };
779
756
  axs.utils.getContrastRatioForElementWithComputedStyle = function(a, b) {
780
- if(!axs.utils.elementIsVisible(b)) {
757
+ if(axs.utils.isElementHidden(b)) {
781
758
  return null
782
759
  }
783
760
  var c = axs.utils.getBgColor(a, b);
784
761
  if(!c) {
785
762
  return null
786
763
  }
787
- var d = axs.utils.getFgColor(a, c);
788
- return d ? axs.utils.calculateContrastRatio(d, c) : null
764
+ var d = axs.utils.getFgColor(a, b, c);
765
+ return!d ? null : axs.utils.calculateContrastRatio(d, c)
789
766
  };
790
767
  axs.utils.isNativeTextElement = function(a) {
791
768
  var b = a.tagName.toLowerCase();
@@ -881,6 +858,8 @@ axs.utils.getAriaPropertyValue = function(a, b, c) {
881
858
  }
882
859
  return d;
883
860
  case "integer":
861
+ ;
862
+ case "decimal":
884
863
  c = axs.utils.isValidNumber(b);
885
864
  if(!c.valid) {
886
865
  return d.valid = !1, d.reason = c.reason, d
@@ -914,7 +893,7 @@ axs.utils.isValidTokenValue = function(a, b) {
914
893
  return axs.utils.isPossibleValue(b, axs.constants.ARIA_PROPERTIES[c].valuesSet, a)
915
894
  };
916
895
  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)}
896
+ return!b[a] ? {valid:!1, value:a, reason:'"' + a + '" is not a valid value for ' + c, possibleValues:Object.keys(b)} : {valid:!0, value:a}
918
897
  };
919
898
  axs.utils.isValidBoolean = function(a) {
920
899
  try {
@@ -925,10 +904,14 @@ axs.utils.isValidBoolean = function(a) {
925
904
  return"boolean" != typeof b ? {valid:!1, value:a, reason:'"' + a + '" is not a true/false value'} : {valid:!0, value:b}
926
905
  };
927
906
  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 + '"'}
907
+ return 0 == a.length ? {valid:!0, idref:a} : !b.ownerDocument.getElementById(a) ? {valid:!1, idref:a, reason:'No element with ID "' + a + '"'} : {valid:!0, idref:a}
929
908
  };
930
909
  axs.utils.isValidNumber = function(a) {
931
- var b = JSON.parse(a);
910
+ try {
911
+ var b = JSON.parse(a)
912
+ }catch(c) {
913
+ return{valid:!1, value:a, reason:'"' + a + '" is not a number'}
914
+ }
932
915
  return"number" != typeof b ? {valid:!1, value:a, reason:'"' + a + '" is not a number'} : {valid:!0, value:b}
933
916
  };
934
917
  axs.utils.isElementImplicitlyFocusable = function(a) {
@@ -995,552 +978,592 @@ axs.utils.getQuerySelectorText = function(a) {
995
978
  }
996
979
  return""
997
980
  };
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))
981
+ axs.properties = {};
982
+ axs.properties.TEXT_CONTENT_XPATH = './/text()[normalize-space(.)!=""]/parent::*[name()!="script"]';
983
+ axs.properties.getFocusProperties = function(a) {
984
+ a = a.getAttribute("tabindex");
985
+ return void 0 != a ? {tabindex:{value:a, valid:!0}} : null
986
+ };
987
+ axs.properties.getColorProperties = function(a) {
988
+ var b = {};
989
+ (a = axs.properties.getContrastRatioProperties(a)) && (b.contrastRatio = a);
990
+ return 0 == Object.keys(b).length ? null : b
991
+ };
992
+ axs.properties.getContrastRatioProperties = function(a) {
993
+ for(var b = document.evaluate(axs.properties.TEXT_CONTENT_XPATH, a, null, XPathResult.ANY_TYPE, null), c = !1, d = b.iterateNext();null != d;d = b.iterateNext()) {
994
+ if(d === a) {
995
+ c = !0;
996
+ break
997
+ }
1002
998
  }
1003
- if(!b) {
1004
- throw"Invalid spec; the following fields were not specified: " + c.join(", ") + "\n" + JSON.stringify(a);
999
+ if(!c) {
1000
+ return null
1005
1001
  }
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)
1002
+ b = {};
1003
+ c = window.getComputedStyle(a, null);
1004
+ d = axs.utils.getBgColor(c, a);
1005
+ if(!d) {
1006
+ return null
1007
+ }
1008
+ b.backgroundColor = axs.utils.colorToString(d);
1009
+ var e = axs.utils.getFgColor(c, a, d);
1010
+ b.foregroundColor = axs.utils.colorToString(e);
1011
+ a = axs.utils.getContrastRatioForElementWithComputedStyle(c, a);
1012
+ if(!a) {
1013
+ return null
1014
+ }
1015
+ b.value = a.toFixed(2);
1016
+ axs.utils.isLowContrast(a, c) && (b.alert = !0);
1017
+ (a = axs.utils.suggestColors(d, e, a, c)) && Object.keys(a).length && (b.suggestedColors = a);
1018
+ return b
1019
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
1020
+ axs.properties.findTextAlternatives = function(a, b, c) {
1021
+ var d = c || !1;
1022
+ c = axs.utils.asElement(a);
1023
+ if(!c || !d && axs.utils.isElementOrAncestorHidden(c)) {
1024
+ return null
1025
+ }
1026
+ if(a.nodeType == Node.TEXT_NODE) {
1027
+ return c = {type:"text"}, c.text = a.textContent, c.lastWord = axs.properties.getLastWord(c.text), b.content = c, a.textContent
1028
+ }
1029
+ a = null;
1030
+ d || (a = axs.properties.getTextFromAriaLabelledby(c, b));
1031
+ if(c.hasAttribute("aria-label")) {
1032
+ var e = {type:"text"};
1033
+ e.text = c.getAttribute("aria-label");
1034
+ e.lastWord = axs.properties.getLastWord(e.text);
1035
+ if(a) {
1036
+ e.unused = !0
1037
+ }else {
1038
+ if(!d || !axs.utils.elementIsHtmlControl(c)) {
1039
+ a = e.text
1025
1040
  }
1026
1041
  }
1027
- return!1
1042
+ b.ariaLabel = e
1028
1043
  }
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
1044
+ if(!c.hasAttribute("role") || "presentation" != c.getAttribute("role")) {
1045
+ a = axs.properties.getTextFromHostLangaugeAttributes(c, b, a)
1046
+ }
1047
+ if(d && axs.utils.elementIsHtmlControl(c)) {
1048
+ e = c.ownerDocument.defaultView;
1049
+ if(c instanceof e.HTMLInputElement) {
1050
+ var f = c;
1051
+ "text" == f.type && f.value && 0 < f.value.length && (b.controlValue = {text:f.value});
1052
+ "range" == f.type && (b.controlValue = {text:f.value})
1053
+ }
1054
+ c instanceof e.HTMLSelectElement && (b.controlValue = {text:f.value});
1055
+ b.controlValue && (f = b.controlValue, a ? f.unused = !0 : a = f.text)
1056
+ }
1057
+ if(d && axs.utils.elementIsAriaWidget(c)) {
1058
+ d = c.getAttribute("role");
1059
+ "textbox" == d && c.textContent && 0 < c.textContent.length && (b.controlValue = {text:c.textContent});
1060
+ if("slider" == d || "spinbutton" == d) {
1061
+ 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")})
1062
+ }
1063
+ if("menu" == d) {
1064
+ for(var g = c.querySelectorAll("[role=menuitemcheckbox], [role=menuitemradio]"), f = [], e = 0;e < g.length;e++) {
1065
+ "true" == g[e].getAttribute("aria-checked") && f.push(g[e])
1034
1066
  }
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)
1067
+ if(0 < f.length) {
1068
+ g = "";
1069
+ for(e = 0;e < f.length;e++) {
1070
+ g += axs.properties.findTextAlternatives(f[e], {}, !0), e < f.length - 1 && (g += ", ")
1071
+ }
1072
+ b.controlValue = {text:g}
1038
1073
  }
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
1074
  }
1046
- for(g = 0;g < e.length;g++) {
1047
- h = e[g], this.test_(h) && !c(h) && this.addNode(f, h)
1075
+ if("combobox" == d || "select" == d) {
1076
+ b.controlValue = {text:"TODO"}
1048
1077
  }
1078
+ b.controlValue && (f = b.controlValue, a ? f.unused = !0 : a = f.text)
1049
1079
  }
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
1080
+ if(d = axs.properties.getTextFromDescendantContent(c)) {
1081
+ f = {type:"text"}, f.text = d, f.lastWord = axs.properties.getLastWord(f.text), a ? f.unused = !0 : a = d, b.content = f
1069
1082
  }
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
1083
+ 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);
1084
+ return 0 == Object.keys(b).length && null == a ? null : a
1085
+ };
1086
+ axs.properties.getTextFromDescendantContent = function(a) {
1087
+ if(a.hasAttribute("role")) {
1088
+ var b = a.getAttribute("role");
1089
+ if((b = axs.constants.ARIA_ROLES[b]) && (!b.namefrom || 0 > b.namefrom.indexOf("contents"))) {
1090
+ return null
1080
1091
  }
1081
1092
  }
1082
- return axs.AuditRules.rules[a]
1093
+ a = a.childNodes;
1094
+ for(var b = [], c = 0;c < a.length;c++) {
1095
+ var d = axs.properties.findTextAlternatives(a[c], {}, !0);
1096
+ d && 0 < d.trim().length && b.push(d.trim())
1097
+ }
1098
+ return b.length ? b.join(" ") : null
1083
1099
  };
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 + "],"
1100
+ axs.properties.getTextFromAriaLabelledby = function(a, b) {
1101
+ var c = null;
1102
+ if(!a.hasAttribute("aria-labelledby")) {
1103
+ return c
1088
1104
  }
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
- }
1105
+ for(var d = a.getAttribute("aria-labelledby").split(/\s+/), e = {valid:!0}, f = [], g = [], h = 0;h < d.length;h++) {
1106
+ var k = {type:"element"}, m = d[h];
1107
+ k.value = m;
1108
+ var l = document.getElementById(m);
1109
+ 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]});
1110
+ g.push(k)
1100
1111
  }
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
1112
+ 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);
1113
+ return c
1114
+ };
1115
+ axs.properties.getTextFromHostLangaugeAttributes = function(a, b, c) {
1116
+ if(axs.browserUtils.matchSelector(a, "img")) {
1117
+ if(a.hasAttribute("alt")) {
1118
+ var d = {type:"string", valid:!0};
1119
+ d.text = a.getAttribute("alt");
1120
+ c ? d.unused = !0 : c = d.text;
1121
+ b.alt = d
1122
+ }else {
1123
+ 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})
1161
1124
  }
1162
1125
  }
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
1126
+ if(axs.browserUtils.matchSelector(a, 'input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), video:not([disabled])')) {
1127
+ if(a.hasAttribute("id")) {
1128
+ for(var d = document.querySelectorAll("label[for=" + a.id + "]"), e = {}, f = [], g = [], h = 0;h < d.length;h++) {
1129
+ var k = {type:"element"}, m = d[h], l = axs.properties.findTextAlternatives(m, {}, !0);
1130
+ l && 0 < l.trim().length && (k.text = l.trim(), g.push(l.trim()));
1131
+ k.element = m;
1132
+ f.push(k)
1177
1133
  }
1134
+ 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)
1178
1135
  }
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)
1136
+ d = a.parentElement;
1137
+ for(e = {};d;) {
1138
+ if("label" == d.tagName.toLowerCase() && (f = d, f.control == a)) {
1139
+ e.type = "element";
1140
+ e.text = axs.properties.findTextAlternatives(f, {}, !0);
1141
+ e.lastWord = axs.properties.getLastWord(e.text);
1142
+ e.element = f;
1143
+ break
1144
+ }
1145
+ d = d.parentElement
1234
1146
  }
1147
+ e.text && (c ? e.unused = !0 : c = e.text, b.labelWrapped = e);
1148
+ Object.keys(b).length || (b.noLabel = !0)
1235
1149
  }
1236
1150
  return c
1237
1151
  };
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)))
1152
+ axs.properties.getLastWord = function(a) {
1153
+ if(!a) {
1154
+ return null
1243
1155
  }
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 ***"
1156
+ var b = a.lastIndexOf(" ") + 1, c = a.length - 10;
1157
+ return a.substring(b > c ? b : c)
1252
1158
  };
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
1159
+ axs.properties.getTextProperties = function(a) {
1160
+ var b = {};
1161
+ a = axs.properties.findTextAlternatives(a, b);
1162
+ if(0 == Object.keys(b).length) {
1163
+ if(!a) {
1164
+ return null
1261
1165
  }
1166
+ b.hasProperties = !1
1167
+ }else {
1168
+ b.hasProperties = !0
1262
1169
  }
1263
- "" != a.rule.url && (b += "\nSee " + a.rule.url + " for more information.");
1170
+ b.computedText = a;
1171
+ b.lastWord = axs.properties.getLastWord(a);
1264
1172
  return b
1265
1173
  };
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
1174
+ axs.properties.getAriaProperties = function(a) {
1175
+ var b = {}, c = axs.properties.getGlobalAriaProperties(a), d;
1176
+ for(d in axs.constants.ARIA_PROPERTIES) {
1177
+ var e = "aria-" + d;
1178
+ if(a.hasAttribute(e)) {
1179
+ var f = a.getAttribute(e);
1180
+ c[e] = axs.utils.getAriaPropertyValue(e, f, a)
1181
+ }
1182
+ }
1183
+ 0 < Object.keys(c).length && (b.properties = axs.utils.values(c));
1184
+ f = axs.utils.getRoles(a);
1185
+ if(!f) {
1186
+ return Object.keys(b).length ? b : null
1187
+ }
1188
+ b.roles = f;
1189
+ if(!f.valid || !f.roles) {
1190
+ return b
1191
+ }
1192
+ for(var e = f.roles, g = 0;g < e.length;g++) {
1193
+ var h = e[g];
1194
+ if(h.details && h.details.propertiesSet) {
1195
+ for(d in h.details.propertiesSet) {
1196
+ 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"}))
1197
+ }
1198
+ }
1199
+ }
1200
+ 0 < Object.keys(c).length && (b.properties = axs.utils.values(c));
1201
+ return 0 < Object.keys(b).length ? b : null
1274
1202
  };
1275
- axs.content.getResultNode = function(a) {
1276
- var b = axs.content.auditResultNodes[a];
1277
- delete axs.content.auditResultNodes[a];
1203
+ axs.properties.getGlobalAriaProperties = function(a) {
1204
+ for(var b = {}, c = 0;c < axs.constants.GLOBAL_PROPERTIES.length;c++) {
1205
+ var d = axs.constants.GLOBAL_PROPERTIES[c];
1206
+ if(a.hasAttribute(d)) {
1207
+ var e = a.getAttribute(d);
1208
+ b[d] = axs.utils.getAriaPropertyValue(d, e, a)
1209
+ }
1210
+ }
1278
1211
  return b
1279
1212
  };
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) {
1213
+ axs.properties.getVideoProperties = function(a) {
1214
+ if(!axs.browserUtils.matchSelector(a, "video")) {
1294
1215
  return null
1295
1216
  }
1296
- var b = {}, c = window.getComputedStyle(a, null), d = axs.utils.getBgColor(c, a);
1297
- if(!d) {
1298
- return null
1217
+ var b = {};
1218
+ b.captionTracks = axs.properties.getTrackElements(a, "captions");
1219
+ b.descriptionTracks = axs.properties.getTrackElements(a, "descriptions");
1220
+ b.chapterTracks = axs.properties.getTrackElements(a, "chapters");
1221
+ return b
1222
+ };
1223
+ axs.properties.getTrackElements = function(a, b) {
1224
+ var c = a.querySelectorAll("track[kind=" + b + "]"), d = {};
1225
+ if(!c.length) {
1226
+ return d.valid = !1, d.reason = {messageKey:"noTracksProvided", args:[[b]]}, d
1299
1227
  }
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
1228
+ d.valid = !0;
1229
+ for(var e = [], f = 0;f < c.length;f++) {
1230
+ var g = {}, h = c[f].getAttribute("src"), k = c[f].getAttribute("srcLang"), m = c[f].getAttribute("label");
1231
+ h ? (g.valid = !0, g.src = h) : (g.valid = !1, g.reason = {messageKey:"noSrcProvided"});
1232
+ h = "";
1233
+ m && (h += m, k && (h += " "));
1234
+ k && (h += "(" + k + ")");
1235
+ "" == h && (h = "[[object Object]]");
1236
+ g.name = h;
1237
+ e.push(g)
1306
1238
  }
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
1239
+ d.values = e;
1240
+ return d
1311
1241
  };
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
1242
+ axs.properties.getAllProperties = function(a) {
1243
+ var b = axs.utils.asElement(a);
1244
+ if(!b) {
1245
+ return{}
1317
1246
  }
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
1247
+ var c = {};
1248
+ c.ariaProperties = axs.properties.getAriaProperties(b);
1249
+ c.colorProperties = axs.properties.getColorProperties(b);
1250
+ c.focusProperties = axs.properties.getFocusProperties(b);
1251
+ c.textProperties = axs.properties.getTextProperties(a);
1252
+ c.videoProperties = axs.properties.getVideoProperties(b);
1253
+ return c
1254
+ };
1255
+ axs.AuditRule = function(a) {
1256
+ for(var b = !0, c = [], d = 0;d < axs.AuditRule.requiredFields.length;d++) {
1257
+ var e = axs.AuditRule.requiredFields[d];
1258
+ e in a || (b = !1, c.push(e))
1320
1259
  }
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
1260
+ if(!b) {
1261
+ throw"Invalid spec; the following fields were not specified: " + c.join(", ") + "\n" + JSON.stringify(a);
1329
1262
  }
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})
1263
+ this.name = a.name;
1264
+ this.severity = a.severity;
1265
+ this.relevantNodesSelector_ = a.relevantNodesSelector;
1266
+ this.test_ = a.test;
1267
+ this.code = a.code;
1268
+ this.heading = a.heading || "";
1269
+ this.url = a.url || "";
1270
+ this.requiresConsoleAPI = !!a.opt_requiresConsoleAPI
1271
+ };
1272
+ axs.AuditRule.requiredFields = "name severity relevantNodesSelector test code heading".split(" ");
1273
+ axs.AuditRule.NOT_APPLICABLE = {result:axs.constants.AuditResult.NA};
1274
+ axs.AuditRule.prototype.addNode = function(a, b) {
1275
+ a.push(b)
1276
+ };
1277
+ axs.AuditRule.prototype.run = function(a, b) {
1278
+ function c(a) {
1279
+ for(var b = 0;b < d.length;b++) {
1280
+ if(axs.browserUtils.matchSelector(a, d[b])) {
1281
+ return!0
1282
+ }
1337
1283
  }
1338
- c instanceof e.HTMLSelectElement && (b.controlValue = {text:f.value});
1339
- b.controlValue && (f = b.controlValue, a ? f.unused = !0 : a = f.text)
1284
+ return!1
1340
1285
  }
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])
1286
+ var d = a || [], e = this.relevantNodesSelector_(b || document), f = [];
1287
+ if(e instanceof XPathResult) {
1288
+ if(e.resultType == XPathResult.ORDERED_NODE_SNAPSHOT_TYPE) {
1289
+ if(!e.snapshotLength) {
1290
+ return axs.AuditRule.NOT_APPLICABLE
1350
1291
  }
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}
1292
+ for(var g = 0;g < e.snapshotLength;g++) {
1293
+ var h = e.snapshotItem(g);
1294
+ this.test_(h) && !c(h) && this.addNode(f, h)
1357
1295
  }
1296
+ }else {
1297
+ return console.warn("Unknown XPath result type", e), null
1358
1298
  }
1359
- if("combobox" == d || "select" == d) {
1360
- b.controlValue = {text:"TODO"}
1299
+ }else {
1300
+ if(!e.length) {
1301
+ return{result:axs.constants.AuditResult.NA}
1302
+ }
1303
+ for(g = 0;g < e.length;g++) {
1304
+ h = e[g], this.test_(h) && !c(h) && this.addNode(f, h)
1361
1305
  }
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
1306
  }
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
1307
+ return{result:f.length ? axs.constants.AuditResult.FAIL : axs.constants.AuditResult.PASS, elements:f}
1369
1308
  };
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
1309
+ axs.AuditRule.specs = {};
1310
+ axs.AuditRules = {};
1311
+ axs.AuditRules.getRule = function(a) {
1312
+ if(!axs.AuditRules.rules) {
1313
+ axs.AuditRules.rules = {};
1314
+ for(var b in axs.AuditRule.specs) {
1315
+ var c = axs.AuditRule.specs[b], d = new axs.AuditRule(c);
1316
+ axs.AuditRules.rules[c.name] = d
1375
1317
  }
1376
1318
  }
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
1319
+ return axs.AuditRules.rules[a]
1383
1320
  };
1384
- axs.properties.getTextFromAriaLabelledby = function(a, b) {
1385
- var c = null;
1386
- if(!a.hasAttribute("aria-labelledby")) {
1387
- return c
1321
+ axs.AuditResults = function() {
1322
+ this.errors_ = [];
1323
+ this.warnings_ = []
1324
+ };
1325
+ goog.exportSymbol("axs.AuditResults", axs.AuditResults);
1326
+ axs.AuditResults.prototype.addError = function(a) {
1327
+ "" != a && this.errors_.push(a)
1328
+ };
1329
+ goog.exportProperty(axs.AuditResults.prototype, "addError", axs.AuditResults.prototype.addError);
1330
+ axs.AuditResults.prototype.addWarning = function(a) {
1331
+ "" != a && this.warnings_.push(a)
1332
+ };
1333
+ goog.exportProperty(axs.AuditResults.prototype, "addWarning", axs.AuditResults.prototype.addWarning);
1334
+ axs.AuditResults.prototype.numErrors = function() {
1335
+ return this.errors_.length
1336
+ };
1337
+ goog.exportProperty(axs.AuditResults.prototype, "numErrors", axs.AuditResults.prototype.numErrors);
1338
+ axs.AuditResults.prototype.numWarnings = function() {
1339
+ return this.warnings_.length
1340
+ };
1341
+ goog.exportProperty(axs.AuditResults.prototype, "numWarnings", axs.AuditResults.prototype.numWarnings);
1342
+ axs.AuditResults.prototype.getErrors = function() {
1343
+ return this.errors_
1344
+ };
1345
+ goog.exportProperty(axs.AuditResults.prototype, "getErrors", axs.AuditResults.prototype.getErrors);
1346
+ axs.AuditResults.prototype.getWarnings = function() {
1347
+ return this.warnings_
1348
+ };
1349
+ goog.exportProperty(axs.AuditResults.prototype, "getWarnings", axs.AuditResults.prototype.getWarnings);
1350
+ axs.AuditResults.prototype.toString = function() {
1351
+ for(var a = "", b = 0;b < this.errors_.length;b++) {
1352
+ 0 == b && (a += "\nErrors:\n");
1353
+ var c = this.errors_[b], a = a + (c + "\n\n")
1388
1354
  }
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)
1355
+ for(b = 0;b < this.warnings_.length;b++) {
1356
+ 0 == b && (a += "\nWarnings:\n"), c = this.warnings_[b], a += c + "\n\n"
1395
1357
  }
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
1358
+ return a
1398
1359
  };
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})
1360
+ goog.exportProperty(axs.AuditResults.prototype, "toString", axs.AuditResults.prototype.toString);
1361
+ axs.Audit = {};
1362
+ axs.AuditConfiguration = function() {
1363
+ this.rules_ = {};
1364
+ this.auditRulesToIgnore = this.auditRulesToRun = this.scope = null;
1365
+ this.withConsoleApi = !1;
1366
+ goog.exportProperty(this, "scope", this.scope);
1367
+ goog.exportProperty(this, "auditRulesToRun", this.auditRulesToRun);
1368
+ goog.exportProperty(this, "auditRulesToIgnore", this.auditRulesToIgnore);
1369
+ goog.exportProperty(this, "withConsoleApi", this.withConsoleApi)
1370
+ };
1371
+ goog.exportSymbol("axs.AuditConfiguration", axs.AuditConfiguration);
1372
+ axs.AuditConfiguration.prototype = {ignoreSelectors:function(a, b) {
1373
+ a in this.rules_ || (this.rules_[a] = {});
1374
+ "ignore" in this.rules_[a] || (this.rules_[a].ignore = []);
1375
+ Array.prototype.push.call(this.rules_[a].ignore, b)
1376
+ }, getIgnoreSelectors:function(a) {
1377
+ return a in this.rules_ && "ignore" in this.rules_[a] ? this.rules_[a].ignore : []
1378
+ }};
1379
+ goog.exportProperty(axs.AuditConfiguration.prototype, "ignoreSelectors", axs.AuditConfiguration.prototype.ignoreSelectors);
1380
+ goog.exportProperty(axs.AuditConfiguration.prototype, "getIgnoreSelectors", axs.AuditConfiguration.prototype.getIgnoreSelectors);
1381
+ axs.Audit.run = function(a) {
1382
+ a = a || new axs.AuditConfiguration;
1383
+ var b = a.withConsoleApi, c = [], d;
1384
+ d = a.auditRulesToRun && 0 < a.auditRulesToRun.length ? a.auditRulesToRun : Object.keys(axs.AuditRule.specs);
1385
+ if(a.auditRulesToIgnore) {
1386
+ for(var e = 0;e < a.auditRulesToIgnore.length;e++) {
1387
+ var f = a.auditRulesToIgnore[e];
1388
+ 0 > d.indexOf(f) || d.splice(d.indexOf(f), 1)
1408
1389
  }
1409
1390
  }
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
1391
+ for(e = 0;e < d.length;e++) {
1392
+ if((f = axs.AuditRules.getRule(d[e])) && !f.disabled && (b || !f.requiresConsoleAPI)) {
1393
+ var g = [], h = a.getIgnoreSelectors(f.name);
1394
+ (0 < h.length || a.scope) && g.push(h);
1395
+ a.scope && g.push(a.scope);
1396
+ g = f.run.apply(f, g);
1397
+ g.rule = axs.utils.namedValues(f);
1398
+ c.push(g)
1430
1399
  }
1431
- e.text && (c ? e.unused = !0 : c = e.text, b.labelWrapped = e);
1432
- Object.keys(b).length || (b.noLabel = !0)
1433
1400
  }
1434
1401
  return c
1435
1402
  };
1436
- axs.properties.getLastWord = function(a) {
1437
- if(!a) {
1438
- return null
1403
+ goog.exportSymbol("axs.Audit.run", axs.Audit.run);
1404
+ axs.Audit.auditResults = function(a) {
1405
+ for(var b = new axs.AuditResults, c = 0;c < a.length;c++) {
1406
+ var d = a[c];
1407
+ 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)))
1439
1408
  }
1440
- var b = a.lastIndexOf(" ") + 1, c = a.length - 10;
1441
- return a.substring(b > c ? b : c)
1409
+ return b
1442
1410
  };
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
1411
+ goog.exportSymbol("axs.Audit.auditResults", axs.Audit.auditResults);
1412
+ axs.Audit.createReport = function(a, b) {
1413
+ var c;
1414
+ c = "*** Begin accessibility audit results ***\nAn accessibility audit found " + axs.Audit.auditResults(a).toString();
1415
+ b && (c += "\nFor more information, please see ", c += b);
1416
+ return c += "\n*** End accessibility audit results ***"
1417
+ };
1418
+ goog.exportSymbol("axs.Audit.createReport", axs.Audit.createReport);
1419
+ axs.Audit.accessibilityErrorMessage = function(a) {
1420
+ 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++) {
1421
+ var e = a.elements[d], b = b + "\n";
1422
+ try {
1423
+ b += axs.utils.getQuerySelectorText(e)
1424
+ }catch(f) {
1425
+ b += " tagName:" + e.tagName, b += " id:" + e.id
1449
1426
  }
1450
- b.hasProperties = !1
1451
- }else {
1452
- b.hasProperties = !0
1453
1427
  }
1454
- b.computedText = a;
1455
- b.lastWord = axs.properties.getLastWord(a);
1428
+ "" != a.rule.url && (b += "\nSee " + a.rule.url + " for more information.");
1456
1429
  return b
1457
1430
  };
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
- }
1431
+ goog.exportSymbol("axs.Audit.accessibilityErrorMessage", axs.Audit.accessibilityErrorMessage);
1432
+ axs.AuditRule.specs.mainRoleOnInappropriateElement = {name:"mainRoleOnInappropriateElement", heading:"role=main should only appear on significant elements", url:"", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
1433
+ return a.querySelectorAll("[role~=main]")
1434
+ }, test:function(a) {
1435
+ return axs.utils.isInlineElement(a) || 50 > axs.properties.findTextAlternatives(a, {}).length ? !0 : !1
1436
+ }, code:"AX_ARIA_04"};
1437
+ axs.AuditRule.specs.audioWithoutControls = {name:"audioWithoutControls", heading:"Audio elements should have controls", url:"", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
1438
+ return a.querySelectorAll("audio[autoplay]")
1439
+ }, test:function(a) {
1440
+ return!a.querySelectorAll("[controls]").length && 3 < a.duration
1441
+ }, code:"AX_AUDIO_01"};
1442
+ 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) {
1443
+ return a
1444
+ }, test:function(a) {
1445
+ a = a.querySelector("head");
1446
+ if(!a) {
1447
+ return!0
1467
1448
  }
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
1449
+ a = a.querySelector("title");
1450
+ return!a.length || !a[0].textContent
1451
+ }, code:"AX_TITLE_01"};
1452
+ axs.AuditRule.specs.lowContrastElements = {name:"lowContrastElements", heading:"Text elements should have a reasonable contrast ratio", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#-ax_color_01--text-elements-should-have-a-reasonable-contrast-ratio", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
1453
+ return document.evaluate('.//text()[normalize-space(.)!=""]/parent::*[name()!="script"]', a, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
1454
+ }, test:function(a) {
1455
+ var b = window.getComputedStyle(a, null);
1456
+ return(a = axs.utils.getContrastRatioForElementWithComputedStyle(b, a)) && axs.utils.isLowContrast(a, b)
1457
+ }, code:"AX_COLOR_01"};
1458
+ axs.AuditRule.specs.nonExistentAriaLabelledbyElement = {name:"nonExistentAriaLabelledbyElement", heading:"aria-labelledby attributes should refer to an element which exists in the DOM", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#-ax_aria_02--aria-labelledby-attributes-should-refer-to-an-element-which-exists-in-the-dom", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
1459
+ return a.querySelectorAll("[aria-labelledby]")
1460
+ }, test:function(a) {
1461
+ a = a.getAttribute("aria-labelledby").split(/\s+/);
1462
+ for(var b = 0;b < a.length;b++) {
1463
+ if(!document.getElementById(a[b])) {
1464
+ return!0
1465
+ }
1473
1466
  }
1474
- b.roles = f;
1475
- if(!f.valid || !f.roles) {
1476
- return b
1467
+ return!1
1468
+ }, code:"AX_ARIA_02"};
1469
+ axs.AuditRule.specs.requiredAriaAttributeMissing = {name:"requiredAriaAttributeMissing", heading:"Elements with ARIA roles must have all required attributes for that role", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#-ax_aria_03--elements-with-aria-roles-must-have-all-required-attributes-for-that-role", severity:axs.constants.Severity.SEVERE, relevantNodesSelector:function(a) {
1470
+ return a.querySelectorAll("[role]")
1471
+ }, test:function(a) {
1472
+ var b = axs.utils.getRoles(a);
1473
+ if(!b.valid) {
1474
+ return!1
1477
1475
  }
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"}))
1476
+ for(var c = 0;c < b.roles.length;c++) {
1477
+ var d = b.roles[c].details.requiredPropertiesSet, e;
1478
+ for(e in d) {
1479
+ if(d = e.replace(/^aria-/, ""), !("defaultValue" in axs.constants.ARIA_PROPERTIES[d]) && !a.hasAttribute(e)) {
1480
+ return!0
1483
1481
  }
1484
1482
  }
1485
1483
  }
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
1484
+ }, code:"AX_ARIA_03"};
1485
+ axs.AuditRule.specs.focusableElementNotVisibleAndNotAriaHidden = {name:"focusableElementNotVisibleAndNotAriaHidden", heading:"These elements are focusable but either invisible or obscured by another element", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#-ax_focus_01--these-elements-are-focusable-but-either-invisible-or-obscured-by-another-element", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
1486
+ return a.querySelectorAll(axs.utils.FOCUSABLE_ELEMENTS_SELECTOR)
1487
+ }, test:function(a) {
1488
+ return axs.utils.isElementOrAncestorHidden(a) ? !1 : !axs.utils.elementIsVisible(a)
1489
+ }, code:"AX_FOCUS_01"};
1490
+ axs.AuditRule.specs.elementsWithMeaningfulBackgroundImage = {name:"elementsWithMeaningfulBackgroundImage", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
1491
+ a = a.querySelectorAll("*");
1492
+ for(var b = [], c = 0;c < a.length;c++) {
1493
+ var d = a[c];
1494
+ axs.utils.isElementOrAncestorHidden(d) || b.push(d)
1502
1495
  }
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
1496
  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
1497
+ }, heading:"Meaningful images should not be used in element backgrounds", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#-ax_image_01--meaningful-images-should-not-be-used-in-element-backgrounds", test:function(a) {
1498
+ if(a.textContent && 0 < a.textContent.length) {
1499
+ return!1
1513
1500
  }
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)
1501
+ a = window.getComputedStyle(a, null);
1502
+ var b = a.backgroundImage;
1503
+ if(!b || "undefined" === b || "none" === b || 0 != b.indexOf("url")) {
1504
+ return!1
1524
1505
  }
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{}
1506
+ b = parseInt(a.width, 10);
1507
+ a = parseInt(a.height, 10);
1508
+ return 150 > b && 150 > a
1509
+ }, code:"AX_IMAGE_01"};
1510
+ 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) {
1511
+ return a.querySelectorAll("a")
1512
+ }, test:function(a) {
1513
+ return/^\s*click\s*here\s*[^a-z]?$/i.test(a.textContent)
1514
+ }, code:"AX_TITLE_01"};
1515
+ axs.AuditRule.specs.controlsWithoutLabel = {name:"controlsWithoutLabel", heading:"Controls and media elements should have labels", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#-ax_text_01--controls-and-media-elements-should-have-labels", severity:axs.constants.Severity.SEVERE, relevantNodesSelector:function(a) {
1516
+ return a.querySelectorAll('input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), video:not([disabled])')
1517
+ }, test:function(a) {
1518
+ return axs.utils.isElementOrAncestorHidden(a) || "input" == a.tagName.toLowerCase() && "button" == a.type && a.value.length || "button" == a.tagName.toLowerCase() && a.textContent.replace(/^\s+|\s+$/g, "").length ? !1 : !axs.utils.hasLabel(a) ? !0 : !1
1519
+ }, code:"AX_TEXT_01", ruleName:"Controls and media elements should have labels"};
1520
+ axs.AuditRule.specs.videoWithoutCaptions = {name:"videoWithoutCaptions", heading:"Video elements should use <track> elements to provide captions", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#-ax_video_01--video-elements-should-use-track-elements-to-provide-captions", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
1521
+ return a.querySelectorAll("video")
1522
+ }, test:function(a) {
1523
+ return!a.querySelectorAll("track[kind=captions]").length
1524
+ }, code:"AX_VIDEO_01"};
1525
+ axs.AuditRule.specs.badAriaAttributeValue = {name:"badAriaAttributeValue", heading:"ARIA state and property values must be valid", url:"", severity:axs.constants.Severity.SEVERE, relevantNodesSelector:function(a) {
1526
+ var b = "", c;
1527
+ for(c in axs.constants.ARIA_PROPERTIES) {
1528
+ b += "[aria-" + c + "],"
1532
1529
  }
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]")
1530
+ b = b.substring(0, b.length - 1);
1531
+ return a.querySelectorAll(b)
1543
1532
  }, test:function(a) {
1544
- return axs.utils.isInlineElement(a) || 50 > axs.properties.findTextAlternatives(a, {}).length ? !0 : !1
1533
+ for(var b in axs.constants.ARIA_PROPERTIES) {
1534
+ var c = "aria-" + b;
1535
+ if(a.hasAttribute(c)) {
1536
+ var d = a.getAttribute(c);
1537
+ if(!axs.utils.getAriaPropertyValue(c, d, a).valid) {
1538
+ return!0
1539
+ }
1540
+ }
1541
+ }
1542
+ return!1
1545
1543
  }, code:"AX_ARIA_04"};
1544
+ axs.AuditRule.specs.badAriaRole = {name:"badAriaRole", heading:"Elements with ARIA roles must use a valid, non-abstract ARIA role", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#-ax_aria_01--elements-with-aria-roles-must-use-a-valid-non-abstract-aria-role", severity:axs.constants.Severity.SEVERE, relevantNodesSelector:function(a) {
1545
+ return a.querySelectorAll("[role]")
1546
+ }, test:function(a) {
1547
+ return!axs.utils.getRoles(a).valid
1548
+ }, code:"AX_ARIA_01"};
1549
+ axs.AuditRule.specs.imagesWithoutAltText = {name:"imagesWithoutAltText", heading:"Images should have an alt attribute", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#-ax_text_02--images-should-have-an-alt-attribute-unless-they-have-an-aria-role-of-presentation", severity:axs.constants.Severity.WARNING, relevantNodesSelector:function(a) {
1550
+ a = a.querySelectorAll("img");
1551
+ for(var b = [], c = 0;c < a.length;c++) {
1552
+ var d = a[c];
1553
+ axs.utils.isElementOrAncestorHidden(d) || b.push(d)
1554
+ }
1555
+ return b
1556
+ }, test:function(a) {
1557
+ return!a.hasAttribute("alt") && "presentation" != a.getAttribute("role")
1558
+ }, code:"AX_TEXT_02"};
1559
+ axs.AuditRule.specs.unfocusableElementsWithOnClick = {name:"unfocusableElementsWithOnClick", heading:"Elements with onclick handlers must be focusable", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#-ax_focus_02--elements-with-onclick-handlers-must-be-focusable", severity:axs.constants.Severity.WARNING, opt_requiresConsoleAPI:!0, relevantNodesSelector:function(a) {
1560
+ a = a.querySelectorAll("*");
1561
+ for(var b = [], c = 0;c < a.length;c++) {
1562
+ var d = a[c];
1563
+ d instanceof d.ownerDocument.defaultView.HTMLBodyElement || axs.utils.isElementOrAncestorHidden(d) || "click" in getEventListeners(d) && b.push(d)
1564
+ }
1565
+ return b
1566
+ }, test:function(a) {
1567
+ return!a.hasAttribute("tabindex") && !axs.utils.isElementImplicitlyFocusable(a)
1568
+ }, code:"AX_FOCUS_02"};
1546
1569