diff options
author | apacible <apacible@chromium.org> | 2015-11-25 18:16:38 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-26 02:18:04 +0000 |
commit | 12fdc0a6860f25e24cca86250e8b9d0f17f3cc47 (patch) | |
tree | 3eacf375ea0b1a4f76d2537f6abe8c178e8541ca | |
parent | 5592f3cdc930a676c72f78e290011e28792abe21 (diff) | |
download | chromium_src-12fdc0a6860f25e24cca86250e8b9d0f17f3cc47.zip chromium_src-12fdc0a6860f25e24cca86250e8b9d0f17f3cc47.tar.gz chromium_src-12fdc0a6860f25e24cca86250e8b9d0f17f3cc47.tar.bz2 |
[a11y] Bring accessibility-audit up to date: v2.10.0 release.
This change pulls in the latest a11y devtools release.
With the update of third_party/accessibility_audit to release v2.10.0, a number of browser tests had accessibility audit failures and warnings. These are all disabled/ignored and bugs filed for each set of audit failures.
The accessibility audit repository can be found at: https://github.com/GoogleChrome/accessibility-developer-tools
TBR=sky@chromium.org
BUG=555753
Review URL: https://codereview.chromium.org/1447693002
Cr-Commit-Position: refs/heads/master@{#361792}
16 files changed, 1336 insertions, 476 deletions
diff --git a/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc b/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc index 8560489..81afc7f 100644 --- a/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc +++ b/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc @@ -20,7 +20,11 @@ class BookmarksTest : public InProcessBrowserTest { void SetUpOnMainThread() override { InProcessBrowserTest::SetUpOnMainThread(); - EnableAccessibilityChecksForTestCase(true); + + // Re-enable accessibility checks when audit failures are resolved. + // AX_TEXT_01: http://crbug.com/559201 + // AX_ARIA_08: http://crbug.com/559202 + // EnableAccessibilityChecksForTestCase(true); } void OpenBookmarksManager() { diff --git a/chrome/browser/ui/webui/downloads_ui_browsertest.js b/chrome/browser/ui/webui/downloads_ui_browsertest.js index 89fc311..8ffba04 100644 --- a/chrome/browser/ui/webui/downloads_ui_browsertest.js +++ b/chrome/browser/ui/webui/downloads_ui_browsertest.js @@ -120,6 +120,8 @@ EmptyDownloadsWebUITest.prototype = { setUp: function() { // Doesn't create any fake downloads. assertEquals(0, downloads.Manager.size()); + + this.updateAccessibilityAuditConfig(); }, }; diff --git a/chrome/browser/ui/webui/downloads_ui_browsertest_base.js b/chrome/browser/ui/webui/downloads_ui_browsertest_base.js index 4af9e7e..24ec279 100644 --- a/chrome/browser/ui/webui/downloads_ui_browsertest_base.js +++ b/chrome/browser/ui/webui/downloads_ui_browsertest_base.js @@ -47,6 +47,8 @@ BaseDownloadsWebUITest.prototype = { * @override */ setUp: function() { + testing.Test.prototype.setUp.call(this); + this.createdDownloads = []; // The entries will begin at 1:00 AM on Sept 2, 2008, and will be spaced @@ -58,6 +60,26 @@ BaseDownloadsWebUITest.prototype = { } downloads.Manager.updateAll(this.createdDownloads); expectEquals(downloads.Manager.size(), TOTAL_RESULT_COUNT); + + this.updateAccessibilityAuditConfig(); + }, + + /** + * Disables failing accessibility audits. This should be removed when all + * audit issues have been resolved. + */ + updateAccessibilityAuditConfig: function() { + // Enable when failure is resolved. + // AX_TEXT_01: http://crbug.com/559217 + this.accessibilityAuditConfig.ignoreSelectors( + 'controlsWithoutLabel', + '#term'); + + // Enable when failure is resolved. + // AX_FOCUS_03: http://crbug.com/559219 + this.accessibilityAuditConfig.ignoreSelectors( + 'tabIndexGreaterThanZero', + '#term'); }, /** diff --git a/chrome/browser/ui/webui/extensions/extension_settings_browsertest.js b/chrome/browser/ui/webui/extensions/extension_settings_browsertest.js index d7847ef..1aca91b 100644 --- a/chrome/browser/ui/webui/extensions/extension_settings_browsertest.js +++ b/chrome/browser/ui/webui/extensions/extension_settings_browsertest.js @@ -51,7 +51,14 @@ ExtensionSettingsWebUITest.prototype = { /** @override */ setUp: function() { + testing.Test.prototype.setUp.call(this); testing.Test.disableAnimationsAndTransitions(); + + // Enable when failure is resolved. + // AX_ARIA_08: http://crbug.com/560903 + this.accessibilityAuditConfig.ignoreSelectors( + 'requiredOwnedAriaRoleMissing', + '#kiosk-app-list'); }, /** diff --git a/chrome/browser/ui/webui/options/language_options_browsertest.js b/chrome/browser/ui/webui/options/language_options_browsertest.js index fc5ffba..bfd3acb 100644 --- a/chrome/browser/ui/webui/options/language_options_browsertest.js +++ b/chrome/browser/ui/webui/options/language_options_browsertest.js @@ -16,6 +16,23 @@ LanguageOptionsWebUITest.prototype = { /** @override */ browsePreload: 'chrome://settings-frame/languages', + + /** @override */ + setUp: function() { + OptionsBrowsertestBase.prototype.setUp.call(this); + + // Enable when failure is resolved. + // AX_ARIA_10: http://crbug.com/559266 + this.accessibilityAuditConfig.ignoreSelectors( + 'unsupportedAriaAttribute', + '#language-options-list'); + + // Enable when failure is resolved. + // AX_TEXT_04: http://crbug.com/559271 + this.accessibilityAuditConfig.ignoreSelectors( + 'linkWithUnclearPurpose', + '#languagePage > .content-area > .language-options-header > A'); + } }; // Test opening language options has correct location. diff --git a/chrome/browser/ui/webui/options/multilanguage_options_webui_browsertest.js b/chrome/browser/ui/webui/options/multilanguage_options_webui_browsertest.js index 56419fa..deeff84 100644 --- a/chrome/browser/ui/webui/options/multilanguage_options_webui_browsertest.js +++ b/chrome/browser/ui/webui/options/multilanguage_options_webui_browsertest.js @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +GEN_INCLUDE(['options_browsertest_base.js']); GEN('#include "chrome/browser/ui/webui/options/' + 'multilanguage_options_browsertest.h"'); @@ -13,7 +14,7 @@ GEN('#include "chrome/browser/ui/webui/options/' + function MultilanguageOptionsWebUIBrowserTest() {} MultilanguageOptionsWebUIBrowserTest.prototype = { - __proto__: testing.Test.prototype, + __proto__: OptionsBrowsertestBase.prototype, /** @override */ browsePreload: 'chrome://settings-frame/languages', @@ -32,7 +33,7 @@ MultilanguageOptionsWebUIBrowserTest.prototype = { /** @override */ setUp: function() { - testing.Test.prototype.setUp.call(this); + OptionsBrowsertestBase.prototype.setUp.call(this); assertTrue(loadTimeData.getBoolean('enableMultilingualSpellChecker')); assertFalse(cr.isMac); @@ -40,6 +41,29 @@ MultilanguageOptionsWebUIBrowserTest.prototype = { expectFalse($('edit-custom-dictionary-button').hidden); this.expectEnableSpellcheckCheckboxHidden(); this.expectCurrentlySelected('fr'); + + var requiredOwnedAriaRoleMissingSelectors = [ + '#default-search-engine-list', + '#other-search-engine-list', + ]; + + // Enable when failure is resolved. + // AX_ARIA_08: http://crbug.com/559320 + this.accessibilityAuditConfig.ignoreSelectors( + 'requiredOwnedAriaRoleMissing', + requiredOwnedAriaRoleMissingSelectors); + + // Enable when failure is resolved. + // AX_ARIA_10: http://crbug.com/559266 + this.accessibilityAuditConfig.ignoreSelectors( + 'unsupportedAriaAttribute', + '#language-options-list'); + + // Enable when failure is resolved. + // AX_TEXT_04: http://crbug.com/559271 + this.accessibilityAuditConfig.ignoreSelectors( + 'linkWithUnclearPurpose', + '#languagePage > .content-area > .language-options-header > A'); }, /** @override */ @@ -140,7 +164,7 @@ MultilanguagePreferenceWebUIBrowserTest.prototype = { /** @override */ setUp: function() { - testing.Test.prototype.setUp.call(this); + OptionsBrowsertestBase.prototype.setUp.call(this); assertTrue(loadTimeData.getBoolean('enableMultilingualSpellChecker')); assertFalse(cr.isMac); @@ -149,6 +173,18 @@ MultilanguagePreferenceWebUIBrowserTest.prototype = { this.expectEnableSpellcheckCheckboxHidden(); this.expectCurrentlySelected(''); this.expectRegisteredDictionariesPref(''); + + // Enable when failure is resolved. + // AX_ARIA_10: http://crbug.com/559266 + this.accessibilityAuditConfig.ignoreSelectors( + 'unsupportedAriaAttribute', + '#language-options-list'); + + // Enable when failure is resolved. + // AX_TEXT_04: http://crbug.com/559271 + this.accessibilityAuditConfig.ignoreSelectors( + 'linkWithUnclearPurpose', + '#languagePage > .content-area > .language-options-header > A'); }, }; diff --git a/chrome/browser/ui/webui/options/options_browsertest.js b/chrome/browser/ui/webui/options/options_browsertest.js index 895928a..4de8c19 100644 --- a/chrome/browser/ui/webui/options/options_browsertest.js +++ b/chrome/browser/ui/webui/options/options_browsertest.js @@ -79,6 +79,31 @@ OptionsWebUITest.prototype = { this.mockHandler.stubs().observePrefs(ANYTHING); this.mockHandler.stubs().coreOptionsUserMetricsAction(ANYTHING); }, + + /** @override */ + setUp: function() { + OptionsBrowsertestBase.prototype.setUp.call(this); + + // Enable when failure is resolved. + // AX_ARIA_10: http://crbug.com/559329 + this.accessibilityAuditConfig.ignoreSelectors( + 'unsupportedAriaAttribute', + '#profiles-list'); + + var linkWithUnclearPurposeSelectors = [ + '#sync-overview > A', + '#privacy-explanation > A', + '#languages-section > .settings-row > A', + '#cloudprint-options-mdns > .settings-row > A', + '#do-not-track-confirm-overlay > .action-area > .hbox.stretch > A', + ]; + + // Enable when failure is resolved. + // AX_TEXT_04: http://crbug.com/559318 + this.accessibilityAuditConfig.ignoreSelectors( + 'linkWithUnclearPurpose', + linkWithUnclearPurposeSelectors); + }, }; /** @@ -378,6 +403,44 @@ OptionsWebUIExtendedTest.prototype = { /** @override */ typedefCppFixture: 'OptionsBrowserTest', + /** @override */ + setUp: function() { + OptionsWebUITest.prototype.setUp.call(this); + + // Enable when failure is resolved. + // AX_ARIA_10: http://crbug.com/559329 + this.accessibilityAuditConfig.ignoreSelectors( + 'unsupportedAriaAttribute', + '#profiles-list'); + + var controlsWithoutLabelSelectors = [ + '#cookies-view-page > .content-area.cookies-list-content-area > *', + '#other-search-engine-list > .deletable-item > DIV > *', + ]; + + // Enable when failure is resolved. + // AX_TEXT_01: http://crbug.com/559330 + this.accessibilityAuditConfig.ignoreSelectors( + 'controlsWithoutLabel', + controlsWithoutLabelSelectors); + + var linkWithUnclearPurposeSelectors = [ + '#sync-overview > A', + '#privacy-explanation > A', + '#languages-section > .settings-row > A', + '#cloudprint-options-mdns > .settings-row > A', + // Selectors below only affect ChromeOS tests. + '#privacy-section > DIV > DIV:nth-of-type(9) > A', + '#accessibility-learn-more', + ]; + + // Enable when failure is resolved. + // AX_TEXT_04: http://crbug.com/559326 + this.accessibilityAuditConfig.ignoreSelectors( + 'linkWithUnclearPurpose', + linkWithUnclearPurposeSelectors); + }, + testGenPreamble: function() { // Start with no supervised users managed by this profile. GEN(' ClearPref("' + SUPERVISED_USERS_PREF + '");'); diff --git a/chrome/browser/ui/webui/options/options_browsertest_base.js b/chrome/browser/ui/webui/options/options_browsertest_base.js index 1483ba3..e298ea1 100644 --- a/chrome/browser/ui/webui/options/options_browsertest_base.js +++ b/chrome/browser/ui/webui/options/options_browsertest_base.js @@ -16,4 +16,54 @@ OptionsBrowsertestBase.prototype = { /** @override */ accessibilityIssuesAreErrors: true, + + /** @override */ + setUp: function() { + testing.Test.prototype.setUp.call(this); + + var requiredOwnedAriaRoleMissingSelectors = [ + '#address-list', + '#creditcard-list', + '#home-page-overlay > .autocomplete-suggestions', + '#language-options-list', + '#manage-profile-icon-grid', + '#create-profile-icon-grid', + '#saved-passwords-list', + '#password-exceptions-list', + '#extension-keyword-list', + '#startup-overlay > .autocomplete-suggestions', + '#content-settings-exceptions-area > .content-area > *', + '#cookies-list', + '#handlers-list', + '#ignored-handlers-list', + '#supervised-user-list', + '#select-avatar-grid', + '#language-dictionary-overlay-word-list', + // Selectors below only affect ChromeOS tests. + '#bluetooth-unpaired-devices-list', + '#ignored-host-list', + '#remembered-network-list', + '#bluetooth-paired-devices-list', + ]; + + // Enable when failure is resolved. + // AX_ARIA_08: http://crbug.com/559265 + this.accessibilityAuditConfig.ignoreSelectors( + 'requiredOwnedAriaRoleMissing', + requiredOwnedAriaRoleMissingSelectors); + + var tabIndexGreaterThanZeroSelectors = [ + '#user-image-grid', + '#discard-photo', + '#take-photo', + '#flip-photo', + '#change-picture-overlay-confirm', + ]; + + // Enable when failure is resolved. + // AX_FOCUS_03: http://crbug.com/560910 + this.accessibilityAuditConfig.ignoreSelectors( + 'tabIndexGreaterThanZero', + tabIndexGreaterThanZeroSelectors); + }, }; diff --git a/chrome/test/data/chromeos/oobe_webui_browsertest.js b/chrome/test/data/chromeos/oobe_webui_browsertest.js index e2c4ce5..c14bff6 100644 --- a/chrome/test/data/chromeos/oobe_webui_browsertest.js +++ b/chrome/test/data/chromeos/oobe_webui_browsertest.js @@ -57,6 +57,62 @@ OobeWebUITest.prototype = { this.accessibilityAuditConfig.ignoreSelectors( 'focusableElementNotVisibleAndNotAriaHidden', '#iconButton'); + + // Enable when failure is resolved. + // AX_ARIA_02: http://crbug.com/560932 + this.accessibilityAuditConfig.ignoreSelectors( + 'nonExistentAriaRelatedElement', + '#cancelConfirmDlg'); + + var requiredOwnedAriaRoleMissingSelectors = [ + '#networks-list-dropdown-container', + '#offline-networks-list-dropdown-container', + '#supervised-user-creation-image-grid', + 'body > .decorated', + ]; + + // Enable when failure is resolved. + // AX_ARIA_08: http://crbug.com/560924 + this.accessibilityAuditConfig.ignoreSelectors( + 'requiredOwnedAriaRoleMissing', + requiredOwnedAriaRoleMissingSelectors); + + var badAriaAttributeSelectors = [ + '#forgotPasswordDlg', + '#cancelConfirmDlg', + ]; + + // Enable when failure is resolved. + // AX_ARIA_11: http://crbug.com/560935 + this.accessibilityAuditConfig.ignoreSelectors( + 'badAriaAttribute', + badAriaAttributeSelectors); + + var tabIndexGreaterThanZeroSelectors = [ + '#user-image-grid', + '#discard-photo', + '#take-photo', + '#flip-photo', + ]; + + // Enable when failure is resolved. + // AX_FOCUS_03: http://crbug.com/560928 + this.accessibilityAuditConfig.ignoreSelectors( + 'tabIndexGreaterThanZero', + tabIndexGreaterThanZeroSelectors); + + var controlsWithoutLabelSelectors = [ + '#supervised-user-creation-managers-pane', + '#supervised-user-creation-name', + '#supervised-user-creation-password', + '#supervised-user-creation-password-confirm', + ]; + + // Enable when failure is resolved. + // AX_TEXT_01: http://crbug.com/560939 + this.accessibilityAuditConfig.ignoreSelectors( + 'controlsWithoutLabel', + controlsWithoutLabelSelectors); }, }; diff --git a/chrome/test/data/webui/history_browsertest.js b/chrome/test/data/webui/history_browsertest.js index d8792ea..d49ee8b 100644 --- a/chrome/test/data/webui/history_browsertest.js +++ b/chrome/test/data/webui/history_browsertest.js @@ -775,6 +775,17 @@ HistoryWebUIRealBackendTest.prototype = { // Add a visit on the next day. GEN(' AddPageToHistory(36, "http://google.com", "Google");'); }, + + /** @override */ + setUp: function() { + BaseHistoryWebUITest.prototype.setUp.call(this); + + // Enable when failure is resolved. + // AX_TEXT_04: http://crbug.com/560914 + this.accessibilityAuditConfig.ignoreSelectors( + 'linkWithUnclearPurpose', + '#notification-bar > A'); + }, }; /** diff --git a/chrome/test/data/webui/net_internals/net_internals_test.js b/chrome/test/data/webui/net_internals/net_internals_test.js index 56bc93f..b381ec8 100644 --- a/chrome/test/data/webui/net_internals/net_internals_test.js +++ b/chrome/test/data/webui/net_internals/net_internals_test.js @@ -56,6 +56,8 @@ var NetInternalsTest = (function() { isAsync: true, setUp: function() { + testing.Test.prototype.setUp.call(this); + // Enforce accessibility auditing, but suppress some false positives. this.accessibilityIssuesAreErrors = true; // False positive because a unicode character is used to draw a square. @@ -79,6 +81,25 @@ var NetInternalsTest = (function() { this.accessibilityAuditConfig.auditRulesToIgnore.push( 'focusableElementNotVisibleAndNotAriaHidden'); + var controlsWithoutLabelSelectors = [ + '#export-view-user-comments', + '#hsts-view-add-input', + '#hsts-view-delete-input', + '#hsts-view-query-input', + ]; + + // Enable when failure is resolved. + // AX_TEXT_01: http://crbug.com/559203 + this.accessibilityAuditConfig.ignoreSelectors( + 'controlsWithoutLabel', + controlsWithoutLabelSelectors); + + // Enable when warning is resolved. + // AX_HTML_01: http://crbug.com/559204 + this.accessibilityAuditConfig.ignoreSelectors( + 'humanLangMissing', + 'html'); + // Wrap g_browser.receive around a test function so that assert and expect // functions can be called from observers. g_browser.receive = diff --git a/chrome/test/data/webui/print_preview.js b/chrome/test/data/webui/print_preview.js index 2ef9260..7d84ef9 100644 --- a/chrome/test/data/webui/print_preview.js +++ b/chrome/test/data/webui/print_preview.js @@ -166,6 +166,7 @@ PrintPreviewWebUITest.prototype = { * @override */ setUp: function() { + testing.Test.prototype.setUp.call(this); Mock4JS.clearMocksToVerify(); this.initialSettings_ = new print_preview.NativeInitialSettings( @@ -189,6 +190,12 @@ PrintPreviewWebUITest.prototype = { this.nativeLayer_ = printPreview.nativeLayer_; testing.Test.disableAnimationsAndTransitions(); + + // Enable when failure is resolved. + // AX_TEXT_03: http://crbug.com/559209 + this.accessibilityAuditConfig.ignoreSelectors( + 'multipleLabelableElementsPerLabel', + '#page-settings > .right-column > *'); } }; diff --git a/chrome/test/data/webui/test_api.js b/chrome/test/data/webui/test_api.js index 4c2243e..248929b 100644 --- a/chrome/test/data/webui/test_api.js +++ b/chrome/test/data/webui/test_api.js @@ -168,15 +168,10 @@ var testing = {}; /** * Returns the configuration for the accessibility audit, creating it * on-demand. - * @return {axs.AuditConfiguration} + * @return {!axs.AuditConfiguration} */ get accessibilityAuditConfig() { - // The axs namespace is not available in chromevox tests. - // Further, 'window' is not available in unit tests, but since the - // accessibility audit library pulls in the closure library, - // 'goog.global' has to be present if axs is, so we use that here. - if (!this.accessibilityAuditConfig_ && - goog && goog.global && goog.global.axs) { + if (!this.accessibilityAuditConfig_) { this.accessibilityAuditConfig_ = new axs.AuditConfiguration(); this.accessibilityAuditConfig_.showUnsupportedRulesWarning = false; @@ -196,6 +191,10 @@ var testing = {}; // TODO(aboxhall): re-enable when crbug.com/267035 is fixed. // Until then it's just noise. "lowContrastElements", + + // TODO(apacible): re-enable when following issue is fixed. + // github.com/GoogleChrome/accessibility-developer-tools/issues/251 + "tableHasAppropriateHeaders", ]; } return this.accessibilityAuditConfig_; @@ -307,17 +306,14 @@ var testing = {}; * @type {Function} */ setUp: function() { - var auditConfig = this.accessibilityAuditConfig; - if (auditConfig) { - // These should be ignored in many of the web UI tests. - // user-image-stream and supervised-user-creation-image-stream are - // streaming video elements used for capturing a user image so they - // won't have captions and should be ignored everywhere. - auditConfig.ignoreSelectors('videoWithoutCaptions', - '.user-image-stream'); - auditConfig.ignoreSelectors( - 'videoWithoutCaptions', '.supervised-user-creation-image-stream'); - } + // These should be ignored in many of the web UI tests. + // user-image-stream and supervised-user-creation-image-stream are + // streaming video elements used for capturing a user image so they + // won't have captions and should be ignored everywhere. + this.accessibilityAuditConfig.ignoreSelectors('videoWithoutCaptions', + '.user-image-stream'); + this.accessibilityAuditConfig.ignoreSelectors( + 'videoWithoutCaptions', '.supervised-user-creation-image-stream'); }, /** diff --git a/third_party/accessibility-audit/OWNERS b/third_party/accessibility-audit/OWNERS new file mode 100644 index 0000000..cd795ab --- /dev/null +++ b/third_party/accessibility-audit/OWNERS @@ -0,0 +1 @@ +aboxhall@chromium.org
\ No newline at end of file diff --git a/third_party/accessibility-audit/README.chromium b/third_party/accessibility-audit/README.chromium index 8df3389..6cf4986 100644 --- a/third_party/accessibility-audit/README.chromium +++ b/third_party/accessibility-audit/README.chromium @@ -2,7 +2,7 @@ Name: Accessibility Audit library, from Accessibility Developer Tools Short Name: accessibility-audit URL: https://raw.githubusercontent.com/GoogleChrome/accessibility-developer-tools/master/dist/js/axs_testing.js Version: 0 -Revision: 3d4893b4ecd0eb8f4765e04479213d04b240f3e0 +Revision: 404ede0f2186682fbbef624141e76ec2b601317d License: Apache 2.0 License File: LICENSE Security Critical: no diff --git a/third_party/accessibility-audit/axs_testing.js b/third_party/accessibility-audit/axs_testing.js index f0e6f4a..f075a05 100644 --- a/third_party/accessibility-audit/axs_testing.js +++ b/third_party/accessibility-audit/axs_testing.js @@ -1,5 +1,5 @@ /* - * Copyright 2014 Google Inc. + * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * Generated from http://github.com/GoogleChrome/accessibility-developer-tools/tree/3d4893b4ecd0eb8f4765e04479213d04b240f3e0 + * Generated from http://github.com/GoogleChrome/accessibility-developer-tools/tree/404ede0f2186682fbbef624141e76ec2b601317d * * See project README for build steps. */ - + // AUTO-GENERATED CONTENT BELOW: DO NOT EDIT! See above for details. -var COMPILED = !0, goog = goog || {}; +var fn = (function() { + var COMPILED = !0, goog = goog || {}; goog.global = this; goog.isDef = function(a) { return void 0 !== a; @@ -62,7 +63,7 @@ goog.setTestOnly = function(a) { goog.forwardDeclare = function(a) { }; COMPILED || (goog.isProvided_ = function(a) { - return!goog.implicitNamespaces_[a] && goog.isDefAndNotNull(goog.getObjectByName(a)); + return !goog.implicitNamespaces_[a] && goog.isDefAndNotNull(goog.getObjectByName(a)); }, goog.implicitNamespaces_ = {}); goog.getObjectByName = function(a, b) { for (var c = a.split("."), d = b || goog.global, e;e = c.shift();) { @@ -153,14 +154,14 @@ goog.DEPENDENCIES_ENABLED && (goog.included_ = {}, goog.dependencies_ = {pathToN var b = goog.global.document; if ("complete" == b.readyState) { if (/\bdeps.js$/.test(a)) { - return!1; + return !1; } throw Error('Cannot write "' + a + '" after document load'); } b.write('<script type="text/javascript" src="' + a + '">\x3c/script>'); - return!0; + return !0; } - return!1; + return !1; }, goog.writeScripts_ = function() { function a(e) { if (!(e in d.written)) { @@ -258,7 +259,7 @@ goog.getUid = function(a) { return a[goog.UID_PROPERTY_] || (a[goog.UID_PROPERTY_] = ++goog.uidCounter_); }; goog.hasUid = function(a) { - return!!a[goog.UID_PROPERTY_]; + return !!a[goog.UID_PROPERTY_]; }; goog.removeUid = function(a) { "removeAttribute" in a && a.removeAttribute(goog.UID_PROPERTY_); @@ -322,7 +323,7 @@ goog.mixin = function(a, b) { } }; goog.now = goog.TRUSTED_SITE && Date.now || function() { - return+new Date; + return +new Date; }; goog.globalEval = function(a) { if (goog.global.execScript) { @@ -421,24 +422,24 @@ goog.scope = function(a) { var axs = {}; axs.browserUtils = {}; axs.browserUtils.matchSelector = function(a, b) { - return a.webkitMatchesSelector ? a.webkitMatchesSelector(b) : a.mozMatchesSelector ? a.mozMatchesSelector(b) : !1; + return a.matches ? a.matches(b) : a.webkitMatchesSelector ? a.webkitMatchesSelector(b) : a.mozMatchesSelector ? a.mozMatchesSelector(b) : a.msMatchesSelector ? a.msMatchesSelector(b) : !1; }; 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"], +"author"], namerequired:!0, parent:["input"], requiredProperties:["aria-checked"], properties:["aria-checked"]}, columnheader:{namefrom:["contents", "author"], namerequired:!0, parent:["gridcell", "sectionhead", "widget"], properties:["aria-sort"], scope:["row"]}, 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"], -properties:["aria-expanded"]}, form:{namefrom:["author"], parent:["landmark"]}, grid:{mustcontain:["row", "rowgroup"], namefrom:["author"], namerequired:!0, parent:["composite", "region"], properties:["aria-level", "aria-multiselectable", "aria-readonly"]}, gridcell:{namefrom:["contents", "author"], namerequired:!0, parent:["section", "widget"], properties:["aria-readonly", "aria-required", "aria-selected"]}, group:{namefrom:[" author"], parent:["section"], properties:["aria-activedescendant"]}, +properties:["aria-expanded"]}, form:{namefrom:["author"], parent:["landmark"]}, grid:{mustcontain:["row", "rowgroup"], namefrom:["author"], namerequired:!0, parent:["composite", "region"], properties:["aria-level", "aria-multiselectable", "aria-readonly"]}, gridcell:{namefrom:["contents", "author"], namerequired:!0, parent:["section", "widget"], properties:["aria-readonly", "aria-required", "aria-selected"], scope:["row"]}, group:{namefrom:[" author"], parent:["section"], properties:["aria-activedescendant"]}, heading:{namerequired:!0, parent:["sectionhead"], properties:["aria-level"]}, img:{childpresentational:!0, namefrom:["author"], namerequired:!0, parent:["section"]}, input:{"abstract":!0, namefrom:["author"], parent:["widget"]}, landmark:{"abstract":!0, namefrom:["contents", "author"], namerequired:!1, parent:["region"]}, link:{namefrom:["contents", "author"], namerequired:!0, parent:["command"], properties:["aria-expanded"]}, list:{mustcontain:["group", "listitem"], namefrom:["author"], parent:["region"]}, -listbox:{mustcontain:["option"], namefrom:["author"], namerequired:!0, parent:["list", "select"], properties:["aria-multiselectable", "aria-required"]}, listitem:{namefrom:["contents", "author"], namerequired:!0, parent:["section"], properties:["aria-level", "aria-posinset", "aria-setsize"]}, log:{namefrom:[" author"], namerequired:!0, parent:["region"]}, main:{namefrom:["author"], parent:["landmark"]}, marquee:{namerequired:!0, parent:["section"]}, math:{childpresentational:!0, namefrom:["author"], -parent:["section"]}, menu:{mustcontain:["group", "menuitemradio", "menuitem", "menuitemcheckbox"], namefrom:["author"], namerequired:!0, parent:["list", "select"]}, menubar:{namefrom:["author"], parent:["menu"]}, menuitem:{namefrom:["contents", "author"], namerequired:!0, parent:["command"]}, menuitemcheckbox:{namefrom:["contents", "author"], namerequired:!0, parent:["checkbox", "menuitem"]}, menuitemradio:{namefrom:["contents", "author"], namerequired:!0, parent:["menuitemcheckbox", "radio"]}, navigation:{namefrom:["author"], -parent:["landmark"]}, note:{namefrom:["author"], parent:["section"]}, option:{namefrom:["contents", "author"], namerequired:!0, parent:["input"], properties:["aria-checked", "aria-posinset", "aria-selected", "aria-setsize"]}, presentation:{parent:["structure"]}, progressbar:{childpresentational:!0, namefrom:["author"], namerequired:!0, parent:["range"]}, radio:{namefrom:["contents", "author"], namerequired:!0, parent:["checkbox", "option"]}, radiogroup:{mustcontain:["radio"], namefrom:["author"], -namerequired:!0, parent:["select"], properties:["aria-required"]}, range:{"abstract":!0, namefrom:["author"], parent:["widget"], properties:["aria-valuemax", "aria-valuemin", "aria-valuenow", "aria-valuetext"]}, region:{namefrom:[" author"], parent:["section"]}, roletype:{"abstract":!0, properties:"aria-atomic aria-busy aria-controls aria-describedby aria-disabled aria-dropeffect aria-flowto aria-grabbed aria-haspopup aria-hidden aria-invalid aria-label aria-labelledby aria-live aria-owns aria-relevant".split(" ")}, -row:{mustcontain:["columnheader", "gridcell", "rowheader"], namefrom:["contents", "author"], parent:["group", "widget"], properties:["aria-level", "aria-selected"]}, rowgroup:{mustcontain:["row"], namefrom:["contents", "author"], parent:["group"]}, rowheader:{namefrom:["contents", "author"], namerequired:!0, parent:["gridcell", "sectionhead", "widget"], properties:["aria-sort"]}, search:{namefrom:["author"], parent:["landmark"]}, section:{"abstract":!0, namefrom:["contents", "author"], parent:["structure"], -properties:["aria-expanded"]}, sectionhead:{"abstract":!0, namefrom:["contents", "author"], parent:["structure"], properties:["aria-expanded"]}, select:{"abstract":!0, namefrom:["author"], parent:["composite", "group", "input"]}, separator:{childpresentational:!0, namefrom:["author"], parent:["structure"], properties:["aria-expanded", "aria-orientation"]}, scrollbar:{childpresentational:!0, namefrom:["author"], namerequired:!1, parent:["input", "range"], requiredProperties:["aria-controls", "aria-orientation", -"aria-valuemax", "aria-valuemin", "aria-valuenow"], properties:["aria-controls", "aria-orientation", "aria-valuemax", "aria-valuemin", "aria-valuenow"]}, slider:{childpresentational:!0, namefrom:["author"], namerequired:!0, parent:["input", "range"], requiredProperties:["aria-valuemax", "aria-valuemin", "aria-valuenow"], properties:["aria-valuemax", "aria-valuemin", "aria-valuenow", "aria-orientation"]}, spinbutton:{namefrom:["author"], namerequired:!0, parent:["input", "range"], requiredProperties:["aria-valuemax", -"aria-valuemin", "aria-valuenow"], properties:["aria-valuemax", "aria-valuemin", "aria-valuenow", "aria-required"]}, status:{parent:["region"]}, structure:{"abstract":!0, parent:["roletype"]}, tab:{namefrom:["contents", "author"], parent:["sectionhead", "widget"], properties:["aria-selected"]}, tablist:{mustcontain:["tab"], namefrom:["author"], parent:["composite", "directory"], properties:["aria-level"]}, tabpanel:{namefrom:["author"], namerequired:!0, parent:["region"]}, textbox:{namefrom:["author"], -namerequired:!0, parent:["input"], properties:["aria-activedescendant", "aria-autocomplete", "aria-multiline", "aria-readonly", "aria-required"]}, timer:{namefrom:["author"], namerequired:!0, parent:["status"]}, toolbar:{namefrom:["author"], parent:["group"]}, tooltip:{namerequired:!0, parent:["section"]}, tree:{mustcontain:["group", "treeitem"], namefrom:["author"], namerequired:!0, parent:["select"], properties:["aria-multiselectable", "aria-required"]}, treegrid:{mustcontain:["row"], namefrom:["author"], -namerequired:!0, parent:["grid", "tree"]}, treeitem:{namefrom:["contents", "author"], namerequired:!0, parent:["listitem", "option"]}, widget:{"abstract":!0, parent:["roletype"]}, window:{"abstract":!0, namefrom:[" author"], parent:["roletype"], properties:["aria-expanded"]}}; +listbox:{mustcontain:["option"], namefrom:["author"], namerequired:!0, parent:["list", "select"], properties:["aria-multiselectable", "aria-required"]}, listitem:{namefrom:["contents", "author"], namerequired:!0, parent:["section"], properties:["aria-level", "aria-posinset", "aria-setsize"], scope:["list"]}, log:{namefrom:[" author"], namerequired:!0, parent:["region"]}, main:{namefrom:["author"], parent:["landmark"]}, marquee:{namerequired:!0, parent:["section"]}, math:{childpresentational:!0, namefrom:["author"], +parent:["section"]}, menu:{mustcontain:["group", "menuitemradio", "menuitem", "menuitemcheckbox"], namefrom:["author"], namerequired:!0, parent:["list", "select"]}, menubar:{namefrom:["author"], parent:["menu"]}, menuitem:{namefrom:["contents", "author"], namerequired:!0, parent:["command"], scope:["menu", "menubar"]}, menuitemcheckbox:{namefrom:["contents", "author"], namerequired:!0, parent:["checkbox", "menuitem"], scope:["menu", "menubar"]}, menuitemradio:{namefrom:["contents", "author"], namerequired:!0, +parent:["menuitemcheckbox", "radio"], scope:["menu", "menubar"]}, navigation:{namefrom:["author"], parent:["landmark"]}, note:{namefrom:["author"], parent:["section"]}, option:{namefrom:["contents", "author"], namerequired:!0, parent:["input"], properties:["aria-checked", "aria-posinset", "aria-selected", "aria-setsize"]}, presentation:{parent:["structure"]}, progressbar:{childpresentational:!0, namefrom:["author"], namerequired:!0, parent:["range"]}, radio:{namefrom:["contents", "author"], namerequired:!0, +parent:["checkbox", "option"]}, radiogroup:{mustcontain:["radio"], namefrom:["author"], namerequired:!0, parent:["select"], properties:["aria-required"]}, range:{"abstract":!0, namefrom:["author"], parent:["widget"], properties:["aria-valuemax", "aria-valuemin", "aria-valuenow", "aria-valuetext"]}, region:{namefrom:[" author"], parent:["section"]}, roletype:{"abstract":!0, properties:"aria-atomic aria-busy aria-controls aria-describedby aria-disabled aria-dropeffect aria-flowto aria-grabbed aria-haspopup aria-hidden aria-invalid aria-label aria-labelledby aria-live aria-owns aria-relevant".split(" ")}, +row:{mustcontain:["columnheader", "gridcell", "rowheader"], namefrom:["contents", "author"], parent:["group", "widget"], properties:["aria-level", "aria-selected"], scope:["grid", "rowgroup", "treegrid"]}, rowgroup:{mustcontain:["row"], namefrom:["contents", "author"], parent:["group"], scope:["grid"]}, rowheader:{namefrom:["contents", "author"], namerequired:!0, parent:["gridcell", "sectionhead", "widget"], properties:["aria-sort"], scope:["row"]}, search:{namefrom:["author"], parent:["landmark"]}, +section:{"abstract":!0, namefrom:["contents", "author"], parent:["structure"], properties:["aria-expanded"]}, sectionhead:{"abstract":!0, namefrom:["contents", "author"], parent:["structure"], properties:["aria-expanded"]}, select:{"abstract":!0, namefrom:["author"], parent:["composite", "group", "input"]}, separator:{childpresentational:!0, namefrom:["author"], parent:["structure"], properties:["aria-expanded", "aria-orientation"]}, scrollbar:{childpresentational:!0, namefrom:["author"], namerequired:!1, +parent:["input", "range"], requiredProperties:["aria-controls", "aria-orientation", "aria-valuemax", "aria-valuemin", "aria-valuenow"], properties:["aria-controls", "aria-orientation", "aria-valuemax", "aria-valuemin", "aria-valuenow"]}, slider:{childpresentational:!0, namefrom:["author"], namerequired:!0, parent:["input", "range"], requiredProperties:["aria-valuemax", "aria-valuemin", "aria-valuenow"], properties:["aria-valuemax", "aria-valuemin", "aria-valuenow", "aria-orientation"]}, spinbutton:{namefrom:["author"], +namerequired:!0, parent:["input", "range"], requiredProperties:["aria-valuemax", "aria-valuemin", "aria-valuenow"], properties:["aria-valuemax", "aria-valuemin", "aria-valuenow", "aria-required"]}, status:{parent:["region"]}, structure:{"abstract":!0, parent:["roletype"]}, tab:{namefrom:["contents", "author"], parent:["sectionhead", "widget"], properties:["aria-selected"], scope:["tablist"]}, tablist:{mustcontain:["tab"], namefrom:["author"], parent:["composite", "directory"], properties:["aria-level"]}, +tabpanel:{namefrom:["author"], namerequired:!0, parent:["region"]}, textbox:{namefrom:["author"], namerequired:!0, parent:["input"], properties:["aria-activedescendant", "aria-autocomplete", "aria-multiline", "aria-readonly", "aria-required"]}, timer:{namefrom:["author"], namerequired:!0, parent:["status"]}, toolbar:{namefrom:["author"], parent:["group"]}, tooltip:{namerequired:!0, parent:["section"]}, tree:{mustcontain:["group", "treeitem"], namefrom:["author"], namerequired:!0, parent:["select"], +properties:["aria-multiselectable", "aria-required"]}, treegrid:{mustcontain:["row"], namefrom:["author"], namerequired:!0, parent:["grid", "tree"]}, treeitem:{namefrom:["contents", "author"], namerequired:!0, parent:["listitem", "option"], scope:["group", "tree"]}, widget:{"abstract":!0, parent:["roletype"]}, window:{"abstract":!0, namefrom:[" author"], parent:["roletype"], properties:["aria-expanded"]}}; axs.constants.WIDGET_ROLES = {}; axs.constants.addAllParentRolesToSet_ = function(a, b) { if (a.parent) { @@ -480,7 +481,18 @@ describedby:{type:"property", valueType:"idref_list"}, disabled:{defaultValue:"f multiline:{defaultValue:"false", type:"property", valueType:"boolean"}, multiselectable:{defaultValue:"false", type:"property", valueType:"boolean"}, orientation:{defaultValue:"vertical", type:"property", valueType:"token", values:["horizontal", "vertical"]}, owns:{type:"property", valueType:"idref_list"}, posinset:{type:"property", valueType:"integer"}, pressed:{defaultValue:"undefined", type:"state", valueType:"token", values:["true", "false", "mixed", "undefined"]}, readonly:{defaultValue:"false", type:"property", valueType:"boolean"}, relevant:{defaultValue:"additions text", type:"property", valueType:"token_list", values:["additions", "removals", "text", "all"]}, required:{defaultValue:"false", type:"property", valueType:"boolean"}, selected:{defaultValue:"undefined", type:"state", valueType:"token", values:["true", "false", "undefined"]}, setsize:{type:"property", valueType:"integer"}, sort:{defaultValue:"none", type:"property", valueType:"token", values:["ascending", "descending", "none", "other"]}, valuemax:{type:"property", valueType:"decimal"}, valuemin:{type:"property", valueType:"decimal"}, valuenow:{type:"property", valueType:"decimal"}, valuetext:{type:"property", valueType:"string"}}; -axs.constants.GLOBAL_PROPERTIES = "aria-atomic aria-busy aria-controls aria-describedby aria-disabled aria-dropeffect aria-flowto aria-grabbed aria-haspopup aria-hidden aria-invalid aria-label aria-labelledby aria-live aria-owns aria-relevant".split(" "); +(function() { + for (var a in axs.constants.ARIA_PROPERTIES) { + var b = axs.constants.ARIA_PROPERTIES[a]; + if (b.values) { + for (var c = {}, d = 0;d < b.values.length;d++) { + c[b.values[d]] = !0; + } + b.valuesSet = c; + } + } +})(); +axs.constants.GLOBAL_PROPERTIES = axs.constants.ARIA_ROLES.roletype.propertiesSet; axs.constants.NO_ROLE_NAME = " "; axs.constants.WIDGET_ROLE_TO_NAME = {alert:"aria_role_alert", alertdialog:"aria_role_alertdialog", button:"aria_role_button", checkbox:"aria_role_checkbox", columnheader:"aria_role_columnheader", combobox:"aria_role_combobox", dialog:"aria_role_dialog", grid:"aria_role_grid", gridcell:"aria_role_gridcell", link:"aria_role_link", listbox:"aria_role_listbox", log:"aria_role_log", marquee:"aria_role_marquee", menu:"aria_role_menu", menubar:"aria_role_menubar", menuitem:"aria_role_menuitem", menuitemcheckbox:"aria_role_menuitemcheckbox", menuitemradio:"aria_role_menuitemradio", option:axs.constants.NO_ROLE_NAME, progressbar:"aria_role_progressbar", radio:"aria_role_radio", radiogroup:"aria_role_radiogroup", rowheader:"aria_role_rowheader", scrollbar:"aria_role_scrollbar", slider:"aria_role_slider", spinbutton:"aria_role_spinbutton", status:"aria_role_status", tab:"aria_role_tab", tabpanel:"aria_role_tabpanel", textbox:"aria_role_textbox", timer:"aria_role_timer", toolbar:"aria_role_toolbar", tooltip:"aria_role_tooltip", treeitem:"aria_role_treeitem"}; @@ -494,80 +506,277 @@ submit:"input_type_submit", tel:"input_type_tel", text:"input_type_text", url:"i 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"}; axs.constants.TAG_TO_INFORMATION_TABLE_BRIEF_MSG = {BUTTON:"tag_button", SELECT:"tag_select", TEXTAREA:"tag_textarea"}; axs.constants.MIXED_VALUES = {"true":!0, "false":!0, mixed:!0}; -(function() { - for (var a in axs.constants.ARIA_PROPERTIES) { - var b = axs.constants.ARIA_PROPERTIES[a]; - if (b.values) { - for (var c = {}, d = 0;d < b.values.length;d++) { - c[b.values[d]] = !0; - } - b.valuesSet = c; - } - } -})(); axs.constants.Severity = {INFO:"Info", WARNING:"Warning", SEVERE:"Severe"}; axs.constants.AuditResult = {PASS:"PASS", FAIL:"FAIL", NA:"NA"}; 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}; -axs.utils = {}; -axs.utils.FOCUSABLE_ELEMENTS_SELECTOR = "input:not([type=hidden]):not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),a[href],iframe,[tabindex]"; -axs.utils.Color = function(a, b, c, d) { +axs.constants.NATIVELY_DISABLEABLE = {BUTTON:!0, INPUT:!0, SELECT:!0, TEXTAREA:!0, FIELDSET:!0, OPTGROUP:!0, OPTION:!0}; +axs.constants.ARIA_TO_HTML_ATTRIBUTE = {"aria-checked":"checked", "aria-disabled":"disabled", "aria-hidden":"hidden", "aria-expanded":"open", "aria-valuemax":"max", "aria-valuemin":"min", "aria-readonly":"readonly", "aria-required":"required", "aria-selected":"selected", "aria-valuenow":"value"}; +axs.constants.TAG_TO_IMPLICIT_SEMANTIC_INFO = {A:[{role:"link", allowed:"button checkbox menuitem menuitemcheckbox menuitemradio tab treeitem".split(" "), selector:"a[href]"}], ADDRESS:[{role:"", allowed:["contentinfo", "presentation"]}], AREA:[{role:"link", selector:"area[href]"}], ARTICLE:[{role:"article", allowed:["presentation", "article", "document", "application", "main"]}], ASIDE:[{role:"complementary", allowed:["note", "complementary", "search", "presentation"]}], AUDIO:[{role:"", allowed:["application", +"presentation"]}], BASE:[{role:"", reserved:!0}], BODY:[{role:"document", allowed:["presentation"]}], BUTTON:[{role:"button", allowed:["link", "menuitem", "menuitemcheckbox", "menuitemradio", "radio"], selector:'button:not([aria-pressed]):not([type="menu"])'}, {role:"button", allowed:["button"], selector:"button[aria-pressed]"}, {role:"button", attributes:{"aria-haspopup":!0}, allowed:["link", "menuitem", "menuitemcheckbox", "menuitemradio", "radio"], selector:'button[type="menu"]'}], CAPTION:[{role:"", +allowed:["presentation"]}], COL:[{role:"", reserved:!0}], COLGROUP:[{role:"", reserved:!0}], DATALIST:[{role:"listbox", attributes:{"aria-multiselectable":!1}, allowed:["presentation"]}], DEL:[{role:"", allowed:["*"]}], DD:[{role:"", allowed:["presentation"]}], DT:[{role:"", allowed:["presentation"]}], DETAILS:[{role:"group", allowed:["group", "presentation"]}], DIALOG:[{role:"dialog", allowed:"dialog alert alertdialog application log marquee status".split(" "), selector:"dialog[open]"}, {role:"dialog", +attributes:{"aria-hidden":!0}, allowed:"dialog alert alertdialog application log marquee status".split(" "), selector:"dialog:not([open])"}], DIV:[{role:"", allowed:["*"]}], DL:[{role:"list", allowed:["presentation"]}], EMBED:[{role:"", allowed:["application", "document", "img", "presentation"]}], FIGURE:[{role:"", allowed:["*"]}], FOOTER:[{role:"", allowed:["contentinfo", "presentation"]}], FORM:[{role:"form", allowed:["presentation"]}], P:[{role:"", allowed:["*"]}], PRE:[{role:"", allowed:["*"]}], +BLOCKQUOTE:[{role:"", allowed:["*"]}], H1:[{role:"heading"}], H2:[{role:"heading"}], H3:[{role:"heading"}], H4:[{role:"heading"}], H5:[{role:"heading"}], H6:[{role:"heading"}], HEAD:[{role:"", reserved:!0}], HEADER:[{role:"", allowed:["banner", "presentation"]}], HR:[{role:"separator", allowed:["presentation"]}], HTML:[{role:"", reserved:!0}], IFRAME:[{role:"", allowed:["application", "document", "img", "presentation"], selector:"iframe:not([seamless])"}, {role:"", allowed:["application", "document", +"img", "presentation", "group"], selector:"iframe[seamless]"}], IMG:[{role:"presentation", reserved:!0, selector:'img[alt=""]'}, {role:"img", allowed:["*"], selector:'img[alt]:not([alt=""])'}], INPUT:[{role:"button", allowed:["link", "menuitem", "menuitemcheckbox", "menuitemradio", "radio"], selector:'input[type="button"]:not([aria-pressed])'}, {role:"button", allowed:["button"], selector:'input[type="button"][aria-pressed]'}, {role:"checkbox", allowed:["checkbox"], selector:'input[type="checkbox"]'}, +{role:"", selector:'input[type="color"]'}, {role:"", selector:'input[type="date"]'}, {role:"", selector:'input[type="datetime"]'}, {role:"textbox", selector:'input[type="email"]:not([list])'}, {role:"", selector:'input[type="file"]'}, {role:"", reserved:!0, selector:'input[type="hidden"]'}, {role:"button", allowed:["button"], selector:'input[type="image"][aria-pressed]'}, {role:"button", allowed:["link", "menuitem", "menuitemcheckbox", "menuitemradio", "radio"], selector:'input[type="image"]:not([aria-pressed])'}, +{role:"", selector:'input[type="month"]'}, {role:"", selector:'input[type="number"]'}, {role:"textbox", selector:'input[type="password"]'}, {role:"radio", allowed:["menuitemradio"], selector:'input[type="radio"]'}, {role:"slider", selector:'input[type="range"]'}, {role:"button", selector:'input[type="reset"]'}, {role:"combobox", selector:'input[type="search"][list]'}, {role:"textbox", selector:'input[type="search"]:not([list])'}, {role:"button", selector:'input[type="submit"]'}, {role:"combobox", +selector:'input[type="tel"][list]'}, {role:"textbox", selector:'input[type="tel"]:not([list])'}, {role:"combobox", selector:'input[type="text"][list]'}, {role:"textbox", selector:'input[type="text"]:not([list])'}, {role:"textbox", selector:"input:not([type])"}, {role:"", selector:'input[type="time"]'}, {role:"combobox", selector:'input[type="url"][list]'}, {role:"textbox", selector:'input[type="url"]:not([list])'}, {role:"", selector:'input[type="week"]'}], INS:[{role:"", allowed:["*"]}], KEYGEN:[{role:""}], +LABEL:[{role:"", allowed:["presentation"]}], LI:[{role:"listitem", allowed:"menuitem menuitemcheckbox menuitemradio option tab treeitem presentation".split(" "), selector:'ol:not([role="presentation"])>li, ul:not([role="presentation"])>li'}, {role:"listitem", allowed:"listitem menuitem menuitemcheckbox menuitemradio option tab treeitem presentation".split(" "), selector:'ol[role="presentation"]>li, ul[role="presentation"]>li'}], LINK:[{role:"link", reserved:!0, selector:"link[href]"}], MAIN:[{role:"", +allowed:["main", "presentation"]}], MAP:[{role:"", reserved:!0}], MATH:[{role:"", allowed:["presentation"]}], MENU:[{role:"toolbar", selector:'menu[type="toolbar"]'}], MENUITEM:[{role:"menuitem", selector:'menuitem[type="command"]'}, {role:"menuitemcheckbox", selector:'menuitem[type="checkbox"]'}, {role:"menuitemradio", selector:'menuitem[type="radio"]'}], META:[{role:"", reserved:!0}], METER:[{role:"progressbar", allowed:["presentation"]}], NAV:[{role:"navigation", allowed:["navigation", "presentation"]}], +NOSCRIPT:[{role:"", reserved:!0}], OBJECT:[{role:"", allowed:["application", "document", "img", "presentation"]}], OL:[{role:"list", allowed:"directory group listbox menu menubar tablist toolbar tree presentation".split(" ")}], OPTGROUP:[{role:"", allowed:["presentation"]}], OPTION:[{role:"option"}], OUTPUT:[{role:"status", allowed:["*"]}], PARAM:[{role:"", reserved:!0}], PICTURE:[{role:"", reserved:!0}], PROGRESS:[{role:"progressbar", allowed:["presentation"]}], SCRIPT:[{role:"", reserved:!0}], +SECTION:[{role:"region", allowed:"alert alertdialog application contentinfo dialog document log marquee search status presentation".split(" ")}], SELECT:[{role:"listbox"}], SOURCE:[{role:"", reserved:!0}], SPAN:[{role:"", allowed:["*"]}], STYLE:[{role:"", reserved:!0}], SVG:[{role:"", allowed:["application", "document", "img", "presentation"]}], SUMMARY:[{role:"", allowed:["presentation"]}], TABLE:[{role:"", allowed:["*"]}], TEMPLATE:[{role:"", reserved:!0}], TEXTAREA:[{role:"textbox"}], TBODY:[{role:"rowgroup", +allowed:["*"]}], THEAD:[{role:"rowgroup", allowed:["*"]}], TFOOT:[{role:"rowgroup", allowed:["*"]}], TITLE:[{role:"", reserved:!0}], TD:[{role:"", allowed:["*"]}], TH:[{role:"", allowed:["*"]}], TR:[{role:"", allowed:["*"]}], TRACK:[{role:"", reserved:!0}], UL:[{role:"list", allowed:"directory group listbox menu menubar tablist toolbar tree presentation".split(" ")}], VIDEO:[{role:"", allowed:["application", "presentation"]}]}; +axs.color = {}; +axs.color.Color = function(a, b, c, d) { this.red = a; this.green = b; this.blue = c; this.alpha = d; }; -axs.utils.calculateContrastRatio = function(a, b) { - if (!a || !b) { - return null; +axs.color.YCbCr = function(a) { + this.luma = this.z = a[0]; + this.Cb = this.x = a[1]; + this.Cr = this.y = a[2]; +}; +axs.color.YCbCr.prototype = {multiply:function(a) { + return new axs.color.YCbCr([this.luma * a, this.Cb * a, this.Cr * a]); +}, add:function(a) { + return new axs.color.YCbCr([this.luma + a.luma, this.Cb + a.Cb, this.Cr + a.Cr]); +}, subtract:function(a) { + return new axs.color.YCbCr([this.luma - a.luma, this.Cb - a.Cb, this.Cr - a.Cr]); +}}; +axs.color.calculateContrastRatio = function(a, b) { + 1 > a.alpha && (a = axs.color.flattenColors(a, b)); + var c = axs.color.calculateLuminance(a), d = axs.color.calculateLuminance(b); + return (Math.max(c, d) + .05) / (Math.min(c, d) + .05); +}; +axs.color.calculateLuminance = function(a) { + return axs.color.toYCbCr(a).luma; +}; +axs.color.luminanceRatio = function(a, b) { + return (Math.max(a, b) + .05) / (Math.min(a, b) + .05); +}; +axs.color.parseColor = function(a) { + if ("transparent" === a) { + return new axs.color.Color(0, 0, 0, 0); } - 1 > a.alpha && (a = axs.utils.flattenColors(a, b)); - var c = axs.utils.calculateLuminance(a), d = axs.utils.calculateLuminance(b); - return(Math.max(c, d) + .05) / (Math.min(c, d) + .05); + var b = a.match(/^rgb\((\d+), (\d+), (\d+)\)$/); + if (b) { + a = parseInt(b[1], 10); + var c = parseInt(b[2], 10), d = parseInt(b[3], 10); + return new axs.color.Color(a, c, d, 1); + } + return (b = a.match(/^rgba\((\d+), (\d+), (\d+), (\d*(\.\d+)?)\)/)) ? (a = parseInt(b[1], 10), c = parseInt(b[2], 10), d = parseInt(b[3], 10), b = parseFloat(b[4]), new axs.color.Color(a, c, d, b)) : null; }; -axs.utils.luminanceRatio = function(a, b) { - return(Math.max(a, b) + .05) / (Math.min(a, b) + .05); +axs.color.colorChannelToString = function(a) { + a = Math.round(a); + return 15 >= a ? "0" + a.toString(16) : a.toString(16); }; -axs.utils.parentElement = function(a) { - if (!a) { - return null; +axs.color.colorToString = function(a) { + return 1 == a.alpha ? "#" + axs.color.colorChannelToString(a.red) + axs.color.colorChannelToString(a.green) + axs.color.colorChannelToString(a.blue) : "rgba(" + [a.red, a.green, a.blue, a.alpha].join() + ")"; +}; +axs.color.luminanceFromContrastRatio = function(a, b, c) { + return c ? (a + .05) * b - .05 : (a + .05) / b - .05; +}; +axs.color.translateColor = function(a, b) { + for (var c = b > a.luma ? axs.color.WHITE_YCC : axs.color.BLACK_YCC, d = c == axs.color.WHITE_YCC ? axs.color.YCC_CUBE_FACES_WHITE : axs.color.YCC_CUBE_FACES_BLACK, e = new axs.color.YCbCr([0, a.Cb, a.Cr]), f = new axs.color.YCbCr([1, a.Cb, a.Cr]), f = {a:e, b:f}, e = null, g = 0;g < d.length && !(e = axs.color.findIntersection(f, d[g]), 0 <= e.z && 1 >= e.z);g++) { } - if (a.nodeType == Node.DOCUMENT_FRAGMENT_NODE) { - return a.host; + if (!e) { + throw "Couldn't find intersection with YCbCr color cube for Cb=" + a.Cb + ", Cr=" + a.Cr + "."; + } + if (e.x != a.x || e.y != a.y) { + throw "Intersection has wrong Cb/Cr values."; + } + if (Math.abs(c.luma - e.luma) < Math.abs(c.luma - b)) { + return c = [b, a.Cb, a.Cr], axs.color.fromYCbCrArray(c); + } + c = (b - e.luma) / (c.luma - e.luma); + c = [b, e.Cb - e.Cb * c, e.Cr - e.Cr * c]; + return axs.color.fromYCbCrArray(c); +}; +axs.color.suggestColors = function(a, b, c) { + var d = {}, e = axs.color.calculateLuminance(a), f = axs.color.calculateLuminance(b), g = f > e, h = axs.color.toYCbCr(b), k = axs.color.toYCbCr(a), m; + for (m in c) { + var l = c[m], n = axs.color.luminanceFromContrastRatio(e, l + .02, g); + if (1 >= n && 0 <= n) { + var p = axs.color.translateColor(h, n), l = axs.color.calculateContrastRatio(p, a), n = {}; + n.fg = axs.color.colorToString(p); + n.bg = axs.color.colorToString(a); + n.contrast = l.toFixed(2); + d[m] = n; + } else { + l = axs.color.luminanceFromContrastRatio(f, l + .02, !g), 1 >= l && 0 <= l && (p = axs.color.translateColor(k, l), l = axs.color.calculateContrastRatio(b, p), n = {}, n.bg = axs.color.colorToString(p), n.fg = axs.color.colorToString(b), n.contrast = l.toFixed(2), d[m] = n); + } } - var b = a.parentElement; - if (b) { - return b; + return d; +}; +axs.color.flattenColors = function(a, b) { + var c = a.alpha; + return new axs.color.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)); +}; +axs.color.multiplyMatrixVector = function(a, b) { + var c = b[0], d = b[1], e = b[2]; + return [a[0][0] * c + a[0][1] * d + a[0][2] * e, a[1][0] * c + a[1][1] * d + a[1][2] * e, a[2][0] * c + a[2][1] * d + a[2][2] * e]; +}; +axs.color.toYCbCr = function(a) { + var b = a.red / 255, c = a.green / 255; + a = a.blue / 255; + b = .03928 >= b ? b / 12.92 : Math.pow((b + .055) / 1.055, 2.4); + c = .03928 >= c ? c / 12.92 : Math.pow((c + .055) / 1.055, 2.4); + a = .03928 >= a ? a / 12.92 : Math.pow((a + .055) / 1.055, 2.4); + return new axs.color.YCbCr(axs.color.multiplyMatrixVector(axs.color.YCC_MATRIX, [b, c, a])); +}; +axs.color.fromYCbCr = function(a) { + return axs.color.fromYCbCrArray([a.luma, a.Cb, a.Cr]); +}; +axs.color.fromYCbCrArray = function(a) { + var b = axs.color.multiplyMatrixVector(axs.color.INVERTED_YCC_MATRIX, a), c = b[0]; + a = b[1]; + b = b[2]; + c = .00303949 >= c ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - .055; + a = .00303949 >= a ? 12.92 * a : 1.055 * Math.pow(a, 1 / 2.4) - .055; + b = .00303949 >= b ? 12.92 * b : 1.055 * Math.pow(b, 1 / 2.4) - .055; + c = Math.min(Math.max(Math.round(255 * c), 0), 255); + a = Math.min(Math.max(Math.round(255 * a), 0), 255); + b = Math.min(Math.max(Math.round(255 * b), 0), 255); + return new axs.color.Color(c, a, b, 1); +}; +axs.color.RGBToYCbCrMatrix = function(a, b) { + return [[a, 1 - a - b, b], [-a / (2 - 2 * b), (a + b - 1) / (2 - 2 * b), (1 - b) / (2 - 2 * b)], [(1 - a) / (2 - 2 * a), (a + b - 1) / (2 - 2 * a), -b / (2 - 2 * a)]]; +}; +axs.color.invert3x3Matrix = function(a) { + var b = a[0][0], c = a[0][1], d = a[0][2], e = a[1][0], f = a[1][1], g = a[1][2], h = a[2][0], k = a[2][1]; + a = a[2][2]; + return axs.color.scalarMultiplyMatrix([[f * a - g * k, d * k - c * a, c * g - d * f], [g * h - e * a, b * a - d * h, d * e - b * g], [e * k - f * h, h * c - b * k, b * f - c * e]], 1 / (b * (f * a - g * k) - c * (a * e - g * h) + d * (e * k - f * h))); +}; +axs.color.findIntersection = function(a, b) { + var c = [a.a.x - b.p0.x, a.a.y - b.p0.y, a.a.z - b.p0.z], d = axs.color.invert3x3Matrix([[a.a.x - a.b.x, b.p1.x - b.p0.x, b.p2.x - b.p0.x], [a.a.y - a.b.y, b.p1.y - b.p0.y, b.p2.y - b.p0.y], [a.a.z - a.b.z, b.p1.z - b.p0.z, b.p2.z - b.p0.z]]), c = axs.color.multiplyMatrixVector(d, c)[0]; + return a.a.add(a.b.subtract(a.a).multiply(c)); +}; +axs.color.scalarMultiplyMatrix = function(a, b) { + for (var c = [], d = 0;3 > d;d++) { + c[d] = axs.color.scalarMultiplyVector(a[d], b); + } + return c; +}; +axs.color.scalarMultiplyVector = function(a, b) { + for (var c = [], d = 0;d < a.length;d++) { + c[d] = a[d] * b; + } + return c; +}; +axs.color.kR = .2126; +axs.color.kB = .0722; +axs.color.YCC_MATRIX = axs.color.RGBToYCbCrMatrix(axs.color.kR, axs.color.kB); +axs.color.INVERTED_YCC_MATRIX = axs.color.invert3x3Matrix(axs.color.YCC_MATRIX); +axs.color.BLACK = new axs.color.Color(0, 0, 0, 1); +axs.color.BLACK_YCC = axs.color.toYCbCr(axs.color.BLACK); +axs.color.WHITE = new axs.color.Color(255, 255, 255, 1); +axs.color.WHITE_YCC = axs.color.toYCbCr(axs.color.WHITE); +axs.color.RED = new axs.color.Color(255, 0, 0, 1); +axs.color.RED_YCC = axs.color.toYCbCr(axs.color.RED); +axs.color.GREEN = new axs.color.Color(0, 255, 0, 1); +axs.color.GREEN_YCC = axs.color.toYCbCr(axs.color.GREEN); +axs.color.BLUE = new axs.color.Color(0, 0, 255, 1); +axs.color.BLUE_YCC = axs.color.toYCbCr(axs.color.BLUE); +axs.color.CYAN = new axs.color.Color(0, 255, 255, 1); +axs.color.CYAN_YCC = axs.color.toYCbCr(axs.color.CYAN); +axs.color.MAGENTA = new axs.color.Color(255, 0, 255, 1); +axs.color.MAGENTA_YCC = axs.color.toYCbCr(axs.color.MAGENTA); +axs.color.YELLOW = new axs.color.Color(255, 255, 0, 1); +axs.color.YELLOW_YCC = axs.color.toYCbCr(axs.color.YELLOW); +axs.color.YCC_CUBE_FACES_BLACK = [{p0:axs.color.BLACK_YCC, p1:axs.color.RED_YCC, p2:axs.color.GREEN_YCC}, {p0:axs.color.BLACK_YCC, p1:axs.color.GREEN_YCC, p2:axs.color.BLUE_YCC}, {p0:axs.color.BLACK_YCC, p1:axs.color.BLUE_YCC, p2:axs.color.RED_YCC}]; +axs.color.YCC_CUBE_FACES_WHITE = [{p0:axs.color.WHITE_YCC, p1:axs.color.CYAN_YCC, p2:axs.color.MAGENTA_YCC}, {p0:axs.color.WHITE_YCC, p1:axs.color.MAGENTA_YCC, p2:axs.color.YELLOW_YCC}, {p0:axs.color.WHITE_YCC, p1:axs.color.YELLOW_YCC, p2:axs.color.CYAN_YCC}]; +axs.dom = {}; +axs.dom.parentElement = function(a) { + if (!a) { + return null; } - a = a.parentNode; + a = axs.dom.composedParentNode(a); if (!a) { return null; } switch(a.nodeType) { case Node.ELEMENT_NODE: return a; - case Node.DOCUMENT_FRAGMENT_NODE: - return a.host; default: - return null; + return axs.dom.parentElement(a); + } +}; +axs.dom.shadowHost = function(a) { + return "host" in a ? a.host : null; +}; +axs.dom.composedParentNode = function(a) { + if (!a) { + return null; + } + if (a.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { + return axs.dom.shadowHost(a); } + var b = a.parentNode; + if (!b) { + return null; + } + if (b.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { + return axs.dom.shadowHost(b); + } + if (!b.shadowRoot) { + return b; + } + a = a.getDestinationInsertionPoints(); + return 0 < a.length ? axs.dom.composedParentNode(a[a.length - 1]) : null; }; -axs.utils.asElement = function(a) { +axs.dom.asElement = function(a) { switch(a.nodeType) { case Node.COMMENT_NODE: - return null; + break; case Node.ELEMENT_NODE: - if ("script" == a.tagName.toLowerCase()) { - return null; + if ("script" == a.localName || "template" == a.localName) { + break; } - break; + return a; + case Node.DOCUMENT_FRAGMENT_NODE: + return a.host; case Node.TEXT_NODE: - a = axs.utils.parentElement(a); - break; + return axs.dom.parentElement(a); default: - return console.warn("Unhandled node type: ", a.nodeType), null; + console.warn("Unhandled node type: ", a.nodeType); } - return a; + return null; +}; +axs.dom.composedTreeSearch = function(a, b, c, d) { + if (a === b) { + return !0; + } + if (a.nodeType == Node.ELEMENT_NODE) { + var e = a + } + var f = !1; + if (e && c.preorder && !c.preorder(e)) { + return f; + } + if (e) { + var g = e.shadowRoot || e.webkitShadowRoot; + if (g) { + return f = axs.dom.composedTreeSearch(g, b, c, g), e && c.postorder && !f && c.postorder(e), f; + } + } + if (e && "content" == e.localName) { + a = e.getDistributedNodes(); + for (g = 0;g < a.length && !f;g++) { + f = axs.dom.composedTreeSearch(a[g], b, c, d); + } + e && c.postorder && !f && c.postorder.call(null, e); + return f; + } + for (a = a.firstChild;null != a && !f;) { + f = axs.dom.composedTreeSearch(a, b, c, d), a = a.nextSibling; + } + e && c.postorder && !f && c.postorder.call(null, e); + return f; }; +axs.utils = {}; +axs.utils.FOCUSABLE_ELEMENTS_SELECTOR = "input:not([type=hidden]):not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),a[href],iframe,[tabindex]"; +axs.utils.LABELABLE_ELEMENTS_SELECTOR = "button,input:not([type=hidden]),keygen,meter,output,progress,select,textarea"; axs.utils.elementIsTransparent = function(a) { return "0" == a.style.opacity; }; @@ -577,32 +786,45 @@ axs.utils.elementHasZeroArea = function(a) { return a.right - a.left && b ? !1 : !0; }; axs.utils.elementIsOutsideScrollArea = function(a) { - for (var b = axs.utils.parentElement(a), c = a.ownerDocument.defaultView;b != c.document.body;) { + for (var b = axs.dom.parentElement(a), c = a.ownerDocument.defaultView;b != c.document.body;) { if (axs.utils.isClippedBy(a, b)) { - return!0; + return !0; } if (axs.utils.canScrollTo(a, b) && !axs.utils.elementIsOutsideScrollArea(b)) { - return!1; + return !1; } - b = axs.utils.parentElement(b); + b = axs.dom.parentElement(b); } - return!axs.utils.canScrollTo(a, c.document.body); + return !axs.utils.canScrollTo(a, c.document.body); }; axs.utils.canScrollTo = function(a, b) { - var c = a.getBoundingClientRect(), d = b.getBoundingClientRect(), e = d.top, f = d.left, g = e - b.scrollTop, e = e - b.scrollTop + b.scrollHeight, h = f - b.scrollLeft + b.scrollWidth; - if (c.right < f - b.scrollLeft || c.bottom < g || c.left > h || c.top > e) { - return!1; + var c = a.getBoundingClientRect(), d = b.getBoundingClientRect(); + if (b == b.ownerDocument.body) { + var e = d.top, f = d.left + } else { + e = d.top - b.scrollTop, f = d.left - b.scrollLeft; + } + var g = e + b.scrollHeight, h = f + b.scrollWidth; + if (c.right < f || c.bottom < e || c.left > h || c.top > g) { + return !1; } - f = a.ownerDocument.defaultView; - g = f.getComputedStyle(b); - return c.left > d.right || c.top > d.bottom ? "scroll" == g.overflow || "auto" == g.overflow || b instanceof f.HTMLBodyElement : !0; + e = a.ownerDocument.defaultView; + f = e.getComputedStyle(b); + return c.left > d.right || c.top > d.bottom ? "scroll" == f.overflow || "auto" == f.overflow || b instanceof e.HTMLBodyElement : !0; }; axs.utils.isClippedBy = function(a, b) { var c = a.getBoundingClientRect(), d = b.getBoundingClientRect(), e = d.top - b.scrollTop, f = d.left - b.scrollLeft, g = a.ownerDocument.defaultView.getComputedStyle(b); - return(c.right < d.left || c.bottom < d.top || c.left > d.right || c.top > d.bottom) && "hidden" == g.overflow ? !0 : c.right < f || c.bottom < e ? "visible" != g.overflow : !1; + return (c.right < d.left || c.bottom < d.top || c.left > d.right || c.top > d.bottom) && "hidden" == g.overflow ? !0 : c.right < f || c.bottom < e ? "visible" != g.overflow : !1; }; axs.utils.isAncestor = function(a, b) { - return null == b ? !1 : b === a ? !0 : axs.utils.isAncestor(a, b.parentNode); + if (null == b) { + return !1; + } + if (b === a) { + return !0; + } + var c = axs.dom.composedParentNode(b); + return axs.utils.isAncestor(a, c); }; axs.utils.overlappingElements = function(a) { if (axs.utils.elementHasZeroArea(a)) { @@ -648,13 +870,13 @@ axs.utils.isLargeFont = function(a) { } if (c = b.match(/(\d+)pt/)) { if (b = parseInt(c[1], 10), a && 14 <= b || 18 <= b) { - return!0; + return !0; } } - return!1; + return !1; }; axs.utils.getBgColor = function(a, b) { - var c = axs.utils.parseColor(a.backgroundColor); + var c = axs.color.parseColor(a.backgroundColor); if (!c) { return null; } @@ -664,158 +886,38 @@ axs.utils.getBgColor = function(a, b) { if (null == d) { return null; } - c = axs.utils.flattenColors(c, d); + c = axs.color.flattenColors(c, d); } return c; }; axs.utils.getParentBgColor = function(a) { var b = a; a = []; - for (var c = null;b = axs.utils.parentElement(b);) { + for (var c = null;b = axs.dom.parentElement(b);) { var d = window.getComputedStyle(b, null); if (d) { - var e = axs.utils.parseColor(d.backgroundColor); + var e = axs.color.parseColor(d.backgroundColor); if (e && (1 > d.opacity && (e.alpha *= d.opacity), 0 != e.alpha && (a.push(e), 1 == e.alpha))) { c = !0; break; } } } - c || a.push(new axs.utils.Color(255, 255, 255, 1)); + c || a.push(new axs.color.Color(255, 255, 255, 1)); for (b = a.pop();a.length;) { - c = a.pop(), b = axs.utils.flattenColors(c, b); + c = a.pop(), b = axs.color.flattenColors(c, b); } return b; }; axs.utils.getFgColor = function(a, b, c) { - var d = axs.utils.parseColor(a.color); + var d = axs.color.parseColor(a.color); if (!d) { return null; } - 1 > d.alpha && (d = axs.utils.flattenColors(d, c)); - 1 > a.opacity && (b = axs.utils.getParentBgColor(b), d.alpha *= a.opacity, d = axs.utils.flattenColors(d, b)); + 1 > d.alpha && (d = axs.color.flattenColors(d, c)); + 1 > a.opacity && (b = axs.utils.getParentBgColor(b), d.alpha *= a.opacity, d = axs.color.flattenColors(d, b)); return d; }; -axs.utils.parseColor = function(a) { - var b = a.match(/^rgb\((\d+), (\d+), (\d+)\)$/); - if (b) { - a = parseInt(b[1], 10); - var c = parseInt(b[2], 10), b = parseInt(b[3], 10), d; - return new axs.utils.Color(a, c, b, 1); - } - 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; -}; -axs.utils.colorChannelToString = function(a) { - a = Math.round(a); - return 15 >= a ? "0" + a.toString(16) : a.toString(16); -}; -axs.utils.colorToString = function(a) { - return 1 == a.alpha ? "#" + axs.utils.colorChannelToString(a.red) + axs.utils.colorChannelToString(a.green) + axs.utils.colorChannelToString(a.blue) : "rgba(" + [a.red, a.green, a.blue, a.alpha].join() + ")"; -}; -axs.utils.luminanceFromContrastRatio = function(a, b, c) { - return c ? (a + .05) * b - .05 : (a + .05) / b - .05; -}; -axs.utils.translateColor = function(a, b) { - var c = a[0], c = (b - c) / ((c > b ? 0 : 1) - c); - return axs.utils.fromYCC([b, a[1] - a[1] * c, a[2] - a[2] * c]); -}; -axs.utils.suggestColors = function(a, b, c, d) { - if (!axs.utils.isLowContrast(c, d, !0)) { - return null; - } - var e = {}, f = axs.utils.calculateLuminance(a), g = axs.utils.calculateLuminance(b), h = axs.utils.isLargeFont(d) ? 3 : 4.5, k = axs.utils.isLargeFont(d) ? 4.5 : 7, m = g > f, l = axs.utils.luminanceFromContrastRatio(f, h + .02, m), n = axs.utils.luminanceFromContrastRatio(f, k + .02, m), q = axs.utils.toYCC(b); - if (axs.utils.isLowContrast(c, d, !1) && 1 >= l && 0 <= l) { - var p = axs.utils.translateColor(q, l), l = axs.utils.calculateContrastRatio(p, a); - axs.utils.calculateLuminance(p); - f = {}; - f.fg = axs.utils.colorToString(p); - f.bg = axs.utils.colorToString(a); - f.contrast = l.toFixed(2); - e.AA = f; - } - axs.utils.isLowContrast(c, d, !0) && 1 >= n && 0 <= n && (n = axs.utils.translateColor(q, n), l = axs.utils.calculateContrastRatio(n, a), f = {}, f.fg = axs.utils.colorToString(n), f.bg = axs.utils.colorToString(a), f.contrast = l.toFixed(2), e.AAA = f); - h = axs.utils.luminanceFromContrastRatio(g, h + .02, !m); - g = axs.utils.luminanceFromContrastRatio(g, k + .02, !m); - a = axs.utils.toYCC(a); - !("AA" in e) && axs.utils.isLowContrast(c, d, !1) && 1 >= h && 0 <= h && (k = axs.utils.translateColor(a, h), l = axs.utils.calculateContrastRatio(b, k), f = {}, f.bg = axs.utils.colorToString(k), f.fg = axs.utils.colorToString(b), f.contrast = l.toFixed(2), e.AA = f); - !("AAA" in e) && axs.utils.isLowContrast(c, d, !0) && 1 >= g && 0 <= g && (c = axs.utils.translateColor(a, g), l = axs.utils.calculateContrastRatio(b, c), f = {}, f.bg = axs.utils.colorToString(c), f.fg = axs.utils.colorToString(b), f.contrast = l.toFixed(2), e.AAA = f); - return e; -}; -axs.utils.flattenColors = function(a, b) { - var c = a.alpha; - 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)); -}; -axs.utils.calculateLuminance = function(a) { - return axs.utils.toYCC(a)[0]; -}; -axs.utils.RGBToYCCMatrix = function(a, b) { - return[[a, 1 - a - b, b], [-a / (2 - 2 * b), (a + b - 1) / (2 - 2 * b), (1 - b) / (2 - 2 * b)], [(1 - a) / (2 - 2 * a), (a + b - 1) / (2 - 2 * a), -b / (2 - 2 * a)]]; -}; -axs.utils.invert3x3Matrix = function(a) { - var b = a[0][0], c = a[0][1], d = a[0][2], e = a[1][0], f = a[1][1], g = a[1][2], h = a[2][0], k = a[2][1]; - a = a[2][2]; - return axs.utils.scalarMultiplyMatrix([[f * a - g * k, d * k - c * a, c * g - d * f], [g * h - e * a, b * a - d * h, d * e - b * g], [e * k - f * h, h * c - b * k, b * f - c * e]], 1 / (b * (f * a - g * k) - c * (a * e - g * h) + d * (e * k - f * h))); -}; -axs.utils.scalarMultiplyMatrix = function(a, b) { - for (var c = [[], [], []], d = 0;3 > d;d++) { - for (var e = 0;3 > e;e++) { - c[d][e] = a[d][e] * b; - } - } - return c; -}; -axs.utils.kR = .2126; -axs.utils.kB = .0722; -axs.utils.YCC_MATRIX = axs.utils.RGBToYCCMatrix(axs.utils.kR, axs.utils.kB); -axs.utils.INVERTED_YCC_MATRIX = axs.utils.invert3x3Matrix(axs.utils.YCC_MATRIX); -axs.utils.convertColor = function(a, b) { - var c = b[0], d = b[1], e = b[2]; - return[a[0][0] * c + a[0][1] * d + a[0][2] * e, a[1][0] * c + a[1][1] * d + a[1][2] * e, a[2][0] * c + a[2][1] * d + a[2][2] * e]; -}; -axs.utils.multiplyMatrices = function(a, b) { - for (var c = [[], [], []], d = 0;3 > d;d++) { - for (var e = 0;3 > e;e++) { - c[d][e] = a[d][0] * b[0][e] + a[d][1] * b[1][e] + a[d][2] * b[2][e]; - } - } - return c; -}; -axs.utils.toYCC = function(a) { - var b = a.red / 255, c = a.green / 255; - a = a.blue / 255; - b = .03928 >= b ? b / 12.92 : Math.pow((b + .055) / 1.055, 2.4); - c = .03928 >= c ? c / 12.92 : Math.pow((c + .055) / 1.055, 2.4); - a = .03928 >= a ? a / 12.92 : Math.pow((a + .055) / 1.055, 2.4); - return axs.utils.convertColor(axs.utils.YCC_MATRIX, [b, c, a]); -}; -axs.utils.fromYCC = function(a) { - var b = axs.utils.convertColor(axs.utils.INVERTED_YCC_MATRIX, a), c = b[0]; - a = b[1]; - b = b[2]; - c = .00303949 >= c ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - .055; - a = .00303949 >= a ? 12.92 * a : 1.055 * Math.pow(a, 1 / 2.4) - .055; - b = .00303949 >= b ? 12.92 * b : 1.055 * Math.pow(b, 1 / 2.4) - .055; - c = Math.min(Math.max(Math.round(255 * c), 0), 255); - a = Math.min(Math.max(Math.round(255 * a), 0), 255); - b = Math.min(Math.max(Math.round(255 * b), 0), 255); - return new axs.utils.Color(c, a, b, 1); -}; -axs.utils.scalarMultiplyMatrix = function(a, b) { - for (var c = [[], [], []], d = 0;3 > d;d++) { - for (var e = 0;3 > e;e++) { - c[d][e] = a[d][e] * b; - } - } - return c; -}; -axs.utils.multiplyMatrices = function(a, b) { - for (var c = [[], [], []], d = 0;3 > d;d++) { - for (var e = 0;3 > e;e++) { - c[d][e] = a[d][0] * b[0][e] + a[d][1] * b[1][e] + a[d][2] * b[2][e]; - } - } - return c; -}; axs.utils.getContrastRatioForElement = function(a) { var b = window.getComputedStyle(a, null); return axs.utils.getContrastRatioForElementWithComputedStyle(b, a); @@ -829,16 +931,16 @@ axs.utils.getContrastRatioForElementWithComputedStyle = function(a, b) { return null; } var d = axs.utils.getFgColor(a, b, c); - return d ? axs.utils.calculateContrastRatio(d, c) : null; + return d ? axs.color.calculateContrastRatio(d, c) : null; }; axs.utils.isNativeTextElement = function(a) { var b = a.tagName.toLowerCase(); a = a.type ? a.type.toLowerCase() : ""; if ("textarea" == b) { - return!0; + return !0; } if ("input" != b) { - return!1; + return !1; } switch(a) { case "email": @@ -856,9 +958,9 @@ axs.utils.isNativeTextElement = function(a) { case "url": ; case "": - return!0; + return !0; default: - return!1; + return !1; } }; axs.utils.isLowContrast = function(a, b, c) { @@ -867,20 +969,37 @@ axs.utils.isLowContrast = function(a, b, c) { }; axs.utils.hasLabel = function(a) { var b = a.tagName.toLowerCase(), c = a.type ? a.type.toLowerCase() : ""; - if (a.hasAttribute("aria-label") || a.hasAttribute("title") || "img" == b && a.hasAttribute("alt") || "input" == b && "image" == c && a.hasAttribute("alt") || "input" == b && ("submit" == c || "reset" == c) || a.hasAttribute("aria-labelledby") || axs.utils.isNativeTextElement(a) && a.hasAttribute("placeholder") || a.hasAttribute("id") && 0 < document.querySelectorAll('label[for="' + a.id + '"]').length) { - return!0; + if (a.hasAttribute("aria-label") || a.hasAttribute("title") || "img" == b && a.hasAttribute("alt") || "input" == b && "image" == c && a.hasAttribute("alt") || "input" == b && ("submit" == c || "reset" == c) || a.hasAttribute("aria-labelledby") || a.hasAttribute("id") && 0 < document.querySelectorAll('label[for="' + a.id + '"]').length) { + return !0; } - for (b = axs.utils.parentElement(a);b;) { + for (b = axs.dom.parentElement(a);b;) { if ("label" == b.tagName.toLowerCase() && b.control == a) { - return!0; + return !0; + } + b = axs.dom.parentElement(b); + } + return !1; +}; +axs.utils.isNativelyDisableable = function(a) { + return a.tagName.toUpperCase() in axs.constants.NATIVELY_DISABLEABLE; +}; +axs.utils.isElementDisabled = function(a) { + if (axs.browserUtils.matchSelector(a, "[aria-disabled=true], [aria-disabled=true] *")) { + return !0; + } + if (!axs.utils.isNativelyDisableable(a) || axs.browserUtils.matchSelector(a, "fieldset>legend:first-of-type *")) { + return !1; + } + for (;null !== a;a = axs.dom.parentElement(a)) { + if (axs.utils.isNativelyDisableable(a) && a.hasAttribute("disabled")) { + return !0; } - b = axs.utils.parentElement(b); } - return!1; + return !1; }; axs.utils.isElementHidden = function(a) { if (!(a instanceof a.ownerDocument.defaultView.HTMLElement)) { - return!1; + return !1; } if (a.hasAttribute("chromevoxignoreariahidden")) { var b = !0 @@ -889,22 +1008,27 @@ axs.utils.isElementHidden = function(a) { return "none" == c.display || "hidden" == c.visibility ? !0 : a.hasAttribute("aria-hidden") && "true" == a.getAttribute("aria-hidden").toLowerCase() ? !b : !1; }; axs.utils.isElementOrAncestorHidden = function(a) { - return axs.utils.isElementHidden(a) ? !0 : axs.utils.parentElement(a) ? axs.utils.isElementOrAncestorHidden(axs.utils.parentElement(a)) : !1; + return axs.utils.isElementHidden(a) ? !0 : axs.dom.parentElement(a) ? axs.utils.isElementOrAncestorHidden(axs.dom.parentElement(a)) : !1; }; axs.utils.isInlineElement = function(a) { a = a.tagName.toUpperCase(); return axs.constants.InlineElements[a]; }; -axs.utils.getRoles = function(a) { - if (!a.hasAttribute("role")) { - return!1; +axs.utils.getRoles = function(a, b) { + if (!a || a.nodeType !== Node.ELEMENT_NODE || !a.hasAttribute("role") && !b) { + return null; } - a = a.getAttribute("role").split(" "); - for (var b = [], c = !0, d = 0;d < a.length;d++) { - var e = a[d]; - axs.constants.ARIA_ROLES[e] ? b.push({name:e, details:axs.constants.ARIA_ROLES[e], valid:!0}) : (b.push({name:e, valid:!1}), c = !1); + var c = a.getAttribute("role"); + !c && b && (c = axs.properties.getImplicitRole(a)); + if (!c) { + return null; } - return{roles:b, valid:c}; + for (var c = c.split(" "), d = {roles:[], valid:!1}, e = 0;e < c.length;e++) { + var f = c[e], g = axs.constants.ARIA_ROLES[f], f = {name:f}; + g && !g.abstract ? (f.details = g, d.applied || (d.applied = f), f.valid = d.valid = !0) : f.valid = !1; + d.roles.push(f); + } + return d; }; axs.utils.getAriaPropertyValue = function(a, b, c) { var d = a.replace(/^aria-/, ""), e = axs.constants.ARIA_PROPERTIES[d], d = {name:a, rawValue:b}; @@ -926,16 +1050,22 @@ axs.utils.getAriaPropertyValue = function(a, b, c) { } return d; case "integer": - ; - case "decimal": c = axs.utils.isValidNumber(b); if (!c.valid) { return d.valid = !1, d.reason = c.reason, d; } - Math.floor(c.value) != c.value ? (d.valid = !1, d.reason = "" + b + " is not a whole integer") : (d.valid = !0, d.value = c.value); + Math.floor(c.value) !== c.value ? (d.valid = !1, d.reason = "" + b + " is not a whole integer") : (d.valid = !0, d.value = c.value); return d; + case "decimal": + ; case "number": - c = axs.utils.isValidNumber(b), c.valid && (d.valid = !0, d.value = c.value); + c = axs.utils.isValidNumber(b); + d.valid = c.valid; + if (!c.valid) { + return d.reason = c.reason, d; + } + d.value = c.value; + return d; case "string": return d.valid = !0, d.value = b, d; case "token": @@ -975,12 +1105,15 @@ axs.utils.isValidIDRefValue = function(a, b) { return 0 == a.length ? {valid:!0, idref:a} : b.ownerDocument.getElementById(a) ? {valid:!0, idref:a} : {valid:!1, idref:a, reason:'No element with ID "' + a + '"'}; }; axs.utils.isValidNumber = function(a) { - try { - var b = JSON.parse(a); - } catch (c) { - return{valid:!1, value:a, reason:'"' + a + '" is not a number'}; + var b = {valid:!1, value:a, reason:'"' + a + '" is not a number'}; + if (!a) { + return b; + } + if (/^0x/i.test(a)) { + return b.reason = '"' + a + '" is not a decimal number', b; } - return "number" != typeof b ? {valid:!1, value:a, reason:'"' + a + '" is not a number'} : {valid:!0, value:b}; + a *= 1; + return isFinite(a) ? {valid:!0, value:a} : b; }; axs.utils.isElementImplicitlyFocusable = function(a) { var b = a.ownerDocument.defaultView; @@ -1027,7 +1160,9 @@ axs.utils.getQuerySelectorText = function(a) { } else { d = 1; } - return 1 == d ? axs.utils.getQuerySelectorText(a.parentNode) + " > " + b : axs.utils.getQuerySelectorText(a.parentNode) + " > " + b + ":nth-of-type(" + d + ")"; + if (1 == d) { + return axs.utils.getQuerySelectorText(a.parentNode) + " > " + b; + } } if (a.parentNode) { b = a.parentNode.children; @@ -1046,6 +1181,103 @@ axs.utils.getQuerySelectorText = function(a) { } return ""; }; +axs.utils.getAriaIdReferrers = function(a, b) { + var c = function(a) { + var b = axs.constants.ARIA_PROPERTIES[a]; + if (b) { + if ("idref" === b.valueType) { + return "[aria-" + a + "='" + d + "']"; + } + if ("idref_list" === b.valueType) { + return "[aria-" + a + "~='" + d + "']"; + } + } + return ""; + }; + if (!a) { + return null; + } + var d = a.id; + if (!d) { + return null; + } + d = d.replace(/'/g, "\\'"); + if (b) { + var e = b.replace(/^aria-/, ""), f = c(e); + if (f) { + return a.ownerDocument.querySelectorAll(f); + } + } else { + var g = []; + for (e in axs.constants.ARIA_PROPERTIES) { + (f = c(e)) && g.push(f); + } + return a.ownerDocument.querySelectorAll(g.join(",")); + } + return null; +}; +axs.utils.getHtmlIdReferrers = function(a) { + if (!a) { + return null; + } + var b = a.id; + if (!b) { + return null; + } + var b = b.replace(/'/g, "\\'"), c = "[contextmenu='{id}'] [itemref~='{id}'] button[form='{id}'] button[menu='{id}'] fieldset[form='{id}'] input[form='{id}'] input[list='{id}'] keygen[form='{id}'] label[for='{id}'] label[form='{id}'] menuitem[command='{id}'] object[form='{id}'] output[for~='{id}'] output[form='{id}'] select[form='{id}'] td[headers~='{id}'] textarea[form='{id}'] tr[headers~='{id}']".split(" ").map(function(a) { + return a.replace("{id}", b); + }); + return a.ownerDocument.querySelectorAll(c.join(",")); +}; +axs.utils.getIdReferrers = function(a) { + var b = [], c = axs.utils.getHtmlIdReferrers(a); + c && (b = b.concat(Array.prototype.slice.call(c))); + (c = axs.utils.getAriaIdReferrers(a)) && (b = b.concat(Array.prototype.slice.call(c))); + return b; +}; +axs.utils.getIdReferents = function(a, b) { + var c = [], d = a.replace(/^aria-/, ""), d = axs.constants.ARIA_PROPERTIES[d]; + if (!d || !b.hasAttribute(a)) { + return c; + } + d = d.valueType; + if ("idref_list" === d || "idref" === d) { + for (var d = b.ownerDocument, e = b.getAttribute(a), e = e.split(/\s+/), f = 0, g = e.length;f < g;f++) { + var h = d.getElementById(e[f]); + h && (c[c.length] = h); + } + } + return c; +}; +axs.utils.getAriaPropertiesByValueType = function(a) { + var b = {}, c; + for (c in axs.constants.ARIA_PROPERTIES) { + var d = axs.constants.ARIA_PROPERTIES[c]; + d && 0 <= a.indexOf(d.valueType) && (b[c] = d); + } + return b; +}; +axs.utils.getSelectorForAriaProperties = function(a) { + a = Object.keys(a).map(function(a) { + return "[aria-" + a + "]"; + }); + a.sort(); + return a.join(","); +}; +axs.utils.findDescendantsWithRole = function(a, b) { + if (!a || !b) { + return []; + } + var c = axs.properties.getSelectorForRole(b); + if (c && (c = a.querySelectorAll(c))) { + c = Array.prototype.map.call(c, function(a) { + return a; + }); + } else { + return []; + } + return c; +}; axs.properties = {}; axs.properties.TEXT_CONTENT_XPATH = './/text()[normalize-space(.)!=""]/parent::*[name()!="script"]'; axs.properties.getFocusProperties = function(a) { @@ -1078,7 +1310,7 @@ axs.properties.getHiddenReason = function(a) { var b = !0 } var c = window.getComputedStyle(a, null); - return "none" == c.display ? {property:"display: none", on:a} : "hidden" == c.visibility ? {property:"visibility: hidden", on:a} : a.hasAttribute("aria-hidden") && "true" == a.getAttribute("aria-hidden").toLowerCase() && !b ? {property:"aria-hidden", on:a} : axs.properties.getHiddenReason(axs.utils.parentElement(a)); + return "none" == c.display ? {property:"display: none", on:a} : "hidden" == c.visibility ? {property:"visibility: hidden", on:a} : a.hasAttribute("aria-hidden") && "true" == a.getAttribute("aria-hidden").toLowerCase() && !b ? {property:"aria-hidden", on:a} : axs.properties.getHiddenReason(axs.dom.parentElement(a)); }; axs.properties.getColorProperties = function(a) { var b = {}; @@ -1086,13 +1318,25 @@ axs.properties.getColorProperties = function(a) { return 0 == Object.keys(b).length ? null : b; }; axs.properties.hasDirectTextDescendant = function(a) { - for (var b = (a.nodeType == Node.DOCUMENT_NODE ? a : a.ownerDocument).evaluate(axs.properties.TEXT_CONTENT_XPATH, a, null, XPathResult.ANY_TYPE, null), c = !1, d = b.iterateNext();null != d;d = b.iterateNext()) { - if (d === a) { - c = !0; - break; + function b() { + for (var b = c.evaluate(axs.properties.TEXT_CONTENT_XPATH, a, null, XPathResult.ANY_TYPE, null), e = b.iterateNext();null != e;e = b.iterateNext()) { + if (e === a) { + return !0; + } } + return !1; } - return c; + var c; + c = a.nodeType == Node.DOCUMENT_NODE ? a : a.ownerDocument; + return c.evaluate ? b() : function() { + for (var b = c.createTreeWalker(a, NodeFilter.SHOW_TEXT, null, !1);b.nextNode();) { + var e = b.currentNode, f = e.parentNode.tagName.toLowerCase(); + if (e.nodeValue.trim() && "script" !== f && a !== e) { + return !0; + } + } + return !1; + }(); }; axs.properties.getContrastRatioProperties = function(a) { if (!axs.properties.hasDirectTextDescendant(a)) { @@ -1102,22 +1346,28 @@ axs.properties.getContrastRatioProperties = function(a) { if (!d) { return null; } - b.backgroundColor = axs.utils.colorToString(d); + b.backgroundColor = axs.color.colorToString(d); var e = axs.utils.getFgColor(c, a, d); - b.foregroundColor = axs.utils.colorToString(e); + b.foregroundColor = axs.color.colorToString(e); a = axs.utils.getContrastRatioForElementWithComputedStyle(c, a); if (!a) { return null; } b.value = a.toFixed(2); axs.utils.isLowContrast(a, c) && (b.alert = !0); - (c = axs.utils.suggestColors(d, e, a, c)) && Object.keys(c).length && (b.suggestedColors = c); + var f = axs.utils.isLargeFont(c) ? 3 : 4.5, c = axs.utils.isLargeFont(c) ? 4.5 : 7, g = {}; + f > a && (g.AA = f); + c > a && (g.AAA = c); + if (!Object.keys(g).length) { + return b; + } + (d = axs.color.suggestColors(d, e, g)) && Object.keys(d).length && (b.suggestedColors = d); return b; }; axs.properties.findTextAlternatives = function(a, b, c, d) { var e = c || !1; - c = axs.utils.asElement(a); - if (!c || !e && !d && axs.utils.isElementOrAncestorHidden(c)) { + c = axs.dom.asElement(a); + if (!c || !d && axs.utils.isElementOrAncestorHidden(c)) { return null; } if (a.nodeType == Node.TEXT_NODE) { @@ -1125,17 +1375,23 @@ axs.properties.findTextAlternatives = function(a, b, c, d) { } a = null; e || (a = axs.properties.getTextFromAriaLabelledby(c, b)); - c.hasAttribute("aria-label") && (d = {type:"text"}, d.text = c.getAttribute("aria-label"), d.lastWord = axs.properties.getLastWord(d.text), a ? d.unused = !0 : e && axs.utils.elementIsHtmlControl(c) || (a = d.text), b.ariaLabel = d); + if (c.hasAttribute("aria-label")) { + var f = {type:"text"}; + f.text = c.getAttribute("aria-label"); + f.lastWord = axs.properties.getLastWord(f.text); + a ? f.unused = !0 : e && axs.utils.elementIsHtmlControl(c) || (a = f.text); + b.ariaLabel = f; + } c.hasAttribute("role") && "presentation" == c.getAttribute("role") || (a = axs.properties.getTextFromHostLanguageAttributes(c, b, a, e)); if (e && axs.utils.elementIsHtmlControl(c)) { - d = c.ownerDocument.defaultView; - if (c instanceof d.HTMLInputElement) { - var f = c; - "text" == f.type && f.value && 0 < f.value.length && (b.controlValue = {text:f.value}); - "range" == f.type && (b.controlValue = {text:f.value}); + f = c.ownerDocument.defaultView; + if (c instanceof f.HTMLInputElement) { + var g = c; + "text" == g.type && g.value && 0 < g.value.length && (b.controlValue = {text:g.value}); + "range" == g.type && (b.controlValue = {text:g.value}); } - c instanceof d.HTMLSelectElement && (b.controlValue = {text:c.value}); - b.controlValue && (d = b.controlValue, a ? d.unused = !0 : a = d.text); + c instanceof f.HTMLSelectElement && (b.controlValue = {text:c.value}); + b.controlValue && (f = b.controlValue, a ? f.unused = !0 : a = f.text); } if (e && axs.utils.elementIsAriaWidget(c)) { e = c.getAttribute("role"); @@ -1144,43 +1400,39 @@ axs.properties.findTextAlternatives = function(a, b, c, d) { 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")}); } if ("menu" == e) { - var g = c.querySelectorAll("[role=menuitemcheckbox], [role=menuitemradio]"); - d = []; - for (f = 0;f < g.length;f++) { - "true" == g[f].getAttribute("aria-checked") && d.push(g[f]); + for (var h = c.querySelectorAll("[role=menuitemcheckbox], [role=menuitemradio]"), f = [], g = 0;g < h.length;g++) { + "true" == h[g].getAttribute("aria-checked") && f.push(h[g]); } - if (0 < d.length) { - g = ""; - for (f = 0;f < d.length;f++) { - g += axs.properties.findTextAlternatives(d[f], {}, !0), f < d.length - 1 && (g += ", "); + if (0 < f.length) { + h = ""; + for (g = 0;g < f.length;g++) { + h += axs.properties.findTextAlternatives(f[g], {}, !0), g < f.length - 1 && (h += ", "); } - b.controlValue = {text:g}; + b.controlValue = {text:h}; } } if ("combobox" == e || "select" == e) { b.controlValue = {text:"TODO"}; } - b.controlValue && (d = b.controlValue, a ? d.unused = !0 : a = d.text); + b.controlValue && (f = b.controlValue, a ? f.unused = !0 : a = f.text); } - d = !0; - c.hasAttribute("role") && (e = c.getAttribute("role"), (e = axs.constants.ARIA_ROLES[e]) && (!e.namefrom || 0 > e.namefrom.indexOf("contents")) && (d = !1)); - (e = axs.properties.getTextFromDescendantContent(c)) && d && (d = {type:"text"}, d.text = e, d.lastWord = axs.properties.getLastWord(d.text), a ? d.unused = !0 : a = e, b.content = d); - c.hasAttribute("title") && (e = {type:"string", valid:!0}, e.text = c.getAttribute("title"), e.lastWord = axs.properties.getLastWord(e.lastWord), a ? e.unused = !0 : a = e.text, b.title = e); + f = !0; + c.hasAttribute("role") && (e = c.getAttribute("role"), (e = axs.constants.ARIA_ROLES[e]) && (!e.namefrom || 0 > e.namefrom.indexOf("contents")) && (f = !1)); + (d = axs.properties.getTextFromDescendantContent(c, d)) && f && (e = {type:"text"}, e.text = d, e.lastWord = axs.properties.getLastWord(e.text), a ? e.unused = !0 : a = d, b.content = e); + 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); return 0 == Object.keys(b).length && null == a ? null : a; }; -axs.properties.getTextFromDescendantContent = function(a) { - var b = a.childNodes; - a = []; - for (var c = 0;c < b.length;c++) { - var d = axs.properties.findTextAlternatives(b[c], {}, !0); - d && a.push(d.trim()); +axs.properties.getTextFromDescendantContent = function(a, b) { + for (var c = a.childNodes, d = [], e = 0;e < c.length;e++) { + var f = axs.properties.findTextAlternatives(c[e], {}, !0, b); + f && d.push(f.trim()); } - if (a.length) { - b = ""; - for (c = 0;c < a.length;c++) { - b = [b, a[c]].join(" ").trim(); + if (d.length) { + c = ""; + for (e = 0;e < d.length;e++) { + c = [c, d[e]].join(" ").trim(); } - return b; + return c; } return null; }; @@ -1193,22 +1445,18 @@ axs.properties.getTextFromAriaLabelledby = function(a, b) { var k = {type:"element"}, m = d[h]; k.value = m; var l = document.getElementById(m); - 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]}); + l ? (k.valid = !0, k.text = axs.properties.findTextAlternatives(l, {}, !0, !0), k.lastWord = axs.properties.getLastWord(k.text), f.push(k.text), k.element = l) : (k.valid = !1, e.valid = !1, k.errorMessage = {messageKey:"noElementWithId", args:[m]}); g.push(k); } 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); return c; }; axs.properties.getTextFromHostLanguageAttributes = function(a, b, c, d) { - if (axs.browserUtils.matchSelector(a, "img")) { - if (a.hasAttribute("alt")) { - var e = {type:"string", valid:!0}; - e.text = a.getAttribute("alt"); - c ? e.unused = !0 : c = e.text; - b.alt = e; - } else { - e = {valid:!1, errorMessage:"No alt value provided"}, b.alt = e, e = a.src, "string" == typeof e && (c = e.split("/").pop(), b.filename = {text:c}); - } + if (axs.browserUtils.matchSelector(a, "img") && a.hasAttribute("alt")) { + var e = {type:"string", valid:!0}; + e.text = a.getAttribute("alt"); + c ? e.unused = !0 : c = e.text; + b.alt = e; } if (axs.browserUtils.matchSelector(a, 'input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), video:not([disabled])') && !d) { if (a.hasAttribute("id")) { @@ -1221,7 +1469,7 @@ axs.properties.getTextFromHostLanguageAttributes = function(a, b, c, d) { } 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); } - d = axs.utils.parentElement(a); + d = axs.dom.parentElement(a); for (e = {};d;) { if ("label" == d.tagName.toLowerCase() && (f = d, f.control == a)) { e.type = "element"; @@ -1230,9 +1478,10 @@ axs.properties.getTextFromHostLanguageAttributes = function(a, b, c, d) { e.element = f; break; } - d = axs.utils.parentElement(d); + d = axs.dom.parentElement(d); } e.text && (c ? e.unused = !0 : c = e.text, b.labelWrapped = e); + axs.browserUtils.matchSelector(a, 'input[type="image"]') && a.hasAttribute("alt") && (e = {type:"string", valid:!0}, e.text = a.getAttribute("alt"), c ? e.unused = !0 : c = e.text, b.alt = e); Object.keys(b).length || (b.noLabel = !0); } return c; @@ -1245,18 +1494,13 @@ axs.properties.getLastWord = function(a) { return a.substring(b > c ? b : c); }; axs.properties.getTextProperties = function(a) { - var b = {}; - a = axs.properties.findTextAlternatives(a, b, !1, !0); - if (0 == Object.keys(b).length) { - if (!a) { - return null; - } - b.hasProperties = !1; - } else { - b.hasProperties = !0; + var b = {}, c = axs.properties.findTextAlternatives(a, b, !1, !0); + if (0 == Object.keys(b).length && ((a = axs.dom.asElement(a)) && axs.browserUtils.matchSelector(a, "img") && (b.alt = {valid:!1, errorMessage:"No alt value provided"}, a = a.src, "string" == typeof a && (c = a.split("/").pop(), b.filename = {text:c})), !c)) { + return null; } - b.computedText = a; - b.lastWord = axs.properties.getLastWord(a); + b.hasProperties = Boolean(Object.keys(b).length); + b.computedText = c; + b.lastWord = axs.properties.getLastWord(c); return b; }; axs.properties.getAriaProperties = function(a) { @@ -1289,11 +1533,11 @@ axs.properties.getAriaProperties = function(a) { return 0 < Object.keys(b).length ? b : null; }; axs.properties.getGlobalAriaProperties = function(a) { - for (var b = {}, c = 0;c < axs.constants.GLOBAL_PROPERTIES.length;c++) { - var d = axs.constants.GLOBAL_PROPERTIES[c]; - if (a.hasAttribute(d)) { - var e = a.getAttribute(d); - b[d] = axs.utils.getAriaPropertyValue(d, e, a); + var b = {}, c; + for (c in axs.constants.GLOBAL_PROPERTIES) { + if (a.hasAttribute(c)) { + var d = a.getAttribute(c); + b[c] = axs.utils.getAriaPropertyValue(c, d, a); } } return b; @@ -1328,9 +1572,9 @@ axs.properties.getTrackElements = function(a, b) { return d; }; axs.properties.getAllProperties = function(a) { - var b = axs.utils.asElement(a); + var b = axs.dom.asElement(a); if (!b) { - return{}; + return {}; } var c = {}; c.ariaProperties = axs.properties.getAriaProperties(b); @@ -1340,6 +1584,80 @@ axs.properties.getAllProperties = function(a) { c.videoProperties = axs.properties.getVideoProperties(b); return c; }; +(function() { + function a(a) { + if (!a) { + return null; + } + var c = a.tagName; + if (!c) { + return null; + } + c = c.toUpperCase(); + c = axs.constants.TAG_TO_IMPLICIT_SEMANTIC_INFO[c]; + if (!c || !c.length) { + return null; + } + for (var d = null, e = 0, f = c.length;e < f;e++) { + var g = c[e]; + if (g.selector) { + if (axs.browserUtils.matchSelector(a, g.selector)) { + return g; + } + } else { + d = g; + } + } + return d; + } + axs.properties.getImplicitRole = function(b) { + return (b = a(b)) ? b.role : ""; + }; + axs.properties.canTakeAriaAttributes = function(b) { + return (b = a(b)) ? !b.reserved : !0; + }; +})(); +axs.properties.getNativelySupportedAttributes = function(a) { + var b = []; + if (!a) { + return b; + } + a = a.cloneNode(!1); + for (var c = Object.keys(axs.constants.ARIA_TO_HTML_ATTRIBUTE), d = 0;d < c.length;d++) { + var e = c[d]; + axs.constants.ARIA_TO_HTML_ATTRIBUTE[e] in a && (b[b.length] = e); + } + return b; +}; +(function() { + var a = {}; + axs.properties.getSelectorForRole = function(b) { + if (!b) { + return ""; + } + if (a[b] && a.hasOwnProperty(b)) { + return a[b]; + } + var c = ['[role="' + b + '"]']; + Object.keys(axs.constants.TAG_TO_IMPLICIT_SEMANTIC_INFO).forEach(function(a) { + var e = axs.constants.TAG_TO_IMPLICIT_SEMANTIC_INFO[a]; + if (e && e.length) { + for (var f = 0;f < e.length;f++) { + var g = e[f]; + if (g.role === b) { + if (g.selector) { + c[c.length] = g.selector; + } else { + c[c.length] = a; + break; + } + } + } + } + }); + return a[b] = c.join(","); + }; +})(); axs.AuditRule = function(a) { for (var b = !0, c = [], d = 0;d < axs.AuditRule.requiredFields.length;d++) { var e = axs.AuditRule.requiredFields[d]; @@ -1363,69 +1681,59 @@ axs.AuditRule.prototype.addElement = function(a, b) { a.push(b); }; axs.AuditRule.collectMatchingElements = function(a, b, c, d) { - if (a.nodeType == Node.ELEMENT_NODE) { - var e = a - } - e && b.call(null, e) && c.push(e); - if (e) { - var f = e.shadowRoot || e.webkitShadowRoot; - if (f) { - axs.AuditRule.collectMatchingElements(f, b, c, f); - return; - } - } - if (e && "content" == e.localName) { - for (e = e.getDistributedNodes(), a = 0;a < e.length;a++) { - axs.AuditRule.collectMatchingElements(e[a], b, c, d); - } - } else { - if (e && "shadow" == e.localName) { - a = e, d ? (d = d.olderShadowRoot || a.olderShadowRoot) && axs.AuditRule.collectMatchingElements(d, b, c, d) : console.warn("ShadowRoot not provided for", e); - } else { - for (e = a.firstChild;null != e;) { - axs.AuditRule.collectMatchingElements(e, b, c, d), e = e.nextSibling; + axs.dom.composedTreeSearch(a, null, {preorder:function(a) { + if (d) { + for (var f = 0;f < d.length;f++) { + if (axs.browserUtils.matchSelector(a, d[f])) { + return !1; + } } } - } + b(a) && c.push(a); + return !0; + }}); }; axs.AuditRule.prototype.run = function(a) { a = a || {}; - var b = "ignoreSelectors" in a ? a.ignoreSelectors : [], c = "maxResults" in a ? a.maxResults : null, d = []; - axs.AuditRule.collectMatchingElements("scope" in a ? a.scope : document, this.relevantElementMatcher_, d); - var e = []; - if (!d.length) { - return{result:axs.constants.AuditResult.NA}; - } - for (a = 0;a < d.length && !(null != c && e.length >= c);a++) { - var f = d[a], g; - a: { - g = f; - for (var h = 0;h < b.length;h++) { - if (axs.browserUtils.matchSelector(g, b[h])) { - g = !0; - break a; - } - } - g = !1; - } - !g && this.test_(f) && this.addElement(e, f); + var b = "maxResults" in a ? a.maxResults : null, c = []; + axs.AuditRule.collectMatchingElements("scope" in a ? a.scope : document, this.relevantElementMatcher_, c, a.ignoreSelectors); + var d = []; + if (!c.length) { + return {result:axs.constants.AuditResult.NA}; } - b = {result:e.length ? axs.constants.AuditResult.FAIL : axs.constants.AuditResult.PASS, elements:e}; - a < d.length && (b.resultsTruncated = !0); - return b; -}; -axs.AuditRule.specs = {}; -axs.AuditRules = {}; -axs.AuditRules.getRule = function(a) { - if (!axs.AuditRules.rules) { - axs.AuditRules.rules = {}; - for (var b in axs.AuditRule.specs) { - var c = axs.AuditRule.specs[b], d = new axs.AuditRule(c); - axs.AuditRules.rules[c.name] = d; - } + for (var e = 0;e < c.length && !(null != b && d.length >= b);e++) { + var f = c[e]; + this.test_(f, a.config) && this.addElement(d, f); } - return axs.AuditRules.rules[a]; + a = {result:d.length ? axs.constants.AuditResult.FAIL : axs.constants.AuditResult.PASS, elements:d}; + e < c.length && (a.resultsTruncated = !0); + return a; }; +axs.AuditRules = {}; +(function() { + var a = {}, b = {}; + axs.AuditRules.specs = {}; + axs.AuditRules.addRule = function(c) { + var d = new axs.AuditRule(c); + if (d.code in b) { + throw Error('Can not add audit rule with same code: "' + d.code + '"'); + } + if (d.name in a) { + throw Error('Can not add audit rule with same name: "' + d.name + '"'); + } + a[d.name] = b[d.code] = d; + axs.AuditRules.specs[c.name] = c; + }; + axs.AuditRules.getRule = function(c) { + return a[c] || b[c] || null; + }; + axs.AuditRules.getRules = function(b) { + var d = Object.keys(a); + return b ? d : d.map(function(a) { + return this.getRule(a); + }, axs.AuditRules); + }; +})(); axs.AuditResults = function() { this.errors_ = []; this.warnings_ = []; @@ -1467,11 +1775,15 @@ axs.AuditResults.prototype.toString = function() { }; goog.exportProperty(axs.AuditResults.prototype, "toString", axs.AuditResults.prototype.toString); axs.Audit = {}; -axs.AuditConfiguration = function() { +axs.AuditConfiguration = function(a) { + null == a && (a = {}); this.rules_ = {}; this.maxResults = this.auditRulesToIgnore = this.auditRulesToRun = this.scope = null; this.withConsoleApi = !1; this.showUnsupportedRulesWarning = !0; + for (var b in this) { + this.hasOwnProperty(b) && b in a && (this[b] = a[b]); + } goog.exportProperty(this, "scope", this.scope); goog.exportProperty(this, "auditRulesToRun", this.auditRulesToRun); goog.exportProperty(this, "auditRulesToIgnore", this.auditRulesToIgnore); @@ -1490,21 +1802,26 @@ axs.AuditConfiguration.prototype = {ignoreSelectors:function(a, b) { this.rules_[a].severity = b; }, getSeverity:function(a) { return a in this.rules_ && "severity" in this.rules_[a] ? this.rules_[a].severity : null; +}, setRuleConfig:function(a, b) { + a in this.rules_ || (this.rules_[a] = {}); + this.rules_[a].config = b; +}, getRuleConfig:function(a) { + return a in this.rules_ && "config" in this.rules_[a] ? this.rules_[a].config : null; }}; goog.exportProperty(axs.AuditConfiguration.prototype, "ignoreSelectors", axs.AuditConfiguration.prototype.ignoreSelectors); goog.exportProperty(axs.AuditConfiguration.prototype, "getIgnoreSelectors", axs.AuditConfiguration.prototype.getIgnoreSelectors); axs.Audit.unsupportedRulesWarningShown = !1; axs.Audit.getRulesCannotRun = function(a) { - return a.withConsoleApi ? [] : Object.keys(axs.AuditRule.specs).filter(function(a) { - return axs.AuditRules.getRule(a).requiresConsoleAPI; + return a.withConsoleApi ? [] : axs.AuditRules.getRules().filter(function(a) { + return a.requiresConsoleAPI; }).map(function(a) { - return axs.AuditRules.getRule(a).code; + return a.code; }); }; 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); + d = a.auditRulesToRun && 0 < a.auditRulesToRun.length ? a.auditRulesToRun : axs.AuditRules.getRules(!0); if (a.auditRulesToIgnore) { for (var e = 0;e < a.auditRulesToIgnore.length;e++) { var f = a.auditRulesToIgnore[e]; @@ -1519,6 +1836,8 @@ axs.Audit.run = function(a) { if (0 < k.length || a.scope) { h.ignoreSelectors = k; } + k = a.getRuleConfig(g.name); + null != k && (h.config = k); a.scope && (h.scope = a.scope); a.maxResults && (h.maxResults = a.maxResults); h = g.run.call(g, h); @@ -1559,17 +1878,72 @@ axs.Audit.accessibilityErrorMessage = function(a) { return b; }; goog.exportSymbol("axs.Audit.accessibilityErrorMessage", axs.Audit.accessibilityErrorMessage); -axs.AuditRule.specs.audioWithoutControls = {name:"audioWithoutControls", heading:"Audio elements should have controls", url:"", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { - return axs.browserUtils.matchSelector(a, "audio[autoplay]"); +axs.AuditRules.addRule({name:"ariaOnReservedElement", heading:"This element does not support ARIA roles, states and properties", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_12", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { + return !axs.properties.canTakeAriaAttributes(a); }, test:function(a) { - return!a.querySelectorAll("[controls]").length && 3 < a.duration; -}, code:"AX_AUDIO_01"}; -axs.AuditRule.specs.badAriaAttributeValue = {name:"badAriaAttributeValue", heading:"ARIA state and property values must be valid", url:"", severity:axs.constants.Severity.SEVERE, relevantElementMatcher:function(a) { - var b = "", c; - for (c in axs.constants.ARIA_PROPERTIES) { - b += "[aria-" + c + "],"; + return null !== axs.properties.getAriaProperties(a); +}, code:"AX_ARIA_12"}); +axs.AuditRules.addRule({name:"ariaOwnsDescendant", heading:"aria-owns should not be used if ownership is implicit in the DOM", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_06", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { + return axs.browserUtils.matchSelector(a, "[aria-owns]"); +}, test:function(a) { + return axs.utils.getIdReferents("aria-owns", a).some(function(b) { + return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_CONTAINED_BY; + }); +}, code:"AX_ARIA_06"}); +axs.AuditRules.addRule({name:"ariaRoleNotScoped", heading:"Elements with ARIA roles must be in the correct scope", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_09", severity:axs.constants.Severity.SEVERE, relevantElementMatcher:function(a) { + return axs.browserUtils.matchSelector(a, "[role]"); +}, test:function(a) { + var b = axs.utils.getRoles(a); + if (!b || !b.applied) { + return !1; + } + b = b.applied.details.scope; + if (!b || 0 === b.length) { + return !1; + } + for (var c = a;c = axs.dom.parentElement(c);) { + var d = axs.utils.getRoles(c, !0); + if (d && d.applied && 0 <= b.indexOf(d.applied.name)) { + return !1; + } } - b = b.substring(0, b.length - 1); + if (a = axs.utils.getAriaIdReferrers(a, "aria-owns")) { + for (c = 0;c < a.length;c++) { + if ((d = axs.utils.getRoles(a[c], !0)) && d.applied && 0 <= b.indexOf(d.applied.name)) { + return !1; + } + } + } + return !0; +}, code:"AX_ARIA_09"}); +axs.AuditRules.addRule({name:"audioWithoutControls", heading:"Audio elements should have controls", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_audio_01", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { + return axs.browserUtils.matchSelector(a, "audio[autoplay]"); +}, test:function(a) { + return !a.querySelectorAll("[controls]").length && 3 < a.duration; +}, code:"AX_AUDIO_01"}); +(function() { + var a = /^aria\-/; + axs.AuditRules.addRule({name:"badAriaAttribute", heading:"This element has an invalid ARIA attribute", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_11", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(b) { + b = b.attributes; + for (var c = 0, d = b.length;c < d;c++) { + if (a.test(b[c].name)) { + return !0; + } + } + return !1; + }, test:function(b) { + b = b.attributes; + for (var c = 0, d = b.length;c < d;c++) { + var e = b[c].name; + if (a.test(e) && (e = e.replace(a, ""), !axs.constants.ARIA_PROPERTIES.hasOwnProperty(e))) { + return !0; + } + } + return !1; + }, code:"AX_ARIA_11"}); +})(); +axs.AuditRules.addRule({name:"badAriaAttributeValue", heading:"ARIA state and property values must be valid", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_04", severity:axs.constants.Severity.SEVERE, relevantElementMatcher:function(a) { + var b = axs.utils.getSelectorForAriaProperties(axs.constants.ARIA_PROPERTIES); return axs.browserUtils.matchSelector(a, b); }, test:function(a) { for (var b in axs.constants.ARIA_PROPERTIES) { @@ -1577,135 +1951,328 @@ axs.AuditRule.specs.badAriaAttributeValue = {name:"badAriaAttributeValue", headi if (a.hasAttribute(c)) { var d = a.getAttribute(c); if (!axs.utils.getAriaPropertyValue(c, d, a).valid) { - return!0; + return !0; } } } - return!1; -}, code:"AX_ARIA_04"}; -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, relevantElementMatcher:function(a) { + return !1; +}, code:"AX_ARIA_04"}); +axs.AuditRules.addRule({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", severity:axs.constants.Severity.SEVERE, relevantElementMatcher:function(a) { return axs.browserUtils.matchSelector(a, "[role]"); }, test:function(a) { - return!axs.utils.getRoles(a).valid; -}, code:"AX_ARIA_01"}; -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, relevantElementMatcher:function(a) { - if (!axs.browserUtils.matchSelector(a, 'input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), video:not([disabled])')) { - return!1; + return !axs.utils.getRoles(a).valid; +}, code:"AX_ARIA_01"}); +axs.AuditRules.addRule({name:"controlsWithoutLabel", heading:"Controls and media elements should have labels", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_text_01", severity:axs.constants.Severity.SEVERE, relevantElementMatcher:function(a) { + if (!axs.browserUtils.matchSelector(a, 'input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), video:not([disabled])') || "presentation" == a.getAttribute("role")) { + return !1; } if (0 <= a.tabIndex) { - return!0; + return !0; } - for (a = axs.utils.parentElement(a);null != a;a = axs.utils.parentElement(a)) { + for (a = axs.dom.parentElement(a);null != a;a = axs.dom.parentElement(a)) { if (axs.utils.elementIsAriaWidget(a)) { - return!1; + return !1; } } - return!0; + return !0; +}, test:function(a) { + if (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 || axs.utils.hasLabel(a)) { + return !1; + } + a = axs.properties.findTextAlternatives(a, {}); + return null === a || "" === a.trim() ? !0 : !1; +}, code:"AX_TEXT_01", ruleName:"Controls and media elements should have labels"}); +axs.AuditRules.addRule({name:"duplicateId", heading:"Any ID referred to via an IDREF must be unique in the DOM", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_html_02", severity:axs.constants.Severity.SEVERE, relevantElementMatcher:function(a) { + return a.hasAttribute("id") ? axs.utils.getIdReferrers(a).some(function(a) { + return !axs.utils.isElementOrAncestorHidden(a); + }) : !1; }, test:function(a) { - 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) ? !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://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, relevantElementMatcher:function(a) { + var b = "[id='" + a.id.replace(/'/g, "\\'") + "']"; + return 1 < a.ownerDocument.querySelectorAll(b).length; +}, code:"AX_HTML_02"}); +axs.AuditRules.addRule({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", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { if (!axs.browserUtils.matchSelector(a, axs.utils.FOCUSABLE_ELEMENTS_SELECTOR)) { - return!1; + return !1; } if (0 <= a.tabIndex) { - return!0; + return !0; } - for (a = axs.utils.parentElement(a);null != a;a = axs.utils.parentElement(a)) { - if (axs.utils.elementIsAriaWidget(a)) { - return!1; + for (var b = axs.dom.parentElement(a);null != b;b = axs.dom.parentElement(b)) { + if (axs.utils.elementIsAriaWidget(b)) { + return !1; } } - return!0; + a = axs.properties.findTextAlternatives(a, {}); + return null === a || "" === a.trim() ? !1 : !0; }, test:function(a) { if (axs.utils.isElementOrAncestorHidden(a)) { - return!1; + return !1; } a.focus(); - return!axs.utils.elementIsVisible(a); -}, code:"AX_FOCUS_01"}; -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, relevantElementMatcher:function(a) { - return axs.browserUtils.matchSelector(a, "img") && !axs.utils.isElementOrAncestorHidden(a); + return !axs.utils.elementIsVisible(a); +}, code:"AX_FOCUS_01"}); +axs.AuditRules.addRule({name:"humanLangMissing", heading:"The web page should have the content's human language indicated in the markup", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_html_01", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { + return a instanceof a.ownerDocument.defaultView.HTMLHtmlElement; }, test:function(a) { - return!a.hasAttribute("alt") && "presentation" != a.getAttribute("role"); -}, code:"AX_TEXT_02"}; -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, relevantElementMatcher:function(a) { - return axs.browserUtils.matchSelector(a, "a"); + return a.lang ? !1 : !0; +}, code:"AX_HTML_01"}); +axs.AuditRules.addRule({name:"imagesWithoutAltText", heading:"Images should have a text alternative or presentational role", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_text_02", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { + return axs.browserUtils.matchSelector(a, "img") && !axs.utils.isElementOrAncestorHidden(a); }, test:function(a) { - return/^\s*click\s*here\s*[^a-z]?$/i.test(a.textContent); -}, code:"AX_TITLE_01"}; -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, relevantElementMatcher:function(a) { - return axs.properties.hasDirectTextDescendant(a); + if (a.hasAttribute("alt") && "" == a.alt || "presentation" == a.getAttribute("role")) { + return !1; + } + var b = {}; + axs.properties.findTextAlternatives(a, b); + return 0 == Object.keys(b).length ? !0 : !1; +}, code:"AX_TEXT_02"}); +axs.AuditRules.addRule({name:"linkWithUnclearPurpose", heading:"The purpose of each link should be clear from the link text", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_text_04", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { + return axs.browserUtils.matchSelector(a, "a[href]") && !axs.utils.isElementOrAncestorHidden(a); +}, test:function(a, b) { + for (var c = b || {}, d = c.blacklistPhrases || [], e = /\s+/, f = 0;f < d.length;f++) { + var g = "^\\s*" + d[f].trim().replace(e, "\\s*") + "s*[^a-z]$"; + if ((new RegExp(g, "i")).test(a.textContent)) { + return !0; + } + } + c = c.stopwords || "click tap go here learn more this page link about".split(" "); + d = axs.properties.findTextAlternatives(a, {}); + if (null === d || "" === d.trim()) { + return !0; + } + d = d.replace(/[^a-zA-Z ]/g, ""); + for (f = 0;f < c.length;f++) { + if (d = d.replace(new RegExp("\\b" + c[f] + "\\b", "ig"), ""), "" == d.trim()) { + return !0; + } + } + return !1; +}, code:"AX_TEXT_04"}); +axs.AuditRules.addRule({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", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { + return axs.properties.hasDirectTextDescendant(a) && !axs.utils.isElementDisabled(a); }, 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.mainRoleOnInappropriateElement = {name:"mainRoleOnInappropriateElement", heading:"role=main should only appear on significant elements", url:"", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { + return (a = axs.utils.getContrastRatioForElementWithComputedStyle(b, a)) && axs.utils.isLowContrast(a, b); +}, code:"AX_COLOR_01"}); +axs.AuditRules.addRule({name:"mainRoleOnInappropriateElement", heading:"role=main should only appear on significant elements", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_05", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { return axs.browserUtils.matchSelector(a, "[role~=main]"); }, test:function(a) { if (axs.utils.isInlineElement(a)) { - return!0; + return !0; } a = axs.properties.getTextFromDescendantContent(a); - return!a || 50 > a.length ? !0 : !1; -}, code:"AX_ARIA_04"}; -axs.AuditRule.specs.elementsWithMeaningfulBackgroundImage = {name:"elementsWithMeaningfulBackgroundImage", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { - return!axs.utils.isElementOrAncestorHidden(a); -}, 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) { + return !a || 50 > a.length ? !0 : !1; +}, code:"AX_ARIA_05"}); +axs.AuditRules.addRule({name:"elementsWithMeaningfulBackgroundImage", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { + return !axs.utils.isElementOrAncestorHidden(a); +}, heading:"Meaningful images should not be used in element backgrounds", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_image_01", test:function(a) { if (a.textContent && 0 < a.textContent.length) { - return!1; + return !1; } a = window.getComputedStyle(a, null); var b = a.backgroundImage; if (!b || "undefined" === b || "none" === b || 0 != b.indexOf("url")) { - return!1; + 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://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, relevantElementMatcher:function(a) { - return axs.browserUtils.matchSelector(a, "[aria-labelledby]"); +}, code:"AX_IMAGE_01"}); +axs.AuditRules.addRule({name:"multipleAriaOwners", heading:"An element's ID must not be present in more that one aria-owns attribute at any time", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_07", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { + return axs.browserUtils.matchSelector(a, "[aria-owns]"); +}, test:function(a) { + return axs.utils.getIdReferents("aria-owns", a).some(function(a) { + return 1 < axs.utils.getAriaIdReferrers(a, "aria-owns").length; + }); +}, code:"AX_ARIA_07"}); +axs.AuditRules.addRule({name:"multipleLabelableElementsPerLabel", heading:"A label element may not have labelable descendants other than its labeled control.", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#-ax_text_03--labels-should-only-contain-one-labelable-element", severity:axs.constants.Severity.SEVERE, relevantElementMatcher:function(a) { + return axs.browserUtils.matchSelector(a, "label"); +}, test:function(a) { + if (1 < a.querySelectorAll(axs.utils.LABELABLE_ELEMENTS_SELECTOR).length) { + return !0; + } +}, code:"AX_TEXT_03"}); +axs.AuditRules.addRule({name:"nonExistentAriaRelatedElement", heading:"ARIA attributes which refer to other elements by ID should refer to elements which exist in the DOM", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_02", severity:axs.constants.Severity.SEVERE, relevantElementMatcher:function(a) { + var b = axs.utils.getAriaPropertiesByValueType(["idref", "idref_list"]), b = axs.utils.getSelectorForAriaProperties(b); + return axs.browserUtils.matchSelector(a, b); }, test:function(a) { - a = a.getAttribute("aria-labelledby").split(/\s+/); - for (var b = 0;b < a.length;b++) { - if (!document.getElementById(a[b])) { - return!0; + for (var b = axs.utils.getAriaPropertiesByValueType(["idref", "idref_list"]), b = axs.utils.getSelectorForAriaProperties(b).split(","), c = 0, d = b.length;c < d;c++) { + var e = b[c]; + if (axs.browserUtils.matchSelector(a, e)) { + var e = e.match(/aria-[^\]]+/)[0], f = a.getAttribute(e); + if (!axs.utils.getAriaPropertyValue(e, f, a).valid) { + return !0; + } } } - return!1; -}, code:"AX_ARIA_02"}; -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, relevantElementMatcher:function(a) { + return !1; +}, code:"AX_ARIA_02"}); +axs.AuditRules.addRule({name:"pageWithoutTitle", heading:"The web page should have a title that describes topic or purpose", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_title_01", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { return "html" == a.tagName.toLowerCase(); }, test:function(a) { a = a.querySelector("head"); return a ? (a = a.querySelector("title")) ? !a.textContent : !0 : !0; -}, code:"AX_TITLE_01"}; -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, relevantElementMatcher:function(a) { +}, code:"AX_TITLE_01"}); +axs.AuditRules.addRule({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", severity:axs.constants.Severity.SEVERE, relevantElementMatcher:function(a) { return axs.browserUtils.matchSelector(a, "[role]"); }, test:function(a) { var b = axs.utils.getRoles(a); if (!b.valid) { - return!1; + return !1; } for (var c = 0;c < b.roles.length;c++) { var d = b.roles[c].details.requiredPropertiesSet, e; for (e in d) { - if (d = e.replace(/^aria-/, ""), !("defaultValue" in axs.constants.ARIA_PROPERTIES[d] || a.hasAttribute(e))) { - return!0; + if (d = e.replace(/^aria-/, ""), !("defaultValue" in axs.constants.ARIA_PROPERTIES[d] || a.hasAttribute(e)) && 0 > axs.properties.getNativelySupportedAttributes(a).indexOf(e)) { + return !0; } } } -}, code:"AX_ARIA_03"}; -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, relevantElementMatcher:function(a) { +}, code:"AX_ARIA_03"}); +(function() { + function a(a) { + a = axs.utils.getRoles(a); + if (!a || !a.applied) { + return []; + } + a = a.applied; + return a.valid ? a.details.mustcontain || [] : []; + } + axs.AuditRules.addRule({name:"requiredOwnedAriaRoleMissing", heading:"Elements with ARIA roles must ensure required owned elements are present", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_08", severity:axs.constants.Severity.SEVERE, relevantElementMatcher:function(b) { + return axs.browserUtils.matchSelector(b, "[role]") ? 0 < a(b).length : !1; + }, test:function(b) { + if ("true" === b.getAttribute("aria-busy")) { + return !1; + } + for (var c = a(b), d = c.length - 1;0 <= d;d--) { + var e = axs.utils.findDescendantsWithRole(b, c[d]); + if (e && e.length) { + return !1; + } + } + b = axs.utils.getIdReferents("aria-owns", b); + for (d = b.length - 1;0 <= d;d--) { + if ((e = axs.utils.getRoles(b[d], !0)) && e.applied) { + for (var e = e.applied, f = c.length - 1;0 <= f;f--) { + if (e.name === c[f]) { + return !1; + } + } + } + } + return !0; + }, code:"AX_ARIA_08"}); +})(); +axs.AuditRules.addRule({name:"roleTooltipRequiresDescribedby", heading:"Elements with role=tooltip should have a corresponding element with aria-describedby", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_02", severity:axs.constants.Severity.SEVERE, relevantElementMatcher:function(a) { + return axs.browserUtils.matchSelector(a, "[role=tooltip]") && !axs.utils.isElementOrAncestorHidden(a); +}, test:function(a) { + return 0 === axs.utils.getAriaIdReferrers(a, "aria-describedby").length; +}, code:"AX_TOOLTIP_01"}); +axs.AuditRules.addRule({name:"tabIndexGreaterThanZero", heading:"Avoid positive integer values for tabIndex", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_focus_03", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { + return axs.browserUtils.matchSelector(a, "[tabindex]"); +}, test:function(a) { + if (0 < a.tabIndex) { + return !0; + } +}, code:"AX_FOCUS_03"}); +(function() { + axs.AuditRules.addRule({name:"tableHasAppropriateHeaders", heading:"Tables should have appropriate headers", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_table_01", severity:axs.constants.Severity.SEVERE, relevantElementMatcher:function(a) { + return axs.browserUtils.matchSelector(a, "table"); + }, test:function(a) { + if ("presentation" == a.getAttribute("role")) { + return 0 != a.querySelectorAll("th").length; + } + a = a.querySelectorAll("tr"); + var b; + a: { + b = a[0].children; + for (var c = 0;c < b.length;c++) { + if ("TH" != b[c].tagName) { + b = !0; + break a; + } + } + b = !1; + } + if (b) { + a: { + for (b = 0;b < a.length;b++) { + if ("TH" != a[b].children[0].tagName) { + b = !0; + break a; + } + } + b = !1; + } + } + if (b) { + a: { + b = a[0].children; + for (c = 1;c < b.length;c++) { + if ("TH" != b[c].tagName) { + b = !0; + break a; + } + } + for (c = 1;c < a.length;c++) { + if ("TH" != a[c].children[0].tagName) { + b = !0; + break a; + } + } + b = !1; + } + } + return b; + }, code:"AX_TABLE_01"}); +})(); +(function() { + axs.AuditRules.addRule({name:"uncontrolledTabpanel", heading:"A tabpanel should be related to a tab via aria-controls or aria-labelledby", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_13", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { + return axs.browserUtils.matchSelector(a, '[role="tabpanel"]'); + }, test:function(a) { + var b; + b = document.querySelectorAll('[role="tab"][aria-controls="' + a.id + '"]'); + (b = a.id && 1 === b.length) || (a.hasAttribute("aria-labelledby") ? (a = document.querySelectorAll("#" + a.getAttribute("aria-labelledby")), b = 1 === a.length && "tab" === a[0].getAttribute("role")) : b = !1); + return !b; + }, code:"AX_ARIA_13"}); +})(); +axs.AuditRules.addRule({name:"unfocusableElementsWithOnClick", heading:"Elements with onclick handlers must be focusable", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_focus_02", severity:axs.constants.Severity.WARNING, opt_requiresConsoleAPI:!0, relevantElementMatcher:function(a) { return a instanceof a.ownerDocument.defaultView.HTMLBodyElement || axs.utils.isElementOrAncestorHidden(a) ? !1 : "click" in getEventListeners(a) ? !0 : !1; }, test:function(a) { - return!a.hasAttribute("tabindex") && !axs.utils.isElementImplicitlyFocusable(a) && !a.disabled; -}, code:"AX_FOCUS_02"}; -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, relevantElementMatcher:function(a) { + return !a.hasAttribute("tabindex") && !axs.utils.isElementImplicitlyFocusable(a) && !a.disabled; +}, code:"AX_FOCUS_02"}); +(function() { + var a = /^aria\-/, b = axs.utils.getSelectorForAriaProperties(axs.constants.ARIA_PROPERTIES); + axs.AuditRules.addRule({name:"unsupportedAriaAttribute", heading:"This element has an unsupported ARIA attribute", url:"https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_10", severity:axs.constants.Severity.SEVERE, relevantElementMatcher:function(a) { + return axs.browserUtils.matchSelector(a, b); + }, test:function(b) { + var d = axs.utils.getRoles(b, !0), d = d && d.applied ? d.applied.details.propertiesSet : axs.constants.GLOBAL_PROPERTIES; + b = b.attributes; + for (var e = 0, f = b.length;e < f;e++) { + var g = b[e].name; + if (a.test(g)) { + var h = g.replace(a, ""); + if (axs.constants.ARIA_PROPERTIES.hasOwnProperty(h) && !(g in d)) { + return !0; + } + } + } + return !1; + }, code:"AX_ARIA_10"}); +})(); +axs.AuditRules.addRule({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", severity:axs.constants.Severity.WARNING, relevantElementMatcher:function(a) { return axs.browserUtils.matchSelector(a, "video"); }, test:function(a) { - return!a.querySelectorAll("track[kind=captions]").length; -}, code:"AX_VIDEO_01"}; + return !a.querySelectorAll("track[kind=captions]").length; +}, code:"AX_VIDEO_01"}); + + return axs; +}); +// Define AMD module if possible, export globals otherwise. +if (typeof define !== 'undefined' && define.amd) { + define([], fn); +} else { + var axs = fn.call(this); +} |