From 2d9116a4ec5232fe2395ddbc4ca01de8b1cef6de Mon Sep 17 00:00:00 2001 From: hcarmona Date: Fri, 7 Jul 2017 15:46:51 -0700 Subject: [PATCH] Import Axe Core Accessibility Testing Library BUG=737739 Review-Url: https://codereview.chromium.org/2965493003 Cr-Commit-Position: refs/heads/master@{#485078} --- third_party/axe-core/LICENSE | 362 + third_party/axe-core/OWNERS | 2 + third_party/axe-core/README.chromium | 20 + third_party/axe-core/axe.js | 9454 ++++++++++++++++++++++++++ third_party/axe-core/axe.min.js | 42 + 5 files changed, 9880 insertions(+) create mode 100644 third_party/axe-core/LICENSE create mode 100644 third_party/axe-core/OWNERS create mode 100644 third_party/axe-core/README.chromium create mode 100644 third_party/axe-core/axe.js create mode 100644 third_party/axe-core/axe.min.js diff --git a/third_party/axe-core/LICENSE b/third_party/axe-core/LICENSE new file mode 100644 index 00000000000000..be2cc4dfb609fb --- /dev/null +++ b/third_party/axe-core/LICENSE @@ -0,0 +1,362 @@ +Mozilla Public License, version 2.0 + +1. Definitions + +1.1. "Contributor" + + means each individual or legal entity that creates, contributes to the + creation of, or owns Covered Software. + +1.2. "Contributor Version" + + means the combination of the Contributions of others (if any) used by a + Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + + means Source Code Form to which the initial Contributor has attached the + notice in Exhibit A, the Executable Form of such Source Code Form, and + Modifications of such Source Code Form, in each case including portions + thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + a. that the initial Contributor has attached the notice described in + Exhibit B to the Covered Software; or + + b. that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the terms of + a Secondary License. + +1.6. "Executable Form" + + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + + means a work that combines Covered Software with other material, in a + separate file or files, that is not Covered Software. + +1.8. "License" + + means this document. + +1.9. "Licensable" + + means having the right to grant, to the maximum extent possible, whether + at the time of the initial grant or subsequently, any and all of the + rights conveyed by this License. + +1.10. "Modifications" + + means any of the following: + + a. any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered Software; or + + b. any new file in Source Code Form that contains any Covered Software. + +1.11. "Patent Claims" of a Contributor + + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the License, + by the making, using, selling, offering for sale, having made, import, + or transfer of either its Contributions or its Contributor Version. + +1.12. "Secondary License" + + means either the GNU General Public License, Version 2.0, the GNU Lesser + General Public License, Version 2.1, the GNU Affero General Public + License, Version 3.0, or any later versions of those licenses. + +1.13. "Source Code Form" + + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that controls, is + controlled by, or is under common control with You. For purposes of this + definition, "control" means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + + +2. License Grants and Conditions + +2.1. Grants + + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + a. under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + + b. under Patent Claims of such Contributor to make, use, sell, offer for + sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + +2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + + a. for any code that a Contributor has removed from Covered Software; or + + b. for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + c. under Patent Claims infringed by Covered Software in the absence of + its Contributions. + + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + +2.5. Representation + + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights to + grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + +2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in + Section 2.1. + + +3. Responsibilities + +3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + +3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + a. such Covered Software must also be made available in Source Code Form, + as described in Section 3.1, and You must inform recipients of the + Executable Form how they can obtain a copy of such Source Code Form by + reasonable means in a timely manner, at a charge no more than the cost + of distribution to the recipient; and + + b. You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter the + recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + +3.4. Notices + + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, or + limitations of liability) contained within the Source Code Form of the + Covered Software, except that You may alter any license notices to the + extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + + If it is impossible for You to comply with any of the terms of this License + with respect to some or all of the Covered Software due to statute, + judicial order, or regulation then You must: (a) comply with the terms of + this License to the maximum extent possible; and (b) describe the + limitations and the code they affect. Such description must be placed in a + text file included with all distributions of the Covered Software under + this License. Except to the extent prohibited by statute or regulation, + such description must be sufficiently detailed for a recipient of ordinary + skill to be able to understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You + fail to comply with any of its terms. However, if You become compliant, + then the rights granted under this License from a particular Contributor + are reinstated (a) provisionally, unless and until such Contributor + explicitly and finally terminates Your grants, and (b) on an ongoing + basis, if such Contributor fails to notify You of the non-compliance by + some reasonable means prior to 60 days after You have come back into + compliance. Moreover, Your grants from a particular Contributor are + reinstated on an ongoing basis if such Contributor notifies You of the + non-compliance by some reasonable means, this is the first time You have + received notice of non-compliance with this License from such + Contributor, and You become compliant prior to 30 days after Your receipt + of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user + license agreements (excluding distributors and resellers) which have been + validly granted by You or Your distributors under this License prior to + termination shall survive termination. + +6. Disclaimer of Warranty + + Covered Software is provided under this License on an "as is" basis, + without warranty of any kind, either expressed, implied, or statutory, + including, without limitation, warranties that the Covered Software is free + of defects, merchantable, fit for a particular purpose or non-infringing. + The entire risk as to the quality and performance of the Covered Software + is with You. Should any Covered Software prove defective in any respect, + You (not any Contributor) assume the cost of any necessary servicing, + repair, or correction. This disclaimer of warranty constitutes an essential + part of this License. No use of any Covered Software is authorized under + this License except under this disclaimer. + +7. Limitation of Liability + + Under no circumstances and under no legal theory, whether tort (including + negligence), contract, or otherwise, shall any Contributor, or anyone who + distributes Covered Software as permitted above, be liable to You for any + direct, indirect, special, incidental, or consequential damages of any + character including, without limitation, damages for lost profits, loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses, even if such party shall have been + informed of the possibility of such damages. This limitation of liability + shall not apply to liability for death or personal injury resulting from + such party's negligence to the extent applicable law prohibits such + limitation. Some jurisdictions do not allow the exclusion or limitation of + incidental or consequential damages, so this exclusion and limitation may + not apply to You. + +8. Litigation + + Any litigation relating to this License may be brought only in the courts + of a jurisdiction where the defendant maintains its principal place of + business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. Nothing + in this Section shall prevent a party's ability to bring cross-claims or + counter-claims. + +9. Miscellaneous + + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides that + the language of a contract shall be construed against the drafter shall not + be used to construe this License against a Contributor. + + +10. Versions of the License + +10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + +10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + +10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses If You choose to distribute Source Code Form that is + Incompatible With Secondary Licenses under the terms of this version of + the License, the notice described in Exhibit B of this License must be + attached. + +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the + terms of the Mozilla Public License, v. + 2.0. If a copy of the MPL was not + distributed with this file, You can + obtain one at + http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, +then You may include the notice in a location (such as a LICENSE file in a +relevant directory) where a recipient would be likely to look for such a +notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice + + This Source Code Form is "Incompatible + With Secondary Licenses", as defined by + the Mozilla Public License, v. 2.0. diff --git a/third_party/axe-core/OWNERS b/third_party/axe-core/OWNERS new file mode 100644 index 00000000000000..1877266f71241c --- /dev/null +++ b/third_party/axe-core/OWNERS @@ -0,0 +1,2 @@ +aboxhall@chromium.org +hcarmona@chromium.org diff --git a/third_party/axe-core/README.chromium b/third_party/axe-core/README.chromium new file mode 100644 index 00000000000000..6bd3e1bbd7bb45 --- /dev/null +++ b/third_party/axe-core/README.chromium @@ -0,0 +1,20 @@ +Name: AXE-CORE Accessibility Audit +Short Name: axe-core +URL: https://github.com/dequelabs/axe-core/ +Version: 0 +Date: Sun Jun 18 19:21:36 2017 -0400 +Revision: 1986520cdca8ed0f208d2cbd918829b27266a374 +License: MPL 2.0 +License File: LICENSE +Security Critical: no + +Description: +Accessibility engine for automated Web UI testing. This will be used to run +automated accessibility tests in web-ui. + +Local Modifications: + 1 Checked out the origin/shadowDOM branch + 2 Created build + 3 New files: + README.chromium + OWNERS diff --git a/third_party/axe-core/axe.js b/third_party/axe-core/axe.js new file mode 100644 index 00000000000000..19c2cbffab9468 --- /dev/null +++ b/third_party/axe-core/axe.js @@ -0,0 +1,9454 @@ +/*! aXe v2.3.1 + * Copyright (c) 2017 Deque Systems, Inc. + * + * Your use of this Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This entire copyright notice must appear in every copy of this file you + * distribute or in any file that contains substantial portions of this source + * code. + */ +(function axeFunction(window) { + var global = window; + var document = window.document; + 'use strict'; + var _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function(obj) { + return typeof obj; + } : function(obj) { + return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; + }; + var axe = axe || {}; + axe.version = '2.3.1'; + if (typeof define === 'function' && define.amd) { + define([], function() { + 'use strict'; + return axe; + }); + } + if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object' && module.exports && typeof axeFunction.toString === 'function') { + axe.source = '(' + axeFunction.toString() + ')(typeof window === "object" ? window : this);'; + module.exports = axe; + } + if (typeof window.getComputedStyle === 'function') { + window.axe = axe; + } + var commons; + function SupportError(error) { + this.name = 'SupportError'; + this.cause = error.cause; + this.message = '`' + error.cause + '` - feature unsupported in your environment.'; + if (error.ruleId) { + this.ruleId = error.ruleId; + this.message += ' Skipping ' + this.ruleId + ' rule.'; + } + this.stack = new Error().stack; + } + SupportError.prototype = Object.create(Error.prototype); + SupportError.prototype.constructor = SupportError; + 'use strict'; + var utils = axe.utils = {}; + 'use strict'; + var helpers = {}; + 'use strict'; + var _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function(obj) { + return typeof obj; + } : function(obj) { + return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; + }; + function getDefaultConfiguration(audit) { + 'use strict'; + var config; + if (audit) { + config = axe.utils.clone(audit); + config.commons = audit.commons; + } else { + config = {}; + } + config.reporter = config.reporter || null; + config.rules = config.rules || []; + config.checks = config.checks || []; + config.data = Object.assign({ + checks: {}, + rules: {} + }, config.data); + return config; + } + function unpackToObject(collection, audit, method) { + 'use strict'; + var i, l; + for (i = 0, l = collection.length; i < l; i++) { + audit[method](collection[i]); + } + } + function Audit(audit) { + this.brand = 'axe'; + this.application = 'axeAPI'; + this.tagExclude = [ 'experimental' ]; + this.defaultConfig = audit; + this._init(); + } + Audit.prototype._init = function() { + var audit = getDefaultConfiguration(this.defaultConfig); + axe.commons = commons = audit.commons; + this.reporter = audit.reporter; + this.commands = {}; + this.rules = []; + this.checks = {}; + unpackToObject(audit.rules, this, 'addRule'); + unpackToObject(audit.checks, this, 'addCheck'); + this.data = {}; + this.data.checks = audit.data && audit.data.checks || {}; + this.data.rules = audit.data && audit.data.rules || {}; + this.data.failureSummaries = audit.data && audit.data.failureSummaries || {}; + this.data.incompleteFallbackMessage = audit.data && audit.data.incompleteFallbackMessage || ''; + this._constructHelpUrls(); + }; + Audit.prototype.registerCommand = function(command) { + 'use strict'; + this.commands[command.id] = command.callback; + }; + Audit.prototype.addRule = function(spec) { + 'use strict'; + if (spec.metadata) { + this.data.rules[spec.id] = spec.metadata; + } + var rule = this.getRule(spec.id); + if (rule) { + rule.configure(spec); + } else { + this.rules.push(new Rule(spec, this)); + } + }; + Audit.prototype.addCheck = function(spec) { + 'use strict'; + var metadata = spec.metadata; + if ((typeof metadata === 'undefined' ? 'undefined' : _typeof(metadata)) === 'object') { + this.data.checks[spec.id] = metadata; + if (_typeof(metadata.messages) === 'object') { + Object.keys(metadata.messages).filter(function(prop) { + return metadata.messages.hasOwnProperty(prop) && typeof metadata.messages[prop] === 'string'; + }).forEach(function(prop) { + if (metadata.messages[prop].indexOf('function') === 0) { + metadata.messages[prop] = new Function('return ' + metadata.messages[prop] + ';')(); + } + }); + } + } + if (this.checks[spec.id]) { + this.checks[spec.id].configure(spec); + } else { + this.checks[spec.id] = new Check(spec); + } + }; + Audit.prototype.run = function(context, options, resolve, reject) { + 'use strict'; + this.validateOptions(options); + axe._tree = axe.utils.getFlattenedTree(document.body); + var q = axe.utils.queue(); + this.rules.forEach(function(rule) { + if (axe.utils.ruleShouldRun(rule, context, options)) { + if (options.performanceTimer) { + var markEnd = 'mark_rule_end_' + rule.id; + var markStart = 'mark_rule_start_' + rule.id; + axe.utils.performanceTimer.mark(markStart); + } + q.defer(function(res, rej) { + rule.run(context, options, function(out) { + if (options.performanceTimer) { + axe.utils.performanceTimer.mark(markEnd); + axe.utils.performanceTimer.measure('rule_' + rule.id, markStart, markEnd); + } + res(out); + }, function(err) { + if (!options.debug) { + var errResult = Object.assign(new RuleResult(rule), { + result: axe.constants.CANTTELL, + description: 'An error occured while running this rule', + message: err.message, + help: err.stack || err.message, + error: err + }); + res(errResult); + } else { + rej(err); + } + }); + }); + } + }); + q.then(function(results) { + axe._tree = undefined; + resolve(results.filter(function(result) { + return !!result; + })); + }).catch(reject); + }; + Audit.prototype.after = function(results, options) { + 'use strict'; + var rules = this.rules; + return results.map(function(ruleResult) { + var rule = axe.utils.findBy(rules, 'id', ruleResult.id); + return rule.after(ruleResult, options); + }); + }; + Audit.prototype.getRule = function(ruleId) { + return this.rules.find(function(rule) { + return rule.id === ruleId; + }); + }; + Audit.prototype.validateOptions = function(options) { + 'use strict'; + var audit = this; + if (_typeof(options.runOnly) === 'object') { + var only = options.runOnly; + if (only.type === 'rule' && Array.isArray(only.value)) { + only.value.forEach(function(ruleId) { + if (!audit.getRule(ruleId)) { + throw new Error('unknown rule `' + ruleId + '` in options.runOnly'); + } + }); + } else if (Array.isArray(only.value) && only.value.length > 0) { + var tags = [].concat(only.value); + audit.rules.forEach(function(rule) { + var tagPos, i, l; + if (!tags) { + return; + } + for (i = 0, l = rule.tags.length; i < l; i++) { + tagPos = tags.indexOf(rule.tags[i]); + if (tagPos !== -1) { + tags.splice(tagPos, 1); + } + } + }); + if (tags.length !== 0) { + throw new Error('could not find tags `' + tags.join('`, `') + '`'); + } + } + } + if (_typeof(options.rules) === 'object') { + Object.keys(options.rules).forEach(function(ruleId) { + if (!audit.getRule(ruleId)) { + throw new Error('unknown rule `' + ruleId + '` in options.rules'); + } + }); + } + return options; + }; + Audit.prototype.setBranding = function(branding) { + 'use strict'; + var previous = { + brand: this.brand, + application: this.application + }; + if (branding && branding.hasOwnProperty('brand') && branding.brand && typeof branding.brand === 'string') { + this.brand = branding.brand; + } + if (branding && branding.hasOwnProperty('application') && branding.application && typeof branding.application === 'string') { + this.application = branding.application; + } + this._constructHelpUrls(previous); + }; + function getHelpUrl(_ref, ruleId, version) { + var brand = _ref.brand, application = _ref.application; + return axe.constants.helpUrlBase + brand + '/' + (version || axe.version.substring(0, axe.version.lastIndexOf('.'))) + '/' + ruleId + '?application=' + application; + } + Audit.prototype._constructHelpUrls = function() { + var _this = this; + var previous = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + var version = axe.version.substring(0, axe.version.lastIndexOf('.')); + this.rules.forEach(function(rule) { + if (!_this.data.rules[rule.id]) { + _this.data.rules[rule.id] = {}; + } + var metaData = _this.data.rules[rule.id]; + if (typeof metaData.helpUrl !== 'string' || previous && metaData.helpUrl === getHelpUrl(previous, rule.id, version)) { + metaData.helpUrl = getHelpUrl(_this, rule.id, version); + } + }); + }; + Audit.prototype.resetRulesAndChecks = function() { + 'use strict'; + this._init(); + }; + 'use strict'; + function CheckResult(check) { + 'use strict'; + this.id = check.id; + this.data = null; + this.relatedNodes = []; + this.result = null; + } + 'use strict'; + function createExecutionContext(spec) { + 'use strict'; + if (typeof spec === 'string') { + return new Function('return ' + spec + ';')(); + } + return spec; + } + function Check(spec) { + if (spec) { + this.id = spec.id; + this.configure(spec); + } + } + Check.prototype.enabled = true; + Check.prototype.run = function(node, options, resolve, reject) { + 'use strict'; + options = options || {}; + var enabled = options.hasOwnProperty('enabled') ? options.enabled : this.enabled, checkOptions = options.options || this.options; + if (enabled) { + var checkResult = new CheckResult(this); + var checkHelper = axe.utils.checkHelper(checkResult, options, resolve, reject); + var result; + try { + result = this.evaluate.call(checkHelper, node.actualNode, checkOptions, node); + } catch (e) { + reject(e); + return; + } + if (!checkHelper.isAsync) { + checkResult.result = result; + setTimeout(function() { + resolve(checkResult); + }, 0); + } + } else { + resolve(null); + } + }; + Check.prototype.configure = function(spec) { + var _this = this; + [ 'options', 'enabled' ].filter(function(prop) { + return spec.hasOwnProperty(prop); + }).forEach(function(prop) { + return _this[prop] = spec[prop]; + }); + [ 'evaluate', 'after' ].filter(function(prop) { + return spec.hasOwnProperty(prop); + }).forEach(function(prop) { + return _this[prop] = createExecutionContext(spec[prop]); + }); + }; + 'use strict'; + var _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function(obj) { + return typeof obj; + } : function(obj) { + return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; + }; + function pushUniqueFrame(collection, frame) { + 'use strict'; + if (axe.utils.isHidden(frame)) { + return; + } + var fr = axe.utils.findBy(collection, 'node', frame); + if (!fr) { + collection.push({ + node: frame, + include: [], + exclude: [] + }); + } + } + function pushUniqueFrameSelector(context, type, selectorArray) { + 'use strict'; + context.frames = context.frames || []; + var result, frame; + var frames = document.querySelectorAll(selectorArray.shift()); + frameloop: for (var i = 0, l = frames.length; i < l; i++) { + frame = frames[i]; + for (var j = 0, l2 = context.frames.length; j < l2; j++) { + if (context.frames[j].node === frame) { + context.frames[j][type].push(selectorArray); + break frameloop; + } + } + result = { + node: frame, + include: [], + exclude: [] + }; + if (selectorArray) { + result[type].push(selectorArray); + } + context.frames.push(result); + } + } + function normalizeContext(context) { + 'use strict'; + if (context && (typeof context === 'undefined' ? 'undefined' : _typeof(context)) === 'object' || context instanceof NodeList) { + if (context instanceof Node) { + return { + include: [ context ], + exclude: [] + }; + } + if (context.hasOwnProperty('include') || context.hasOwnProperty('exclude')) { + return { + include: context.include && +context.include.length ? context.include : [ document ], + exclude: context.exclude || [] + }; + } + if (context.length === +context.length) { + return { + include: context, + exclude: [] + }; + } + } + if (typeof context === 'string') { + return { + include: [ context ], + exclude: [] + }; + } + return { + include: [ document ], + exclude: [] + }; + } + function parseSelectorArray(context, type) { + 'use strict'; + var item, result = [], nodeList; + for (var i = 0, l = context[type].length; i < l; i++) { + item = context[type][i]; + if (typeof item === 'string') { + nodeList = Array.from(document.querySelectorAll(item)); + result = result.concat(nodeList.map(function(node) { + return axe.utils.getFlattenedTree(node)[0]; + })); + break; + } else if (item && item.length && !(item instanceof Node)) { + if (item.length > 1) { + pushUniqueFrameSelector(context, type, item); + } else { + nodeList = Array.from(document.querySelectorAll(item[0])); + result = result.concat(nodeList.map(function(node) { + return axe.utils.getFlattenedTree(node)[0]; + })); + } + } else if (item instanceof Node) { + result.push(axe.utils.getFlattenedTree(item)[0]); + } + } + return result.filter(function(r) { + return r; + }); + } + function validateContext(context) { + 'use strict'; + if (context.include.length === 0) { + if (context.frames.length === 0) { + var env = axe.utils.respondable.isInFrame() ? 'frame' : 'page'; + return new Error('No elements found for include in ' + env + ' Context'); + } + context.frames.forEach(function(frame, i) { + if (frame.include.length === 0) { + return new Error('No elements found for include in Context of frame ' + i); + } + }); + } + } + function Context(spec) { + 'use strict'; + var self = this; + this.frames = []; + this.initiator = spec && typeof spec.initiator === 'boolean' ? spec.initiator : true; + this.page = false; + spec = normalizeContext(spec); + this.exclude = spec.exclude; + this.include = spec.include; + this.include = parseSelectorArray(this, 'include'); + this.exclude = parseSelectorArray(this, 'exclude'); + axe.utils.select('frame, iframe', this).forEach(function(frame) { + if (isNodeInContext(frame, self)) { + pushUniqueFrame(self.frames, frame.actualNode); + } + }); + if (this.include.length === 1 && this.include[0].actualNode === document.documentElement) { + this.page = true; + } + var err = validateContext(this); + if (err instanceof Error) { + throw err; + } + } + 'use strict'; + function RuleResult(rule) { + 'use strict'; + this.id = rule.id; + this.result = axe.constants.NA; + this.pageLevel = rule.pageLevel; + this.impact = null; + this.nodes = []; + } + 'use strict'; + function Rule(spec, parentAudit) { + 'use strict'; + this._audit = parentAudit; + this.id = spec.id; + this.selector = spec.selector || '*'; + this.excludeHidden = typeof spec.excludeHidden === 'boolean' ? spec.excludeHidden : true; + this.enabled = typeof spec.enabled === 'boolean' ? spec.enabled : true; + this.pageLevel = typeof spec.pageLevel === 'boolean' ? spec.pageLevel : false; + this.any = spec.any || []; + this.all = spec.all || []; + this.none = spec.none || []; + this.tags = spec.tags || []; + if (spec.matches) { + this.matches = createExecutionContext(spec.matches); + } + } + Rule.prototype.matches = function() { + 'use strict'; + return true; + }; + Rule.prototype.gather = function(context) { + 'use strict'; + var elements = axe.utils.select(this.selector, context); + if (this.excludeHidden) { + return elements.filter(function(element) { + return !axe.utils.isHidden(element.actualNode); + }); + } + return elements; + }; + Rule.prototype.runChecks = function(type, node, options, resolve, reject) { + 'use strict'; + var self = this; + var checkQueue = axe.utils.queue(); + this[type].forEach(function(c) { + var check = self._audit.checks[c.id || c]; + var option = axe.utils.getCheckOption(check, self.id, options); + checkQueue.defer(function(res, rej) { + check.run(node, option, res, rej); + }); + }); + checkQueue.then(function(results) { + results = results.filter(function(check) { + return check; + }); + resolve({ + type: type, + results: results + }); + }).catch(reject); + }; + Rule.prototype.run = function(context, options, resolve, reject) { + var _this = this; + var q = axe.utils.queue(); + var ruleResult = new RuleResult(this); + var nodes = void 0; + try { + nodes = this.gather(context).filter(function(node) { + return _this.matches(node.actualNode); + }); + } catch (error) { + reject(new SupportError({ + cause: error, + ruleId: this.id + })); + return; + } + if (options.performanceTimer) { + axe.log('gather (', nodes.length, '):', axe.utils.performanceTimer.timeElapsed() + 'ms'); + } + nodes.forEach(function(node) { + q.defer(function(resolveNode, rejectNode) { + var checkQueue = axe.utils.queue(); + checkQueue.defer(function(res, rej) { + _this.runChecks('any', node, options, res, rej); + }); + checkQueue.defer(function(res, rej) { + _this.runChecks('all', node, options, res, rej); + }); + checkQueue.defer(function(res, rej) { + _this.runChecks('none', node, options, res, rej); + }); + checkQueue.then(function(results) { + if (results.length) { + var hasResults = false, result = {}; + results.forEach(function(r) { + var res = r.results.filter(function(result) { + return result; + }); + result[r.type] = res; + if (res.length) { + hasResults = true; + } + }); + if (hasResults) { + result.node = new axe.utils.DqElement(node.actualNode, options); + ruleResult.nodes.push(result); + } + } + resolveNode(); + }).catch(function(err) { + return rejectNode(err); + }); + }); + }); + q.then(function() { + return resolve(ruleResult); + }).catch(function(error) { + return reject(error); + }); + }; + function findAfterChecks(rule) { + 'use strict'; + return axe.utils.getAllChecks(rule).map(function(c) { + var check = rule._audit.checks[c.id || c]; + return check && typeof check.after === 'function' ? check : null; + }).filter(Boolean); + } + function findCheckResults(nodes, checkID) { + 'use strict'; + var checkResults = []; + nodes.forEach(function(nodeResult) { + var checks = axe.utils.getAllChecks(nodeResult); + checks.forEach(function(checkResult) { + if (checkResult.id === checkID) { + checkResults.push(checkResult); + } + }); + }); + return checkResults; + } + function filterChecks(checks) { + 'use strict'; + return checks.filter(function(check) { + return check.filtered !== true; + }); + } + function sanitizeNodes(result) { + 'use strict'; + var checkTypes = [ 'any', 'all', 'none' ]; + var nodes = result.nodes.filter(function(detail) { + var length = 0; + checkTypes.forEach(function(type) { + detail[type] = filterChecks(detail[type]); + length += detail[type].length; + }); + return length > 0; + }); + if (result.pageLevel && nodes.length) { + nodes = [ nodes.reduce(function(a, b) { + if (a) { + checkTypes.forEach(function(type) { + a[type].push.apply(a[type], b[type]); + }); + return a; + } + }) ]; + } + return nodes; + } + Rule.prototype.after = function(result, options) { + 'use strict'; + var afterChecks = findAfterChecks(this); + var ruleID = this.id; + afterChecks.forEach(function(check) { + var beforeResults = findCheckResults(result.nodes, check.id); + var option = axe.utils.getCheckOption(check, ruleID, options); + var afterResults = check.after(beforeResults, option); + beforeResults.forEach(function(item) { + if (afterResults.indexOf(item) === -1) { + item.filtered = true; + } + }); + }); + result.nodes = sanitizeNodes(result); + return result; + }; + Rule.prototype.configure = function(spec) { + 'use strict'; + if (spec.hasOwnProperty('selector')) { + this.selector = spec.selector; + } + if (spec.hasOwnProperty('excludeHidden')) { + this.excludeHidden = typeof spec.excludeHidden === 'boolean' ? spec.excludeHidden : true; + } + if (spec.hasOwnProperty('enabled')) { + this.enabled = typeof spec.enabled === 'boolean' ? spec.enabled : true; + } + if (spec.hasOwnProperty('pageLevel')) { + this.pageLevel = typeof spec.pageLevel === 'boolean' ? spec.pageLevel : false; + } + if (spec.hasOwnProperty('any')) { + this.any = spec.any; + } + if (spec.hasOwnProperty('all')) { + this.all = spec.all; + } + if (spec.hasOwnProperty('none')) { + this.none = spec.none; + } + if (spec.hasOwnProperty('tags')) { + this.tags = spec.tags; + } + if (spec.hasOwnProperty('matches')) { + if (typeof spec.matches === 'string') { + this.matches = new Function('return ' + spec.matches + ';')(); + } else { + this.matches = spec.matches; + } + } + }; + 'use strict'; + (function(axe) { + var definitions = [ { + name: 'NA', + value: 'inapplicable', + priority: 0, + group: 'inapplicable' + }, { + name: 'PASS', + value: 'passed', + priority: 1, + group: 'passes' + }, { + name: 'CANTTELL', + value: 'cantTell', + priority: 2, + group: 'incomplete' + }, { + name: 'FAIL', + value: 'failed', + priority: 3, + group: 'violations' + } ]; + var constants = { + helpUrlBase: 'https://dequeuniversity.com/rules/', + results: [], + resultGroups: [], + resultGroupMap: {}, + impact: Object.freeze([ 'minor', 'moderate', 'serious', 'critical' ]) + }; + definitions.forEach(function(definition) { + var name = definition.name; + var value = definition.value; + var priority = definition.priority; + var group = definition.group; + constants[name] = value; + constants[name + '_PRIO'] = priority; + constants[name + '_GROUP'] = group; + constants.results[priority] = value; + constants.resultGroups[priority] = group; + constants.resultGroupMap[value] = group; + }); + Object.freeze(constants.results); + Object.freeze(constants.resultGroups); + Object.freeze(constants.resultGroupMap); + Object.freeze(constants); + Object.defineProperty(axe, 'constants', { + value: constants, + enumerable: true, + configurable: false, + writable: false + }); + })(axe); + 'use strict'; + var _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function(obj) { + return typeof obj; + } : function(obj) { + return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; + }; + axe.log = function() { + 'use strict'; + if ((typeof console === 'undefined' ? 'undefined' : _typeof(console)) === 'object' && console.log) { + Function.prototype.apply.call(console.log, console, arguments); + } + }; + 'use strict'; + var _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function(obj) { + return typeof obj; + } : function(obj) { + return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; + }; + axe.a11yCheck = function(context, options, callback) { + 'use strict'; + if (typeof options === 'function') { + callback = options; + options = {}; + } + if (!options || (typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object') { + options = {}; + } + var audit = axe._audit; + if (!audit) { + throw new Error('No audit configured'); + } + options.reporter = options.reporter || audit.reporter || 'v2'; + if (options.performanceTimer) { + axe.utils.performanceTimer.start(); + } + var reporter = axe.getReporter(options.reporter); + axe._runRules(context, options, function(results) { + var res = reporter(results, options, callback); + if (res !== undefined) { + if (options.performanceTimer) { + axe.utils.performanceTimer.end(); + } + callback(res); + } + }, axe.log); + }; + 'use strict'; + function cleanupPlugins(resolve, reject) { + 'use strict'; + if (!axe._audit) { + throw new Error('No audit configured'); + } + var q = axe.utils.queue(); + var cleanupErrors = []; + Object.keys(axe.plugins).forEach(function(key) { + q.defer(function(res) { + var rej = function rej(err) { + cleanupErrors.push(err); + res(); + }; + try { + axe.plugins[key].cleanup(res, rej); + } catch (err) { + rej(err); + } + }); + }); + axe.utils.toArray(document.querySelectorAll('frame, iframe')).forEach(function(frame) { + q.defer(function(res, rej) { + return axe.utils.sendCommandToFrame(frame, { + command: 'cleanup-plugin' + }, res, rej); + }); + }); + q.then(function(results) { + if (cleanupErrors.length === 0) { + resolve(results); + } else { + reject(cleanupErrors); + } + }).catch(reject); + } + axe.cleanup = cleanupPlugins; + 'use strict'; + function configureChecksRulesAndBranding(spec) { + 'use strict'; + var audit; + audit = axe._audit; + if (!audit) { + throw new Error('No audit configured'); + } + if (spec.reporter && (typeof spec.reporter === 'function' || reporters[spec.reporter])) { + audit.reporter = spec.reporter; + } + if (spec.checks) { + spec.checks.forEach(function(check) { + audit.addCheck(check); + }); + } + if (spec.rules) { + spec.rules.forEach(function(rule) { + audit.addRule(rule); + }); + } + if (typeof spec.branding !== 'undefined') { + audit.setBranding(spec.branding); + } else { + audit._constructHelpUrls(); + } + if (spec.tagExclude) { + audit.tagExclude = spec.tagExclude; + } + } + axe.configure = configureChecksRulesAndBranding; + 'use strict'; + axe.getRules = function(tags) { + 'use strict'; + tags = tags || []; + var matchingRules = !tags.length ? axe._audit.rules : axe._audit.rules.filter(function(item) { + return !!tags.filter(function(tag) { + return item.tags.indexOf(tag) !== -1; + }).length; + }); + var ruleData = axe._audit.data.rules || {}; + return matchingRules.map(function(matchingRule) { + var rd = ruleData[matchingRule.id] || {}; + return { + ruleId: matchingRule.id, + description: rd.description, + help: rd.help, + helpUrl: rd.helpUrl, + tags: matchingRule.tags + }; + }); + }; + 'use strict'; + function runCommand(data, keepalive, callback) { + 'use strict'; + var resolve = callback; + var reject = function reject(err) { + if (err instanceof Error === false) { + err = new Error(err); + } + callback(err); + }; + var context = data && data.context || {}; + if (context.include && !context.include.length) { + context.include = [ document ]; + } + var options = data && data.options || {}; + switch (data.command) { + case 'rules': + return runRules(context, options, resolve, reject); + + case 'cleanup-plugin': + return cleanupPlugins(resolve, reject); + + default: + if (axe._audit && axe._audit.commands && axe._audit.commands[data.command]) { + return axe._audit.commands[data.command](data, callback); + } + } + } + axe._load = function(audit) { + 'use strict'; + axe.utils.respondable.subscribe('axe.ping', function(data, keepalive, respond) { + respond({ + axe: true + }); + }); + axe.utils.respondable.subscribe('axe.start', runCommand); + axe._audit = new Audit(audit); + }; + 'use strict'; + var axe = axe || {}; + axe.plugins = {}; + function Plugin(spec) { + 'use strict'; + this._run = spec.run; + this._collect = spec.collect; + this._registry = {}; + spec.commands.forEach(function(command) { + axe._audit.registerCommand(command); + }); + } + Plugin.prototype.run = function() { + 'use strict'; + return this._run.apply(this, arguments); + }; + Plugin.prototype.collect = function() { + 'use strict'; + return this._collect.apply(this, arguments); + }; + Plugin.prototype.cleanup = function(done) { + 'use strict'; + var q = axe.utils.queue(); + var that = this; + Object.keys(this._registry).forEach(function(key) { + q.defer(function(done) { + that._registry[key].cleanup(done); + }); + }); + q.then(function() { + done(); + }); + }; + Plugin.prototype.add = function(impl) { + 'use strict'; + this._registry[impl.id] = impl; + }; + axe.registerPlugin = function(plugin) { + 'use strict'; + axe.plugins[plugin.id] = new Plugin(plugin); + }; + 'use strict'; + var reporters = {}; + var defaultReporter; + axe.getReporter = function(reporter) { + 'use strict'; + if (typeof reporter === 'string' && reporters[reporter]) { + return reporters[reporter]; + } + if (typeof reporter === 'function') { + return reporter; + } + return defaultReporter; + }; + axe.addReporter = function registerReporter(name, cb, isDefault) { + 'use strict'; + reporters[name] = cb; + if (isDefault) { + defaultReporter = cb; + } + }; + 'use strict'; + function resetConfiguration() { + 'use strict'; + var audit = axe._audit; + if (!audit) { + throw new Error('No audit configured'); + } + audit.resetRulesAndChecks(); + } + axe.reset = resetConfiguration; + 'use strict'; + function runRules(context, options, resolve, reject) { + 'use strict'; + try { + context = new Context(context); + } catch (e) { + return reject(e); + } + var q = axe.utils.queue(); + var audit = axe._audit; + if (options.performanceTimer) { + axe.utils.performanceTimer.auditStart(); + } + if (context.frames.length && options.iframes !== false) { + q.defer(function(res, rej) { + axe.utils.collectResultsFromFrames(context, options, 'rules', null, res, rej); + }); + } + q.defer(function(res, rej) { + audit.run(context, options, res, rej); + }); + q.then(function(data) { + try { + if (options.performanceTimer) { + axe.utils.performanceTimer.auditEnd(); + } + var results = axe.utils.mergeResults(data.map(function(d) { + return { + results: d + }; + })); + if (context.initiator) { + results = audit.after(results, options); + results.forEach(axe.utils.publishMetaData); + results = results.map(axe.utils.finalizeRuleResult); + } + try { + resolve(results); + } catch (e) { + axe.log(e); + } + } catch (e) { + reject(e); + } + }).catch(reject); + } + axe._runRules = runRules; + 'use strict'; + var _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function(obj) { + return typeof obj; + } : function(obj) { + return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; + }; + function isContext(potential) { + 'use strict'; + switch (true) { + case typeof potential === 'string': + case Array.isArray(potential): + case Node && potential instanceof Node: + case NodeList && potential instanceof NodeList: + return true; + + case (typeof potential === 'undefined' ? 'undefined' : _typeof(potential)) !== 'object': + return false; + + case potential.include !== undefined: + case potential.exclude !== undefined: + case typeof potential.length === 'number': + return true; + + default: + return false; + } + } + var noop = function noop() {}; + function normalizeRunParams(context, options, callback) { + 'use strict'; + var typeErr = new TypeError('axe.run arguments are invalid'); + if (!isContext(context)) { + if (callback !== undefined) { + throw typeErr; + } + callback = options; + options = context; + context = document; + } + if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object') { + if (callback !== undefined) { + throw typeErr; + } + callback = options; + options = {}; + } + if (typeof callback !== 'function' && callback !== undefined) { + throw typeErr; + } + return { + context: context, + options: options, + callback: callback || noop + }; + } + axe.run = function(context, options, callback) { + 'use strict'; + if (!axe._audit) { + throw new Error('No audit configured'); + } + var args = normalizeRunParams(context, options, callback); + context = args.context; + options = args.options; + callback = args.callback; + options.reporter = options.reporter || axe._audit.reporter || 'v1'; + if (options.performanceTimer) { + axe.utils.performanceTimer.start(); + } + var p = void 0; + var reject = noop; + var resolve = noop; + if (window.Promise && callback === noop) { + p = new Promise(function(_resolve, _reject) { + reject = _reject; + resolve = _resolve; + }); + } + axe._runRules(context, options, function(rawResults) { + var respond = function respond(results) { + try { + callback(null, results); + } catch (e) { + axe.log(e); + } + resolve(results); + }; + if (options.performanceTimer) { + axe.utils.performanceTimer.end(); + } + try { + var reporter = axe.getReporter(options.reporter); + var results = reporter(rawResults, options, respond); + if (results !== undefined) { + respond(results); + } + } catch (err) { + callback(err); + reject(err); + } + }, function(err) { + callback(err); + reject(err); + }); + return p; + }; + 'use strict'; + helpers.failureSummary = function failureSummary(nodeData) { + 'use strict'; + var failingChecks = {}; + failingChecks.none = nodeData.none.concat(nodeData.all); + failingChecks.any = nodeData.any; + return Object.keys(failingChecks).map(function(key) { + if (!failingChecks[key].length) { + return; + } + var sum = axe._audit.data.failureSummaries[key]; + if (sum && typeof sum.failureMessage === 'function') { + return sum.failureMessage(failingChecks[key].map(function(check) { + return check.message || ''; + })); + } + }).filter(function(i) { + return i !== undefined; + }).join('\n\n'); + }; + 'use strict'; + helpers.incompleteFallbackMessage = function incompleteFallbackMessage() { + 'use strict'; + return axe._audit.data.incompleteFallbackMessage(); + }; + 'use strict'; + var _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function(obj) { + return typeof obj; + } : function(obj) { + return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; + }; + function normalizeRelatedNodes(node, options) { + 'use strict'; + [ 'any', 'all', 'none' ].forEach(function(type) { + if (!Array.isArray(node[type])) { + return; + } + node[type].filter(function(checkRes) { + return Array.isArray(checkRes.relatedNodes); + }).forEach(function(checkRes) { + checkRes.relatedNodes = checkRes.relatedNodes.map(function(relatedNode) { + var res = { + html: relatedNode.source + }; + if (options.elementRef && !relatedNode.fromFrame) { + res.element = relatedNode.element; + } + if (options.selectors !== false || relatedNode.fromFrame) { + res.target = relatedNode.selector; + } + if (options.xpath) { + res.xpath = relatedNode.xpath; + } + return res; + }); + }); + }); + } + var resultKeys = axe.constants.resultGroups; + helpers.processAggregate = function(results, options) { + var resultObject = axe.utils.aggregateResult(results); + resultObject.timestamp = new Date().toISOString(); + resultObject.url = window.location.href; + resultKeys.forEach(function(key) { + resultObject[key] = (resultObject[key] || []).map(function(ruleResult) { + ruleResult = Object.assign({}, ruleResult); + if (Array.isArray(ruleResult.nodes) && ruleResult.nodes.length > 0) { + ruleResult.nodes = ruleResult.nodes.map(function(subResult) { + if (_typeof(subResult.node) === 'object') { + subResult.html = subResult.node.source; + if (options.elementRef && !subResult.node.fromFrame) { + subResult.element = subResult.node.element; + } + if (options.selectors !== false || subResult.node.fromFrame) { + subResult.target = subResult.node.selector; + } + if (options.xpath) { + subResult.xpath = subResult.node.xpath; + } + } + delete subResult.result; + delete subResult.node; + normalizeRelatedNodes(subResult, options); + return subResult; + }); + } + resultKeys.forEach(function(key) { + return delete ruleResult[key]; + }); + delete ruleResult.pageLevel; + delete ruleResult.result; + return ruleResult; + }); + }); + return resultObject; + }; + 'use strict'; + axe.addReporter('na', function(results, options, callback) { + 'use strict'; + if (typeof options === 'function') { + callback = options; + options = {}; + } + var out = helpers.processAggregate(results, options); + callback({ + violations: out.violations, + passes: out.passes, + incomplete: out.incomplete, + inapplicable: out.inapplicable, + timestamp: out.timestamp, + url: out.url + }); + }); + 'use strict'; + axe.addReporter('no-passes', function(results, options, callback) { + 'use strict'; + if (typeof options === 'function') { + callback = options; + options = {}; + } + var out = helpers.processAggregate(results, options); + callback({ + violations: out.violations, + timestamp: out.timestamp, + url: out.url + }); + }); + 'use strict'; + axe.addReporter('raw', function(results, options, callback) { + 'use strict'; + if (typeof options === 'function') { + callback = options; + options = {}; + } + callback(results); + }); + 'use strict'; + axe.addReporter('v1', function(results, options, callback) { + 'use strict'; + if (typeof options === 'function') { + callback = options; + options = {}; + } + var out = helpers.processAggregate(results, options); + out.violations.forEach(function(result) { + return result.nodes.forEach(function(nodeResult) { + nodeResult.failureSummary = helpers.failureSummary(nodeResult); + }); + }); + callback({ + violations: out.violations, + passes: out.passes, + incomplete: out.incomplete, + inapplicable: out.inapplicable, + timestamp: out.timestamp, + url: out.url + }); + }); + 'use strict'; + axe.addReporter('v2', function(results, options, callback) { + 'use strict'; + if (typeof options === 'function') { + callback = options; + options = {}; + } + var out = helpers.processAggregate(results, options); + callback({ + violations: out.violations, + passes: out.passes, + incomplete: out.incomplete, + inapplicable: out.inapplicable, + timestamp: out.timestamp, + url: out.url + }); + }, true); + 'use strict'; + axe.utils.aggregate = function(map, values, initial) { + values = values.slice(); + if (initial) { + values.push(initial); + } + var sorting = values.map(function(val) { + return map.indexOf(val); + }).sort(); + return map[sorting.pop()]; + }; + 'use strict'; + var checkMap = []; + checkMap[axe.constants.PASS_PRIO] = true; + checkMap[axe.constants.CANTTELL_PRIO] = null; + checkMap[axe.constants.FAIL_PRIO] = false; + var checkTypes = [ 'any', 'all', 'none' ]; + function anyAllNone(obj, functor) { + return checkTypes.reduce(function(out, type) { + out[type] = (obj[type] || []).map(function(val) { + return functor(val, type); + }); + return out; + }, {}); + } + axe.utils.aggregateChecks = function(nodeResOriginal) { + var nodeResult = Object.assign({}, nodeResOriginal); + anyAllNone(nodeResult, function(check, type) { + var i = checkMap.indexOf(check.result); + check.priority = i !== -1 ? i : axe.constants.CANTTELL_PRIO; + if (type === 'none') { + check.priority = 4 - check.priority; + } + }); + var priorities = anyAllNone(nodeResult, function(c) { + return c.priority; + }); + nodeResult.priority = Math.max(priorities.all.reduce(function(a, b) { + return Math.max(a, b); + }, 0), priorities.none.reduce(function(a, b) { + return Math.max(a, b); + }, 0), priorities.any.reduce(function(a, b) { + return Math.min(a, b); + }, 4) % 4); + var impacts = []; + checkTypes.forEach(function(type) { + nodeResult[type] = nodeResult[type].filter(function(check) { + return check.priority === nodeResult.priority; + }); + nodeResult[type].forEach(function(check) { + return impacts.push(check.impact); + }); + }); + if (nodeResult.priority === axe.constants.FAIL_PRIO) { + nodeResult.impact = axe.utils.aggregate(axe.constants.impact, impacts); + } else { + nodeResult.impact = null; + } + anyAllNone(nodeResult, function(c) { + delete c.result; + delete c.priority; + }); + nodeResult.result = axe.constants.results[nodeResult.priority]; + delete nodeResult.priority; + return nodeResult; + }; + 'use strict'; + function copyToGroup(resultObject, subResult, group) { + var resultCopy = Object.assign({}, subResult); + resultCopy.nodes = (resultCopy[group] || []).concat(); + axe.constants.resultGroups.forEach(function(group) { + delete resultCopy[group]; + }); + resultObject[group].push(resultCopy); + } + axe.utils.aggregateResult = function(results) { + var resultObject = {}; + axe.constants.resultGroups.forEach(function(groupName) { + return resultObject[groupName] = []; + }); + results.forEach(function(subResult) { + if (subResult.error) { + copyToGroup(resultObject, subResult, axe.constants.CANTTELL_GROUP); + } else if (subResult.result === axe.constants.NA) { + copyToGroup(resultObject, subResult, axe.constants.NA_GROUP); + } else { + axe.constants.resultGroups.forEach(function(group) { + if (Array.isArray(subResult[group]) && subResult[group].length > 0) { + copyToGroup(resultObject, subResult, group); + } + }); + } + }); + return resultObject; + }; + 'use strict'; + (function() { + axe.utils.aggregateRule = function(subResults) { + var ruleResult = {}; + subResults = subResults.map(function(subResult) { + if (subResult.any && subResult.all && subResult.none) { + return axe.utils.aggregateChecks(subResult); + } else if (Array.isArray(subResult.node)) { + return axe.utils.finalizeRuleResult(subResult); + } else { + throw new TypeError('Invalid Result type'); + } + }); + var resultList = subResults.map(function(node) { + return node.result; + }); + ruleResult.result = axe.utils.aggregate(axe.constants.results, resultList, ruleResult.result); + axe.constants.resultGroups.forEach(function(group) { + return ruleResult[group] = []; + }); + subResults.forEach(function(subResult) { + var groupName = axe.constants.resultGroupMap[subResult.result]; + ruleResult[groupName].push(subResult); + }); + var failGroup = axe.constants.FAIL_GROUP; + if (ruleResult[failGroup].length > 0) { + var impactList = ruleResult[failGroup].map(function(failure) { + return failure.impact; + }); + ruleResult.impact = axe.utils.aggregate(axe.constants.impact, impactList) || null; + } else { + ruleResult.impact = null; + } + return ruleResult; + }; + })(); + 'use strict'; + function areStylesSet(el, styles, stopAt) { + 'use strict'; + var styl = window.getComputedStyle(el, null); + var set = false; + if (!styl) { + return false; + } + styles.forEach(function(att) { + if (styl.getPropertyValue(att.property) === att.value) { + set = true; + } + }); + if (set) { + return true; + } + if (el.nodeName.toUpperCase() === stopAt.toUpperCase() || !el.parentNode) { + return false; + } + return areStylesSet(el.parentNode, styles, stopAt); + } + axe.utils.areStylesSet = areStylesSet; + 'use strict'; + axe.utils.checkHelper = function checkHelper(checkResult, options, resolve, reject) { + 'use strict'; + return { + isAsync: false, + async: function async() { + this.isAsync = true; + return function(result) { + if (result instanceof Error === false) { + checkResult.value = result; + resolve(checkResult); + } else { + reject(result); + } + }; + }, + data: function data(_data) { + checkResult.data = _data; + }, + relatedNodes: function relatedNodes(nodes) { + nodes = nodes instanceof Node ? [ nodes ] : axe.utils.toArray(nodes); + checkResult.relatedNodes = nodes.map(function(element) { + return new axe.utils.DqElement(element, options); + }); + } + }; + }; + 'use strict'; + var _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function(obj) { + return typeof obj; + } : function(obj) { + return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; + }; + axe.utils.clone = function(obj) { + 'use strict'; + var index, length, out = obj; + if (obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object') { + if (Array.isArray(obj)) { + out = []; + for (index = 0, length = obj.length; index < length; index++) { + out[index] = axe.utils.clone(obj[index]); + } + } else { + out = {}; + for (index in obj) { + out[index] = axe.utils.clone(obj[index]); + } + } + } + return out; + }; + 'use strict'; + function err(message, node) { + 'use strict'; + return new Error(message + ': ' + axe.utils.getSelector(node)); + } + axe.utils.sendCommandToFrame = function(node, parameters, resolve, reject) { + 'use strict'; + var win = node.contentWindow; + if (!win) { + axe.log('Frame does not have a content window', node); + resolve(null); + return; + } + var timeout = setTimeout(function() { + timeout = setTimeout(function() { + var errMsg = err('No response from frame', node); + if (!parameters.debug) { + axe.log(errMsg); + resolve(null); + } else { + reject(errMsg); + } + }, 0); + }, 500); + axe.utils.respondable(win, 'axe.ping', null, undefined, function() { + clearTimeout(timeout); + timeout = setTimeout(function() { + reject(err('Axe in frame timed out', node)); + }, 3e4); + axe.utils.respondable(win, 'axe.start', parameters, undefined, function(data) { + clearTimeout(timeout); + if (data instanceof Error === false) { + resolve(data); + } else { + reject(data); + } + }); + }); + }; + function collectResultsFromFrames(context, options, command, parameter, resolve, reject) { + 'use strict'; + var q = axe.utils.queue(); + var frames = context.frames; + frames.forEach(function(frame) { + var params = { + options: options, + command: command, + parameter: parameter, + context: { + initiator: false, + page: context.page, + include: frame.include || [], + exclude: frame.exclude || [] + } + }; + q.defer(function(res, rej) { + var node = frame.node; + axe.utils.sendCommandToFrame(node, params, function(data) { + if (data) { + return res({ + results: data, + frameElement: node, + frame: axe.utils.getSelector(node) + }); + } + res(null); + }, rej); + }); + }); + q.then(function(data) { + resolve(axe.utils.mergeResults(data, options)); + }).catch(reject); + } + axe.utils.collectResultsFromFrames = collectResultsFromFrames; + 'use strict'; + axe.utils.contains = function(node, otherNode) { + 'use strict'; + function containsShadowChild(node, otherNode) { + if (node.shadowId === otherNode.shadowId) { + return true; + } + return !!node.children.find(function(child) { + return containsShadowChild(child, otherNode); + }); + } + if (node.shadowId || otherNode.shadowId) { + return containsShadowChild(node, otherNode); + } + if (typeof node.actualNode.contains === 'function') { + return node.actualNode.contains(otherNode.actualNode); + } + return !!(node.actualNode.compareDocumentPosition(otherNode.actualNode) & 16); + }; + 'use strict'; + (function(axe) { + /*! + * The copyright below covers the code within this function block only + * + * Copyright (c) 2013 Dulin Marat + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + function CssSelectorParser() { + this.pseudos = {}; + this.attrEqualityMods = {}; + this.ruleNestingOperators = {}; + this.substitutesEnabled = false; + } + CssSelectorParser.prototype.registerSelectorPseudos = function(name) { + for (var j = 0, len = arguments.length; j < len; j++) { + name = arguments[j]; + this.pseudos[name] = 'selector'; + } + return this; + }; + CssSelectorParser.prototype.unregisterSelectorPseudos = function(name) { + for (var j = 0, len = arguments.length; j < len; j++) { + name = arguments[j]; + delete this.pseudos[name]; + } + return this; + }; + CssSelectorParser.prototype.registerNumericPseudos = function(name) { + for (var j = 0, len = arguments.length; j < len; j++) { + name = arguments[j]; + this.pseudos[name] = 'numeric'; + } + return this; + }; + CssSelectorParser.prototype.unregisterNumericPseudos = function(name) { + for (var j = 0, len = arguments.length; j < len; j++) { + name = arguments[j]; + delete this.pseudos[name]; + } + return this; + }; + CssSelectorParser.prototype.registerNestingOperators = function(operator) { + for (var j = 0, len = arguments.length; j < len; j++) { + operator = arguments[j]; + this.ruleNestingOperators[operator] = true; + } + return this; + }; + CssSelectorParser.prototype.unregisterNestingOperators = function(operator) { + for (var j = 0, len = arguments.length; j < len; j++) { + operator = arguments[j]; + delete this.ruleNestingOperators[operator]; + } + return this; + }; + CssSelectorParser.prototype.registerAttrEqualityMods = function(mod) { + for (var j = 0, len = arguments.length; j < len; j++) { + mod = arguments[j]; + this.attrEqualityMods[mod] = true; + } + return this; + }; + CssSelectorParser.prototype.unregisterAttrEqualityMods = function(mod) { + for (var j = 0, len = arguments.length; j < len; j++) { + mod = arguments[j]; + delete this.attrEqualityMods[mod]; + } + return this; + }; + CssSelectorParser.prototype.enableSubstitutes = function() { + this.substitutesEnabled = true; + return this; + }; + CssSelectorParser.prototype.disableSubstitutes = function() { + this.substitutesEnabled = false; + return this; + }; + function isIdentStart(c) { + return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c === '-' || c === '_'; + } + function isIdent(c) { + return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c === '-' || c === '_'; + } + function isHex(c) { + return c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F' || c >= '0' && c <= '9'; + } + function isDecimal(c) { + return c >= '0' && c <= '9'; + } + function isAttrMatchOperator(chr) { + return chr === '=' || chr === '^' || chr === '$' || chr === '*' || chr === '~'; + } + var identSpecialChars = { + '!': true, + '"': true, + '#': true, + $: true, + '%': true, + '&': true, + '\'': true, + '(': true, + ')': true, + '*': true, + '+': true, + ',': true, + '.': true, + '/': true, + ';': true, + '<': true, + '=': true, + '>': true, + '?': true, + '@': true, + '[': true, + '\\': true, + ']': true, + '^': true, + '`': true, + '{': true, + '|': true, + '}': true, + '~': true + }; + var strReplacementsRev = { + '\n': '\\n', + '\r': '\\r', + '\t': '\\t', + '\f': '\\f', + '\v': '\\v' + }; + var singleQuoteEscapeChars = { + n: '\n', + r: '\r', + t: '\t', + f: '\f', + '\\': '\\', + '\'': '\'' + }; + var doubleQuotesEscapeChars = { + n: '\n', + r: '\r', + t: '\t', + f: '\f', + '\\': '\\', + '"': '"' + }; + function ParseContext(str, pos, pseudos, attrEqualityMods, ruleNestingOperators, substitutesEnabled) { + var chr, getIdent, getStr, l, skipWhitespace; + l = str.length; + chr = null; + getStr = function getStr(quote, escapeTable) { + var esc, hex, result; + result = ''; + pos++; + chr = str.charAt(pos); + while (pos < l) { + if (chr === quote) { + pos++; + return result; + } else if (chr === '\\') { + pos++; + chr = str.charAt(pos); + if (chr === quote) { + result += quote; + } else if (esc = escapeTable[chr]) { + result += esc; + } else if (isHex(chr)) { + hex = chr; + pos++; + chr = str.charAt(pos); + while (isHex(chr)) { + hex += chr; + pos++; + chr = str.charAt(pos); + } + if (chr === ' ') { + pos++; + chr = str.charAt(pos); + } + result += String.fromCharCode(parseInt(hex, 16)); + continue; + } else { + result += chr; + } + } else { + result += chr; + } + pos++; + chr = str.charAt(pos); + } + return result; + }; + getIdent = function getIdent() { + var result = ''; + chr = str.charAt(pos); + while (pos < l) { + if (isIdent(chr)) { + result += chr; + } else if (chr === '\\') { + pos++; + if (pos >= l) { + throw Error('Expected symbol but end of file reached.'); + } + chr = str.charAt(pos); + if (identSpecialChars[chr]) { + result += chr; + } else if (isHex(chr)) { + var hex = chr; + pos++; + chr = str.charAt(pos); + while (isHex(chr)) { + hex += chr; + pos++; + chr = str.charAt(pos); + } + if (chr === ' ') { + pos++; + chr = str.charAt(pos); + } + result += String.fromCharCode(parseInt(hex, 16)); + continue; + } else { + result += chr; + } + } else { + return result; + } + pos++; + chr = str.charAt(pos); + } + return result; + }; + skipWhitespace = function skipWhitespace() { + chr = str.charAt(pos); + var result = false; + while (chr === ' ' || chr === '\t' || chr === '\n' || chr === '\r' || chr === '\f') { + result = true; + pos++; + chr = str.charAt(pos); + } + return result; + }; + this.parse = function() { + var res = this.parseSelector(); + if (pos < l) { + throw Error('Rule expected but "' + str.charAt(pos) + '" found.'); + } + return res; + }; + this.parseSelector = function() { + var res; + var selector = res = this.parseSingleSelector(); + chr = str.charAt(pos); + while (chr === ',') { + pos++; + skipWhitespace(); + if (res.type !== 'selectors') { + res = { + type: 'selectors', + selectors: [ selector ] + }; + } + selector = this.parseSingleSelector(); + if (!selector) { + throw Error('Rule expected after ",".'); + } + res.selectors.push(selector); + } + return res; + }; + this.parseSingleSelector = function() { + skipWhitespace(); + var selector = { + type: 'ruleSet' + }; + var rule = this.parseRule(); + if (!rule) { + return null; + } + var currentRule = selector; + while (rule) { + rule.type = 'rule'; + currentRule.rule = rule; + currentRule = rule; + skipWhitespace(); + chr = str.charAt(pos); + if (pos >= l || chr === ',' || chr === ')') { + break; + } + if (ruleNestingOperators[chr]) { + var op = chr; + pos++; + skipWhitespace(); + rule = this.parseRule(); + if (!rule) { + throw Error('Rule expected after "' + op + '".'); + } + rule.nestingOperator = op; + } else { + rule = this.parseRule(); + if (rule) { + rule.nestingOperator = null; + } + } + } + return selector; + }; + this.parseRule = function() { + var rule = null; + while (pos < l) { + chr = str.charAt(pos); + if (chr === '*') { + pos++; + (rule = rule || {}).tagName = '*'; + } else if (isIdentStart(chr) || chr === '\\') { + (rule = rule || {}).tagName = getIdent(); + } else if (chr === '.') { + pos++; + rule = rule || {}; + (rule.classNames = rule.classNames || []).push(getIdent()); + } else if (chr === '#') { + pos++; + (rule = rule || {}).id = getIdent(); + } else if (chr === '[') { + pos++; + skipWhitespace(); + var attr = { + name: getIdent() + }; + skipWhitespace(); + if (chr === ']') { + pos++; + } else { + var operator = ''; + if (attrEqualityMods[chr]) { + operator = chr; + pos++; + chr = str.charAt(pos); + } + if (pos >= l) { + throw Error('Expected "=" but end of file reached.'); + } + if (chr !== '=') { + throw Error('Expected "=" but "' + chr + '" found.'); + } + attr.operator = operator + '='; + pos++; + skipWhitespace(); + var attrValue = ''; + attr.valueType = 'string'; + if (chr === '"') { + attrValue = getStr('"', doubleQuotesEscapeChars); + } else if (chr === '\'') { + attrValue = getStr('\'', singleQuoteEscapeChars); + } else if (substitutesEnabled && chr === '$') { + pos++; + attrValue = getIdent(); + attr.valueType = 'substitute'; + } else { + while (pos < l) { + if (chr === ']') { + break; + } + attrValue += chr; + pos++; + chr = str.charAt(pos); + } + attrValue = attrValue.trim(); + } + skipWhitespace(); + if (pos >= l) { + throw Error('Expected "]" but end of file reached.'); + } + if (chr !== ']') { + throw Error('Expected "]" but "' + chr + '" found.'); + } + pos++; + attr.value = attrValue; + } + rule = rule || {}; + (rule.attrs = rule.attrs || []).push(attr); + } else if (chr === ':') { + pos++; + var pseudoName = getIdent(); + var pseudo = { + name: pseudoName + }; + if (chr === '(') { + pos++; + var value = ''; + skipWhitespace(); + if (pseudos[pseudoName] === 'selector') { + pseudo.valueType = 'selector'; + value = this.parseSelector(); + } else { + pseudo.valueType = pseudos[pseudoName] || 'string'; + if (chr === '"') { + value = getStr('"', doubleQuotesEscapeChars); + } else if (chr === '\'') { + value = getStr('\'', singleQuoteEscapeChars); + } else if (substitutesEnabled && chr === '$') { + pos++; + value = getIdent(); + pseudo.valueType = 'substitute'; + } else { + while (pos < l) { + if (chr === ')') { + break; + } + value += chr; + pos++; + chr = str.charAt(pos); + } + value = value.trim(); + } + skipWhitespace(); + } + if (pos >= l) { + throw Error('Expected ")" but end of file reached.'); + } + if (chr !== ')') { + throw Error('Expected ")" but "' + chr + '" found.'); + } + pos++; + pseudo.value = value; + } + rule = rule || {}; + (rule.pseudos = rule.pseudos || []).push(pseudo); + } else { + break; + } + } + return rule; + }; + return this; + } + CssSelectorParser.prototype.parse = function(str) { + var context = new ParseContext(str, 0, this.pseudos, this.attrEqualityMods, this.ruleNestingOperators, this.substitutesEnabled); + return context.parse(); + }; + CssSelectorParser.prototype.escapeIdentifier = function(s) { + var result = ''; + var i = 0; + var len = s.length; + while (i < len) { + var chr = s.charAt(i); + if (identSpecialChars[chr]) { + result += '\\' + chr; + } else { + if (!(chr === '_' || chr === '-' || chr >= 'A' && chr <= 'Z' || chr >= 'a' && chr <= 'z' || i !== 0 && chr >= '0' && chr <= '9')) { + var charCode = chr.charCodeAt(0); + if ((charCode & 63488) === 55296) { + var extraCharCode = s.charCodeAt(i++); + if ((charCode & 64512) !== 55296 || (extraCharCode & 64512) !== 56320) { + throw Error('UCS-2(decode): illegal sequence'); + } + charCode = ((charCode & 1023) << 10) + (extraCharCode & 1023) + 65536; + } + result += '\\' + charCode.toString(16) + ' '; + } else { + result += chr; + } + } + i++; + } + return result; + }; + CssSelectorParser.prototype.escapeStr = function(s) { + var result = ''; + var i = 0; + var len = s.length; + var chr, replacement; + while (i < len) { + chr = s.charAt(i); + if (chr === '"') { + chr = '\\"'; + } else if (chr === '\\') { + chr = '\\\\'; + } else if (replacement = strReplacementsRev[chr]) { + chr = replacement; + } + result += chr; + i++; + } + return '"' + result + '"'; + }; + CssSelectorParser.prototype.render = function(path) { + return this._renderEntity(path).trim(); + }; + CssSelectorParser.prototype._renderEntity = function(entity) { + var currentEntity, parts, res; + res = ''; + switch (entity.type) { + case 'ruleSet': + currentEntity = entity.rule; + parts = []; + while (currentEntity) { + if (currentEntity.nestingOperator) { + parts.push(currentEntity.nestingOperator); + } + parts.push(this._renderEntity(currentEntity)); + currentEntity = currentEntity.rule; + } + res = parts.join(' '); + break; + + case 'selectors': + res = entity.selectors.map(this._renderEntity, this).join(', '); + break; + + case 'rule': + if (entity.tagName) { + if (entity.tagName === '*') { + res = '*'; + } else { + res = this.escapeIdentifier(entity.tagName); + } + } + if (entity.id) { + res += '#' + this.escapeIdentifier(entity.id); + } + if (entity.classNames) { + res += entity.classNames.map(function(cn) { + return '.' + this.escapeIdentifier(cn); + }, this).join(''); + } + if (entity.attrs) { + res += entity.attrs.map(function(attr) { + if (attr.operator) { + if (attr.valueType === 'substitute') { + return '[' + this.escapeIdentifier(attr.name) + attr.operator + '$' + attr.value + ']'; + } else { + return '[' + this.escapeIdentifier(attr.name) + attr.operator + this.escapeStr(attr.value) + ']'; + } + } else { + return '[' + this.escapeIdentifier(attr.name) + ']'; + } + }, this).join(''); + } + if (entity.pseudos) { + res += entity.pseudos.map(function(pseudo) { + if (pseudo.valueType) { + if (pseudo.valueType === 'selector') { + return ':' + this.escapeIdentifier(pseudo.name) + '(' + this._renderEntity(pseudo.value) + ')'; + } else if (pseudo.valueType === 'substitute') { + return ':' + this.escapeIdentifier(pseudo.name) + '($' + pseudo.value + ')'; + } else if (pseudo.valueType === 'numeric') { + return ':' + this.escapeIdentifier(pseudo.name) + '(' + pseudo.value + ')'; + } else { + return ':' + this.escapeIdentifier(pseudo.name) + '(' + this.escapeIdentifier(pseudo.value) + ')'; + } + } else { + return ':' + this.escapeIdentifier(pseudo.name); + } + }, this).join(''); + } + break; + + default: + throw Error('Unknown entity type: "' + entity.type(+'".')); + } + return res; + }; + var parser = new CssSelectorParser(); + parser.registerNestingOperators('>'); + axe.utils.cssParser = parser; + })(axe); + 'use strict'; + function truncate(str, maxLength) { + maxLength = maxLength || 300; + if (str.length > maxLength) { + var index = str.indexOf('>'); + str = str.substring(0, index + 1); + } + return str; + } + function getSource(element) { + var source = element.outerHTML; + if (!source && typeof XMLSerializer === 'function') { + source = new XMLSerializer().serializeToString(element); + } + return truncate(source || ''); + } + function DqElement(element, options, spec) { + this._fromFrame = !!spec; + this.spec = spec || {}; + if (options && options.absolutePaths) { + this._options = { + toRoot: true + }; + } + this.source = this.spec.source !== undefined ? this.spec.source : getSource(element); + this._element = element; + } + DqElement.prototype = { + get selector() { + return this.spec.selector || [ axe.utils.getSelector(this.element, this._options) ]; + }, + get xpath() { + return this.spec.xpath || [ axe.utils.getXpath(this.element) ]; + }, + get element() { + return this._element; + }, + get fromFrame() { + return this._fromFrame; + }, + toJSON: function toJSON() { + 'use strict'; + return { + selector: this.selector, + source: this.source, + xpath: this.xpath + }; + } + }; + DqElement.fromFrame = function(node, options, frame) { + node.selector.unshift(frame.selector); + node.xpath.unshift(frame.xpath); + return new axe.utils.DqElement(frame.element, options, node); + }; + axe.utils.DqElement = DqElement; + 'use strict'; + axe.utils.matchesSelector = function() { + 'use strict'; + var method; + function getMethod(win) { + var index, candidate, elProto = win.Element.prototype, candidates = [ 'matches', 'matchesSelector', 'mozMatchesSelector', 'webkitMatchesSelector', 'msMatchesSelector' ], length = candidates.length; + for (index = 0; index < length; index++) { + candidate = candidates[index]; + if (elProto[candidate]) { + return candidate; + } + } + } + return function(node, selector) { + if (!method || !node[method]) { + method = getMethod(node.ownerDocument.defaultView); + } + return node[method](selector); + }; + }(); + 'use strict'; + axe.utils.escapeSelector = function(value) { + 'use strict'; + var string = String(value); + var length = string.length; + var index = -1; + var codeUnit; + var result = ''; + var firstCodeUnit = string.charCodeAt(0); + while (++index < length) { + codeUnit = string.charCodeAt(index); + if (codeUnit == 0) { + throw new Error('INVALID_CHARACTER_ERR'); + } + if (codeUnit >= 1 && codeUnit <= 31 || codeUnit >= 127 && codeUnit <= 159 || index == 0 && codeUnit >= 48 && codeUnit <= 57 || index == 1 && codeUnit >= 48 && codeUnit <= 57 && firstCodeUnit == 45) { + result += '\\' + codeUnit.toString(16) + ' '; + continue; + } + if (index == 1 && codeUnit == 45 && firstCodeUnit == 45) { + result += '\\' + string.charAt(index); + continue; + } + if (codeUnit >= 128 || codeUnit == 45 || codeUnit == 95 || codeUnit >= 48 && codeUnit <= 57 || codeUnit >= 65 && codeUnit <= 90 || codeUnit >= 97 && codeUnit <= 122) { + result += string.charAt(index); + continue; + } + result += '\\' + string.charAt(index); + } + return result; + }; + 'use strict'; + axe.utils.extendMetaData = function(to, from) { + Object.assign(to, from); + Object.keys(from).filter(function(prop) { + return typeof from[prop] === 'function'; + }).forEach(function(prop) { + to[prop] = null; + try { + to[prop] = from[prop](to); + } catch (e) {} + }); + }; + 'use strict'; + axe.utils.finalizeRuleResult = function(ruleResult) { + Object.assign(ruleResult, axe.utils.aggregateRule(ruleResult.nodes)); + delete ruleResult.nodes; + return ruleResult; + }; + 'use strict'; + var _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function(obj) { + return typeof obj; + } : function(obj) { + return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; + }; + axe.utils.findBy = function(array, key, value) { + if (Array.isArray(array)) { + return array.find(function(obj) { + return (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj[key] === value; + }); + } + }; + 'use strict'; + var axe = axe || { + utils: {} + }; + function virtualDOMfromNode(node, shadowId) { + return { + shadowId: shadowId, + children: [], + actualNode: node + }; + } + function getSlotChildren(node) { + var retVal = []; + node = node.firstChild; + while (node) { + retVal.push(node); + node = node.nextSibling; + } + return retVal; + } + axe.utils.getFlattenedTree = function(node, shadowId) { + var retVal, realArray, nodeName; + function reduceShadowDOM(res, child) { + var replacements = axe.utils.getFlattenedTree(child, shadowId); + if (replacements) { + res = res.concat(replacements); + } + return res; + } + if (node.documentElement) { + node = node.documentElement; + } + nodeName = node.nodeName.toLowerCase(); + if (node.shadowRoot && nodeName !== 'marquee') { + shadowId = 'a' + Math.random().toString().substring(2); + realArray = Array.from(node.shadowRoot.childNodes); + return realArray.reduce(reduceShadowDOM, []); + } else { + if (nodeName === 'content') { + realArray = Array.from(node.getDistributedNodes()); + return realArray.reduce(reduceShadowDOM, []); + } else if (nodeName === 'slot') { + realArray = Array.from(node.assignedNodes()); + if (!realArray.length) { + realArray = getSlotChildren(node); + } + var styl = window.getComputedStyle(node); + if (false && styl.display !== 'contents') { + retVal = virtualDOMfromNode(node, shadowId); + retVal.children = realArray.reduce(reduceShadowDOM, []); + return [ retVal ]; + } else { + return realArray.reduce(reduceShadowDOM, []); + } + } else { + if (node.nodeType === 1) { + retVal = virtualDOMfromNode(node, shadowId); + realArray = Array.from(node.childNodes); + retVal.children = realArray.reduce(reduceShadowDOM, []); + return [ retVal ]; + } else if (node.nodeType === 3) { + return [ virtualDOMfromNode(node) ]; + } + return undefined; + } + } + }; + axe.utils.getNodeFromTree = function(vNode, node) { + var found; + vNode.children.forEach(function(candidate) { + var retVal; + if (candidate.actualNode === node) { + found = candidate; + } else { + retVal = axe.utils.getNodeFromTree(candidate, node); + if (retVal) { + found = retVal; + } + } + }); + return found; + }; + 'use strict'; + axe.utils.getAllChecks = function getAllChecks(object) { + 'use strict'; + var result = []; + return result.concat(object.any || []).concat(object.all || []).concat(object.none || []); + }; + 'use strict'; + axe.utils.getCheckOption = function(check, ruleID, options) { + var ruleCheckOption = ((options.rules && options.rules[ruleID] || {}).checks || {})[check.id]; + var checkOption = (options.checks || {})[check.id]; + var enabled = check.enabled; + var opts = check.options; + if (checkOption) { + if (checkOption.hasOwnProperty('enabled')) { + enabled = checkOption.enabled; + } + if (checkOption.hasOwnProperty('options')) { + opts = checkOption.options; + } + } + if (ruleCheckOption) { + if (ruleCheckOption.hasOwnProperty('enabled')) { + enabled = ruleCheckOption.enabled; + } + if (ruleCheckOption.hasOwnProperty('options')) { + opts = ruleCheckOption.options; + } + } + return { + enabled: enabled, + options: opts, + absolutePaths: options.absolutePaths + }; + }; + 'use strict'; + var _slicedToArray = function() { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) { + break; + } + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i['return']) { + _i['return'](); + } + } finally { + if (_d) { + throw _e; + } + } + } + return _arr; + } + return function(arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError('Invalid attempt to destructure non-iterable instance'); + } + }; + }(); + function isMostlyNumbers() { + var str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + return str.length !== 0 && (str.match(/[0-9]/g) || '').length >= str.length / 2; + } + function splitString(str, splitIndex) { + return [ str.substring(0, splitIndex), str.substring(splitIndex) ]; + } + function uriParser(url) { + var original = url; + var protocol = '', domain = '', port = '', path = '', query = '', hash = ''; + if (url.includes('#')) { + var _splitString = splitString(url, url.indexOf('#')); + var _splitString2 = _slicedToArray(_splitString, 2); + url = _splitString2[0]; + hash = _splitString2[1]; + } + if (url.includes('?')) { + var _splitString3 = splitString(url, url.indexOf('?')); + var _splitString4 = _slicedToArray(_splitString3, 2); + url = _splitString4[0]; + query = _splitString4[1]; + } + if (url.includes('://')) { + var _url$split = url.split('://'); + var _url$split2 = _slicedToArray(_url$split, 2); + protocol = _url$split2[0]; + url = _url$split2[1]; + var _splitString5 = splitString(url, url.indexOf('/')); + var _splitString6 = _slicedToArray(_splitString5, 2); + domain = _splitString6[0]; + url = _splitString6[1]; + } else if (url.substr(0, 2) === '//') { + url = url.substr(2); + var _splitString7 = splitString(url, url.indexOf('/')); + var _splitString8 = _slicedToArray(_splitString7, 2); + domain = _splitString8[0]; + url = _splitString8[1]; + } + if (domain.substr(0, 4) === 'www.') { + domain = domain.substr(4); + } + if (domain && domain.includes(':')) { + var _splitString9 = splitString(domain, domain.indexOf(':')); + var _splitString10 = _slicedToArray(_splitString9, 2); + domain = _splitString10[0]; + port = _splitString10[1]; + } + path = url; + return { + original: original, + protocol: protocol, + domain: domain, + port: port, + path: path, + query: query, + hash: hash + }; + } + axe.utils.getFriendlyUriEnd = function getFriendlyUriEnd() { + var uri = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + if (uri.length <= 1 || uri.substr(0, 5) === 'data:' || uri.substr(0, 11) === 'javascript:' || uri.includes('?')) { + return; + } + var currentDomain = options.currentDomain, _options$maxLength = options.maxLength, maxLength = _options$maxLength === undefined ? 25 : _options$maxLength; + var _uriParser = uriParser(uri), path = _uriParser.path, domain = _uriParser.domain, hash = _uriParser.hash; + var pathEnd = path.substr(path.substr(0, path.length - 2).lastIndexOf('/') + 1); + if (hash) { + if (pathEnd && (pathEnd + hash).length <= maxLength) { + return pathEnd + hash; + } else if (pathEnd.length < 2 && hash.length > 2 && hash.length <= maxLength) { + return hash; + } else { + return; + } + } else if (domain && domain.length < maxLength && path.length <= 1) { + return domain + path; + } + if (path === '/' + pathEnd && domain && currentDomain && domain !== currentDomain && (domain + path).length <= maxLength) { + return domain + path; + } + var lastDotIndex = pathEnd.lastIndexOf('.'); + if ((lastDotIndex === -1 || lastDotIndex > 1) && (lastDotIndex !== -1 || pathEnd.length > 2) && pathEnd.length <= maxLength && !pathEnd.match(/index(\.[a-zA-Z]{2-4})?/) && !isMostlyNumbers(pathEnd)) { + return pathEnd; + } + }; + 'use strict'; + function _toConsumableArray(arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { + arr2[i] = arr[i]; + } + return arr2; + } else { + return Array.from(arr); + } + } + var escapeSelector = axe.utils.escapeSelector; + function isUncommonClassName(className) { + return ![ 'focus', 'hover', 'hidden', 'visible', 'dirty', 'touched', 'valid', 'disable', 'enable', 'active', 'col-' ].find(function(str) { + return className.includes(str); + }); + } + function getDistinctClassList(elm) { + if (!elm.classList || elm.classList.length === 0) { + return []; + } + var siblings = elm.parentNode && Array.from(elm.parentNode.children || '') || []; + return siblings.reduce(function(classList, childElm) { + if (elm === childElm) { + return classList; + } else { + return classList.filter(function(classItem) { + return !childElm.classList.contains(classItem); + }); + } + }, Array.from(elm.classList).filter(isUncommonClassName)); + } + var commonNodes = [ 'div', 'span', 'p', 'b', 'i', 'u', 'strong', 'em', 'h2', 'h3' ]; + function getNthChildString(elm, selector) { + var siblings = elm.parentNode && Array.from(elm.parentNode.children || '') || []; + var hasMatchingSiblings = siblings.find(function(sibling) { + return sibling !== elm && axe.utils.matchesSelector(sibling, selector); + }); + if (hasMatchingSiblings) { + var nthChild = 1 + siblings.indexOf(elm); + return ':nth-child(' + nthChild + ')'; + } else { + return ''; + } + } + var createSelector = { + getElmId: function getElmId(elm) { + if (!elm.id) { + return; + } + var doc = elm.getRootNode && elm.getRootNode() || document; + var id = '#' + escapeSelector(elm.id || ''); + if (!id.match(/player_uid_/) && doc.querySelectorAll(id).length === 1) { + return id; + } + }, + getCustomElm: function getCustomElm(elm, _ref) { + var isCustomElm = _ref.isCustomElm, nodeName = _ref.nodeName; + if (isCustomElm) { + return nodeName; + } + }, + getElmRoleProp: function getElmRoleProp(elm) { + if (elm.hasAttribute('role')) { + return '[role="' + escapeSelector(elm.getAttribute('role')) + '"]'; + } + }, + getUncommonElm: function getUncommonElm(elm, _ref2) { + var isCommonElm = _ref2.isCommonElm, isCustomElm = _ref2.isCustomElm, nodeName = _ref2.nodeName; + if (!isCommonElm && !isCustomElm) { + nodeName = escapeSelector(nodeName); + if (nodeName === 'input' && elm.hasAttribute('type')) { + nodeName += '[type="' + elm.type + '"]'; + } + return nodeName; + } + }, + getElmNameProp: function getElmNameProp(elm) { + if (!elm.id && elm.name) { + return '[name="' + escapeSelector(elm.name) + '"]'; + } + }, + getDistinctClass: function getDistinctClass(elm, _ref3) { + var distinctClassList = _ref3.distinctClassList; + if (distinctClassList.length > 0 && distinctClassList.length < 3) { + return '.' + distinctClassList.map(escapeSelector).join('.'); + } + }, + getFileRefProp: function getFileRefProp(elm) { + var attr = void 0; + if (elm.hasAttribute('href')) { + attr = 'href'; + } else if (elm.hasAttribute('src')) { + attr = 'src'; + } else { + return; + } + var friendlyUriEnd = axe.utils.getFriendlyUriEnd(elm.getAttribute(attr)); + if (friendlyUriEnd) { + return '[' + attr + '$="' + encodeURI(friendlyUriEnd) + '"]'; + } + }, + getCommonName: function getCommonName(elm, _ref4) { + var nodeName = _ref4.nodeName, isCommonElm = _ref4.isCommonElm; + if (isCommonElm) { + return nodeName; + } + } + }; + function getElmFeatures(elm, featureCount) { + var nodeName = elm.nodeName.toLowerCase(); + var classList = Array.from(elm.classList) || []; + var props = { + nodeName: nodeName, + classList: classList, + isCustomElm: nodeName.includes('-'), + isCommonElm: commonNodes.includes(nodeName), + distinctClassList: getDistinctClassList(elm) + }; + return [ createSelector.getCustomElm, createSelector.getElmRoleProp, createSelector.getUncommonElm, createSelector.getElmNameProp, createSelector.getDistinctClass, createSelector.getFileRefProp, createSelector.getCommonName ].reduce(function(features, func) { + if (features.length === featureCount) { + return features; + } + var feature = func(elm, props); + if (feature) { + if (!feature[0].match(/[a-z]/)) { + features.push(feature); + } else { + features.unshift(feature); + } + } + return features; + }, []); + } + function generateSelector(elm, options, doc) { + var selector = void 0, addParent = void 0; + var _options$isUnique = options.isUnique, isUnique = _options$isUnique === undefined ? false : _options$isUnique; + var idSelector = createSelector.getElmId(elm); + var _options$featureCount = options.featureCount, featureCount = _options$featureCount === undefined ? 2 : _options$featureCount, _options$minDepth = options.minDepth, minDepth = _options$minDepth === undefined ? 1 : _options$minDepth, _options$toRoot = options.toRoot, toRoot = _options$toRoot === undefined ? false : _options$toRoot, _options$childSelecto = options.childSelectors, childSelectors = _options$childSelecto === undefined ? [] : _options$childSelecto; + if (idSelector) { + selector = idSelector; + isUnique = true; + } else { + selector = getElmFeatures(elm, featureCount).join(''); + selector += getNthChildString(elm, selector); + isUnique = options.isUnique || doc.querySelectorAll(selector).length === 1; + if (!isUnique && elm === document.documentElement) { + selector += ':root'; + } + addParent = minDepth !== 0 || !isUnique; + } + var selectorParts = [ selector ].concat(_toConsumableArray(childSelectors)); + if (elm.parentElement && elm.parentElement.nodeType !== 11 && (toRoot || addParent)) { + return generateSelector(elm.parentNode, { + toRoot: toRoot, + isUnique: isUnique, + childSelectors: selectorParts, + featureCount: 1, + minDepth: minDepth - 1 + }, doc); + } else { + return selectorParts.join(' > '); + } + } + axe.utils.getSelector = function createUniqueSelector(elm) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + if (!elm) { + return ''; + } + var doc = elm.getRootNode && elm.getRootNode() || document; + if (doc.nodeType === 11) { + var stack = []; + while (doc.nodeType === 11) { + stack.push({ + elm: elm, + doc: doc + }); + elm = doc.host; + doc = elm.getRootNode(); + } + stack.push({ + elm: elm, + doc: doc + }); + return stack.reverse().map(function(comp) { + return generateSelector(comp.elm, options, comp.doc); + }); + } else { + return generateSelector(elm, options, doc); + } + }; + 'use strict'; + function getXPathArray(node, path) { + var sibling, count; + if (!node) { + return []; + } + if (!path && node.nodeType === 9) { + path = [ { + str: 'html' + } ]; + return path; + } + path = path || []; + if (node.parentNode && node.parentNode !== node) { + path = getXPathArray(node.parentNode, path); + } + if (node.previousSibling) { + count = 1; + sibling = node.previousSibling; + do { + if (sibling.nodeType === 1 && sibling.nodeName === node.nodeName) { + count++; + } + sibling = sibling.previousSibling; + } while (sibling); + if (count === 1) { + count = null; + } + } else if (node.nextSibling) { + sibling = node.nextSibling; + do { + if (sibling.nodeType === 1 && sibling.nodeName === node.nodeName) { + count = 1; + sibling = null; + } else { + count = null; + sibling = sibling.previousSibling; + } + } while (sibling); + } + if (node.nodeType === 1) { + var element = {}; + element.str = node.nodeName.toLowerCase(); + if (node.getAttribute && node.getAttribute('id') && node.ownerDocument.querySelectorAll('#' + axe.utils.escapeSelector(node.id)).length === 1) { + element.id = node.getAttribute('id'); + } + if (count > 1) { + element.count = count; + } + path.push(element); + } + return path; + } + function xpathToString(xpathArray) { + return xpathArray.reduce(function(str, elm) { + if (elm.id) { + return '/' + elm.str + '[@id=\'' + elm.id + '\']'; + } else { + return str + ('/' + elm.str) + (elm.count > 0 ? '[' + elm.count + ']' : ''); + } + }, ''); + } + axe.utils.getXpath = function getXpath(node) { + var xpathArray = getXPathArray(node); + return xpathToString(xpathArray); + }; + 'use strict'; + var styleSheet; + function injectStyle(style) { + 'use strict'; + if (styleSheet && styleSheet.parentNode) { + if (styleSheet.styleSheet === undefined) { + styleSheet.appendChild(document.createTextNode(style)); + } else { + styleSheet.styleSheet.cssText += style; + } + return styleSheet; + } + if (!style) { + return; + } + var head = document.head || document.getElementsByTagName('head')[0]; + styleSheet = document.createElement('style'); + styleSheet.type = 'text/css'; + if (styleSheet.styleSheet === undefined) { + styleSheet.appendChild(document.createTextNode(style)); + } else { + styleSheet.styleSheet.cssText = style; + } + head.appendChild(styleSheet); + return styleSheet; + } + axe.utils.injectStyle = injectStyle; + 'use strict'; + axe.utils.isHidden = function isHidden(el, recursed) { + 'use strict'; + var parent; + if (el.nodeType === 9) { + return false; + } + if (el.nodeType === 11) { + el = el.host; + } + var style = window.getComputedStyle(el, null); + if (!style || !el.parentNode || style.getPropertyValue('display') === 'none' || !recursed && style.getPropertyValue('visibility') === 'hidden' || el.getAttribute('aria-hidden') === 'true') { + return true; + } + parent = el.assignedSlot ? el.assignedSlot : el.parentNode; + return axe.utils.isHidden(parent, true); + }; + 'use strict'; + function pushFrame(resultSet, options, frameElement, frameSelector) { + 'use strict'; + var frameXpath = axe.utils.getXpath(frameElement); + var frameSpec = { + element: frameElement, + selector: frameSelector, + xpath: frameXpath + }; + resultSet.forEach(function(res) { + res.node = axe.utils.DqElement.fromFrame(res.node, options, frameSpec); + var checks = axe.utils.getAllChecks(res); + if (checks.length) { + checks.forEach(function(check) { + check.relatedNodes = check.relatedNodes.map(function(node) { + return axe.utils.DqElement.fromFrame(node, options, frameSpec); + }); + }); + } + }); + } + function spliceNodes(target, to) { + 'use strict'; + var firstFromFrame = to[0].node, sorterResult, t; + for (var i = 0, l = target.length; i < l; i++) { + t = target[i].node; + sorterResult = axe.utils.nodeSorter({ + actualNode: t.element + }, { + actualNode: firstFromFrame.element + }); + if (sorterResult > 0 || sorterResult === 0 && firstFromFrame.selector.length < t.selector.length) { + target.splice.apply(target, [ i, 0 ].concat(to)); + return; + } + } + target.push.apply(target, to); + } + function normalizeResult(result) { + 'use strict'; + if (!result || !result.results) { + return null; + } + if (!Array.isArray(result.results)) { + return [ result.results ]; + } + if (!result.results.length) { + return null; + } + return result.results; + } + axe.utils.mergeResults = function mergeResults(frameResults, options) { + 'use strict'; + var result = []; + frameResults.forEach(function(frameResult) { + var results = normalizeResult(frameResult); + if (!results || !results.length) { + return; + } + results.forEach(function(ruleResult) { + if (ruleResult.nodes && frameResult.frame) { + pushFrame(ruleResult.nodes, options, frameResult.frameElement, frameResult.frame); + } + var res = axe.utils.findBy(result, 'id', ruleResult.id); + if (!res) { + result.push(ruleResult); + } else { + if (ruleResult.nodes.length) { + spliceNodes(res.nodes, ruleResult.nodes); + } + } + }); + }); + return result; + }; + 'use strict'; + axe.utils.nodeSorter = function nodeSorter(a, b) { + 'use strict'; + if (a.actualNode === b.actualNode) { + return 0; + } + if (a.actualNode.compareDocumentPosition(b.actualNode) & 4) { + return -1; + } + return 1; + }; + 'use strict'; + utils.performanceTimer = function() { + 'use strict'; + function now() { + if (window.performance && window.performance) { + return window.performance.now(); + } + } + var originalTime = null; + var lastRecordedTime = now(); + return { + start: function start() { + this.mark('mark_axe_start'); + }, + end: function end() { + this.mark('mark_axe_end'); + this.measure('axe', 'mark_axe_start', 'mark_axe_end'); + this.logMeasures('axe'); + }, + auditStart: function auditStart() { + this.mark('mark_audit_start'); + }, + auditEnd: function auditEnd() { + this.mark('mark_audit_end'); + this.measure('audit_start_to_end', 'mark_audit_start', 'mark_audit_end'); + this.logMeasures(); + }, + mark: function mark(markName) { + if (window.performance && window.performance.mark !== undefined) { + window.performance.mark(markName); + } + }, + measure: function measure(measureName, startMark, endMark) { + if (window.performance && window.performance.measure !== undefined) { + window.performance.measure(measureName, startMark, endMark); + } + }, + logMeasures: function logMeasures(measureName) { + function log(req) { + axe.log('Measure ' + req.name + ' took ' + req.duration + 'ms'); + } + if (window.performance && window.performance.getEntriesByType !== undefined) { + var measures = window.performance.getEntriesByType('measure'); + for (var i = 0; i < measures.length; ++i) { + var req = measures[i]; + if (req.name === measureName) { + log(req); + return; + } + log(req); + } + } + }, + timeElapsed: function timeElapsed() { + return now() - lastRecordedTime; + }, + reset: function reset() { + if (!originalTime) { + originalTime = now(); + } + lastRecordedTime = now(); + } + }; + }(); + 'use strict'; + if (typeof Object.assign !== 'function') { + (function() { + Object.assign = function(target) { + 'use strict'; + if (target === undefined || target === null) { + throw new TypeError('Cannot convert undefined or null to object'); + } + var output = Object(target); + for (var index = 1; index < arguments.length; index++) { + var source = arguments[index]; + if (source !== undefined && source !== null) { + for (var nextKey in source) { + if (source.hasOwnProperty(nextKey)) { + output[nextKey] = source[nextKey]; + } + } + } + } + return output; + }; + })(); + } + if (!Array.prototype.find) { + Array.prototype.find = function(predicate) { + if (this === null) { + throw new TypeError('Array.prototype.find called on null or undefined'); + } + if (typeof predicate !== 'function') { + throw new TypeError('predicate must be a function'); + } + var list = Object(this); + var length = list.length >>> 0; + var thisArg = arguments[1]; + var value; + for (var i = 0; i < length; i++) { + value = list[i]; + if (predicate.call(thisArg, value, i, list)) { + return value; + } + } + return undefined; + }; + } + axe.utils.pollyfillElementsFromPoint = function() { + if (document.elementsFromPoint) { + return document.elementsFromPoint; + } + if (document.msElementsFromPoint) { + return document.msElementsFromPoint; + } + var usePointer = function() { + var element = document.createElement('x'); + element.style.cssText = 'pointer-events:auto'; + return element.style.pointerEvents === 'auto'; + }(); + var cssProp = usePointer ? 'pointer-events' : 'visibility'; + var cssDisableVal = usePointer ? 'none' : 'hidden'; + var style = document.createElement('style'); + style.innerHTML = usePointer ? '* { pointer-events: all }' : '* { visibility: visible }'; + return function(x, y) { + var current, i, d; + var elements = []; + var previousPointerEvents = []; + document.head.appendChild(style); + while ((current = document.elementFromPoint(x, y)) && elements.indexOf(current) === -1) { + elements.push(current); + previousPointerEvents.push({ + value: current.style.getPropertyValue(cssProp), + priority: current.style.getPropertyPriority(cssProp) + }); + current.style.setProperty(cssProp, cssDisableVal, 'important'); + } + for (i = previousPointerEvents.length; !!(d = previousPointerEvents[--i]); ) { + elements[i].style.setProperty(cssProp, d.value ? d.value : '', d.priority); + } + document.head.removeChild(style); + return elements; + }; + }; + if (typeof window.addEventListener === 'function') { + document.elementsFromPoint = axe.utils.pollyfillElementsFromPoint(); + } + if (!Array.prototype.includes) { + Array.prototype.includes = function(searchElement) { + 'use strict'; + var O = Object(this); + var len = parseInt(O.length, 10) || 0; + if (len === 0) { + return false; + } + var n = parseInt(arguments[1], 10) || 0; + var k; + if (n >= 0) { + k = n; + } else { + k = len + n; + if (k < 0) { + k = 0; + } + } + var currentElement; + while (k < len) { + currentElement = O[k]; + if (searchElement === currentElement || searchElement !== searchElement && currentElement !== currentElement) { + return true; + } + k++; + } + return false; + }; + } + if (!Array.prototype.some) { + Array.prototype.some = function(fun) { + 'use strict'; + if (this == null) { + throw new TypeError('Array.prototype.some called on null or undefined'); + } + if (typeof fun !== 'function') { + throw new TypeError(); + } + var t = Object(this); + var len = t.length >>> 0; + var thisArg = arguments.length >= 2 ? arguments[1] : void 0; + for (var i = 0; i < len; i++) { + if (i in t && fun.call(thisArg, t[i], i, t)) { + return true; + } + } + return false; + }; + } + if (!Array.from) { + Array.from = function() { + var toStr = Object.prototype.toString; + var isCallable = function isCallable(fn) { + return typeof fn === 'function' || toStr.call(fn) === '[object Function]'; + }; + var toInteger = function toInteger(value) { + var number = Number(value); + if (isNaN(number)) { + return 0; + } + if (number === 0 || !isFinite(number)) { + return number; + } + return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number)); + }; + var maxSafeInteger = Math.pow(2, 53) - 1; + var toLength = function toLength(value) { + var len = toInteger(value); + return Math.min(Math.max(len, 0), maxSafeInteger); + }; + return function from(arrayLike) { + var C = this; + var items = Object(arrayLike); + if (arrayLike == null) { + throw new TypeError('Array.from requires an array-like object - not null or undefined'); + } + var mapFn = arguments.length > 1 ? arguments[1] : void undefined; + var T; + if (typeof mapFn !== 'undefined') { + if (!isCallable(mapFn)) { + throw new TypeError('Array.from: when provided, the second argument must be a function'); + } + if (arguments.length > 2) { + T = arguments[2]; + } + } + var len = toLength(items.length); + var A = isCallable(C) ? Object(new C(len)) : new Array(len); + var k = 0; + var kValue; + while (k < len) { + kValue = items[k]; + if (mapFn) { + A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k); + } else { + A[k] = kValue; + } + k += 1; + } + A.length = len; + return A; + }; + }(); + } + if (!String.prototype.includes) { + String.prototype.includes = function(search, start) { + if (typeof start !== 'number') { + start = 0; + } + if (start + search.length > this.length) { + return false; + } else { + return this.indexOf(search, start) !== -1; + } + }; + } + 'use strict'; + var _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function(obj) { + return typeof obj; + } : function(obj) { + return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; + }; + function getIncompleteReason(checkData, messages) { + function getDefaultMsg(messages) { + if (messages.incomplete && messages.incomplete.default) { + return messages.incomplete.default; + } else { + return helpers.incompleteFallbackMessage(); + } + } + if (checkData && checkData.missingData) { + try { + var msg = messages.incomplete[checkData.missingData[0].reason]; + if (!msg) { + throw new Error(); + } + return msg; + } catch (e) { + if (typeof checkData.missingData === 'string') { + return messages.incomplete[checkData.missingData]; + } else { + return getDefaultMsg(messages); + } + } + } else { + return getDefaultMsg(messages); + } + } + function extender(checksData, shouldBeTrue) { + 'use strict'; + return function(check) { + var sourceData = checksData[check.id] || {}; + var messages = sourceData.messages || {}; + var data = Object.assign({}, sourceData); + delete data.messages; + if (check.result === undefined) { + if (_typeof(messages.incomplete) === 'object') { + data.message = function() { + return getIncompleteReason(check.data, messages); + }; + } else { + data.message = messages.incomplete; + } + } else { + data.message = check.result === shouldBeTrue ? messages.pass : messages.fail; + } + axe.utils.extendMetaData(check, data); + }; + } + axe.utils.publishMetaData = function(ruleResult) { + 'use strict'; + var checksData = axe._audit.data.checks || {}; + var rulesData = axe._audit.data.rules || {}; + var rule = axe.utils.findBy(axe._audit.rules, 'id', ruleResult.id) || {}; + ruleResult.tags = axe.utils.clone(rule.tags || []); + var shouldBeTrue = extender(checksData, true); + var shouldBeFalse = extender(checksData, false); + ruleResult.nodes.forEach(function(detail) { + detail.any.forEach(shouldBeTrue); + detail.all.forEach(shouldBeTrue); + detail.none.forEach(shouldBeFalse); + }); + axe.utils.extendMetaData(ruleResult, axe.utils.clone(rulesData[ruleResult.id] || {})); + }; + 'use strict'; + var convertExpressions = function convertExpressions() {}; + var matchExpressions = function matchExpressions() {}; + function matchesTag(node, exp) { + return node.nodeType === 1 && (exp.tag === '*' || node.nodeName.toLowerCase() === exp.tag); + } + function matchesClasses(node, exp) { + return !exp.classes || exp.classes.reduce(function(result, cl) { + return result && node.className && node.className.match(cl.regexp); + }, true); + } + function matchesAttributes(node, exp) { + return !exp.attributes || exp.attributes.reduce(function(result, att) { + var nodeAtt = node.getAttribute(att.key); + return result && nodeAtt !== null && (!att.value || att.test(nodeAtt)); + }, true); + } + function matchesId(node, exp) { + return !exp.id || node.id === exp.id; + } + function matchesPseudos(target, exp) { + if (!exp.pseudos || exp.pseudos.reduce(function(result, pseudo) { + if (pseudo.name === 'not') { + return result && !matchExpressions([ target ], pseudo.expressions, false).length; + } + throw new Error('the pseudo selector ' + pseudo.name + ' has not yet been implemented'); + }, true)) { + return true; + } + return false; + } + function matchSelector(targets, exp, recurse) { + var result = []; + targets = Array.isArray(targets) ? targets : [ targets ]; + targets.forEach(function(target) { + if (matchesTag(target.actualNode, exp) && matchesClasses(target.actualNode, exp) && matchesAttributes(target.actualNode, exp) && matchesId(target.actualNode, exp) && matchesPseudos(target, exp)) { + result.push(target); + } + if (recurse) { + result = result.concat(matchSelector(target.children.filter(function(child) { + return !exp.id || child.shadowId === target.shadowId; + }), exp, recurse)); + } + }); + return result; + } + var escapeRegExp = function() { + /*! Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Levithan MIT License */ + var from = /(?=[\-\[\]{}()*+?.\\\^$|,#\s])/g; + var to = '\\'; + return function(string) { + return string.replace(from, to); + }; + }(); + var reUnescape = /\\/g; + function convertAttributes(atts) { + /*! Credit Mootools Copyright Mootools, MIT License */ + if (!atts) { + return; + } + return atts.map(function(att) { + var attributeKey = att.name.replace(reUnescape, ''); + var attributeValue = (att.value || '').replace(reUnescape, ''); + var test, regexp; + switch (att.operator) { + case '^=': + regexp = new RegExp('^' + escapeRegExp(attributeValue)); + break; + + case '$=': + regexp = new RegExp(escapeRegExp(attributeValue) + '$'); + break; + + case '~=': + regexp = new RegExp('(^|\\s)' + escapeRegExp(attributeValue) + '(\\s|$)'); + break; + + case '|=': + regexp = new RegExp('^' + escapeRegExp(attributeValue) + '(-|$)'); + break; + + case '=': + test = function test(value) { + return attributeValue === value; + }; + break; + + case '*=': + test = function test(value) { + return value && value.indexOf(attributeValue) > -1; + }; + break; + + case '!=': + test = function test(value) { + return attributeValue !== value; + }; + break; + + default: + test = function test(value) { + return !!value; + }; + } + if (attributeValue === '' && /^[*$^]=$/.test(att.operator)) { + test = function test() { + return false; + }; + } + if (!test) { + test = function test(value) { + return value && regexp.test(value); + }; + } + return { + key: attributeKey, + value: attributeValue, + test: test + }; + }); + } + function convertClasses(classes) { + if (!classes) { + return; + } + return classes.map(function(className) { + className = className.replace(reUnescape, ''); + return { + value: className, + regexp: new RegExp('(^|\\s)' + escapeRegExp(className) + '(\\s|$)') + }; + }); + } + function convertPseudos(pseudos) { + if (!pseudos) { + return; + } + return pseudos.map(function(p) { + var expressions; + if (p.name === 'not') { + expressions = axe.utils.cssParser.parse(p.value); + expressions = expressions.selectors ? expressions.selectors : [ expressions ]; + expressions = convertExpressions(expressions); + } + return { + name: p.name, + expressions: expressions, + value: p.value + }; + }); + } + convertExpressions = function convertExpressions(expressions) { + return expressions.map(function(exp) { + var newExp = []; + var rule = exp.rule; + while (rule) { + newExp.push({ + tag: rule.tagName ? rule.tagName.toLowerCase() : '*', + combinator: rule.nestingOperator ? rule.nestingOperator : ' ', + id: rule.id, + attributes: convertAttributes(rule.attrs), + classes: convertClasses(rule.classNames), + pseudos: convertPseudos(rule.pseudos) + }); + rule = rule.rule; + } + return newExp; + }); + }; + matchExpressions = function matchExpressions(domTree, expressions, recurse) { + return expressions.reduce(function(collected, exprArr) { + var candidates = domTree; + exprArr.forEach(function(exp, index) { + recurse = exp.combinator === '>' ? false : recurse; + if ([ ' ', '>' ].indexOf(exp.combinator) === -1) { + throw new Error('axe.utils.querySelectorAll does not support the combinator: ' + exp.combinator); + } + candidates = candidates.reduce(function(result, node) { + return result.concat(matchSelector(index ? node.children : node, exp, recurse)); + }, []); + }); + return collected.concat(candidates); + }, []); + }; + axe.utils.querySelectorAll = function(domTree, selector) { + domTree = Array.isArray(domTree) ? domTree : [ domTree ]; + var expressions = axe.utils.cssParser.parse(selector); + expressions = expressions.selectors ? expressions.selectors : [ expressions ]; + expressions = convertExpressions(expressions); + return matchExpressions(domTree, expressions, true); + }; + 'use strict'; + var _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function(obj) { + return typeof obj; + } : function(obj) { + return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; + }; + (function() { + 'use strict'; + function noop() {} + function funcGuard(f) { + if (typeof f !== 'function') { + throw new TypeError('Queue methods require functions as arguments'); + } + } + function queue() { + var tasks = []; + var started = 0; + var remaining = 0; + var completeQueue = noop; + var complete = false; + var err; + var defaultFail = function defaultFail(e) { + err = e; + setTimeout(function() { + if (err !== undefined && err !== null) { + axe.log('Uncaught error (of queue)', err); + } + }, 1); + }; + var failed = defaultFail; + function createResolve(i) { + return function(r) { + tasks[i] = r; + remaining -= 1; + if (!remaining && completeQueue !== noop) { + complete = true; + completeQueue(tasks); + } + }; + } + function abort(msg) { + completeQueue = noop; + failed(msg); + return tasks; + } + function pop() { + var length = tasks.length; + for (;started < length; started++) { + var task = tasks[started]; + try { + task.call(null, createResolve(started), abort); + } catch (e) { + abort(e); + } + } + } + var q = { + defer: function defer(fn) { + if ((typeof fn === 'undefined' ? 'undefined' : _typeof(fn)) === 'object' && fn.then && fn.catch) { + var defer = fn; + fn = function fn(resolve, reject) { + defer.then(resolve).catch(reject); + }; + } + funcGuard(fn); + if (err !== undefined) { + return; + } else if (complete) { + throw new Error('Queue already completed'); + } + tasks.push(fn); + ++remaining; + pop(); + return q; + }, + then: function then(fn) { + funcGuard(fn); + if (completeQueue !== noop) { + throw new Error('queue `then` already set'); + } + if (!err) { + completeQueue = fn; + if (!remaining) { + complete = true; + completeQueue(tasks); + } + } + return q; + }, + catch: function _catch(fn) { + funcGuard(fn); + if (failed !== defaultFail) { + throw new Error('queue `catch` already set'); + } + if (!err) { + failed = fn; + } else { + fn(err); + err = null; + } + return q; + }, + abort: abort + }; + return q; + } + axe.utils.queue = queue; + })(); + 'use strict'; + var _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function(obj) { + return typeof obj; + } : function(obj) { + return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj; + }; + (function(exports) { + 'use strict'; + var messages = {}, subscribers = {}; + function _getSource() { + var application = 'axe', version = '', src; + if (typeof axe !== 'undefined' && axe._audit && !axe._audit.application) { + application = axe._audit.application; + } + if (typeof axe !== 'undefined') { + version = axe.version; + } + src = application + '.' + version; + return src; + } + function verify(postedMessage) { + if ((typeof postedMessage === 'undefined' ? 'undefined' : _typeof(postedMessage)) === 'object' && typeof postedMessage.uuid === 'string' && postedMessage._respondable === true) { + var messageSource = _getSource(); + return postedMessage._source === messageSource || postedMessage._source === 'axe.x.y.z' || messageSource === 'axe.x.y.z'; + } + return false; + } + function post(win, topic, message, uuid, keepalive, callback) { + var error; + if (message instanceof Error) { + error = { + name: message.name, + message: message.message, + stack: message.stack + }; + message = undefined; + } + var data = { + uuid: uuid, + topic: topic, + message: message, + error: error, + _respondable: true, + _source: _getSource(), + _keepalive: keepalive + }; + if (typeof callback === 'function') { + messages[uuid] = callback; + } + win.postMessage(JSON.stringify(data), '*'); + } + function respondable(win, topic, message, keepalive, callback) { + var id = uuid.v1(); + post(win, topic, message, id, keepalive, callback); + } + respondable.subscribe = function(topic, callback) { + subscribers[topic] = callback; + }; + respondable.isInFrame = function(win) { + win = win || window; + return !!win.frameElement; + }; + function createResponder(source, topic, uuid) { + return function(message, keepalive, callback) { + post(source, topic, message, uuid, keepalive, callback); + }; + } + function publish(target, data, keepalive) { + var topic = data.topic; + var subscriber = subscribers[topic]; + if (subscriber) { + var responder = createResponder(target, null, data.uuid); + subscriber(data.message, keepalive, responder); + } + } + function buildErrorObject(error) { + var msg = error.message || 'Unknown error occurred'; + var ErrConstructor = window[error.name] || Error; + if (error.stack) { + msg += '\n' + error.stack.replace(error.message, ''); + } + return new ErrConstructor(msg); + } + function parseMessage(dataString) { + var data; + if (typeof dataString !== 'string') { + return; + } + try { + data = JSON.parse(dataString); + } catch (ex) {} + if (!verify(data)) { + return; + } + if (_typeof(data.error) === 'object') { + data.error = buildErrorObject(data.error); + } else { + data.error = undefined; + } + return data; + } + if (typeof window.addEventListener === 'function') { + window.addEventListener('message', function(e) { + var data = parseMessage(e.data); + if (!data) { + return; + } + var uuid = data.uuid; + var keepalive = data._keepalive; + var callback = messages[uuid]; + if (callback) { + var result = data.error || data.message; + var responder = createResponder(e.source, data.topic, uuid); + callback(result, keepalive, responder); + if (!keepalive) { + delete messages[uuid]; + } + } + if (!data.error) { + try { + publish(e.source, data, keepalive); + } catch (err) { + post(e.source, data.topic, err, uuid, false); + } + } + }, false); + } + exports.respondable = respondable; + })(utils); + 'use strict'; + function matchTags(rule, runOnly) { + 'use strict'; + var include, exclude, matching; + var defaultExclude = axe._audit && axe._audit.tagExclude ? axe._audit.tagExclude : []; + if (runOnly.include || runOnly.exclude) { + include = runOnly.include || []; + include = Array.isArray(include) ? include : [ include ]; + exclude = runOnly.exclude || []; + exclude = Array.isArray(exclude) ? exclude : [ exclude ]; + exclude = exclude.concat(defaultExclude.filter(function(tag) { + return include.indexOf(tag) === -1; + })); + } else { + include = Array.isArray(runOnly) ? runOnly : [ runOnly ]; + exclude = defaultExclude.filter(function(tag) { + return include.indexOf(tag) === -1; + }); + } + matching = include.some(function(tag) { + return rule.tags.indexOf(tag) !== -1; + }); + if (matching || include.length === 0 && rule.enabled !== false) { + return exclude.every(function(tag) { + return rule.tags.indexOf(tag) === -1; + }); + } else { + return false; + } + } + axe.utils.ruleShouldRun = function(rule, context, options) { + 'use strict'; + var runOnly = options.runOnly || {}; + var ruleOptions = (options.rules || {})[rule.id]; + if (rule.pageLevel && !context.page) { + return false; + } else if (runOnly.type === 'rule') { + return runOnly.values.indexOf(rule.id) !== -1; + } else if (ruleOptions && typeof ruleOptions.enabled === 'boolean') { + return ruleOptions.enabled; + } else if (runOnly.type === 'tag' && runOnly.values) { + return matchTags(rule, runOnly.values); + } else { + return matchTags(rule, []); + } + }; + 'use strict'; + function getDeepest(collection) { + 'use strict'; + return collection.sort(function(a, b) { + if (axe.utils.contains(a, b)) { + return 1; + } + return -1; + })[0]; + } + function isNodeInContext(node, context) { + 'use strict'; + var include = context.include && getDeepest(context.include.filter(function(candidate) { + return axe.utils.contains(candidate, node); + })); + var exclude = context.exclude && getDeepest(context.exclude.filter(function(candidate) { + return axe.utils.contains(candidate, node); + })); + if (!exclude && include || exclude && axe.utils.contains(exclude, include)) { + return true; + } + return false; + } + function pushNode(result, nodes, context) { + 'use strict'; + for (var i = 0, l = nodes.length; i < l; i++) { + if (!result.find(function(item) { + return item.actualNode === nodes[i].actualNode; + }) && isNodeInContext(nodes[i], context)) { + result.push(nodes[i]); + } + } + } + axe.utils.select = function select(selector, context) { + 'use strict'; + var result = [], candidate; + for (var i = 0, l = context.include.length; i < l; i++) { + candidate = context.include[i]; + if (candidate.actualNode.nodeType === candidate.actualNode.ELEMENT_NODE && axe.utils.matchesSelector(candidate.actualNode, selector)) { + pushNode(result, [ candidate ], context); + } + pushNode(result, axe.utils.querySelectorAll(candidate, selector), context); + } + return result.sort(axe.utils.nodeSorter); + }; + 'use strict'; + axe.utils.toArray = function(thing) { + 'use strict'; + return Array.prototype.slice.call(thing); + }; + 'use strict'; + var uuid; + (function(_global) { + var _rng; + var _crypto = _global.crypto || _global.msCrypto; + if (!_rng && _crypto && _crypto.getRandomValues) { + var _rnds8 = new Uint8Array(16); + _rng = function whatwgRNG() { + _crypto.getRandomValues(_rnds8); + return _rnds8; + }; + } + if (!_rng) { + var _rnds = new Array(16); + _rng = function _rng() { + for (var i = 0, r; i < 16; i++) { + if ((i & 3) === 0) { + r = Math.random() * 4294967296; + } + _rnds[i] = r >>> ((i & 3) << 3) & 255; + } + return _rnds; + }; + } + var BufferClass = typeof _global.Buffer == 'function' ? _global.Buffer : Array; + var _byteToHex = []; + var _hexToByte = {}; + for (var i = 0; i < 256; i++) { + _byteToHex[i] = (i + 256).toString(16).substr(1); + _hexToByte[_byteToHex[i]] = i; + } + function parse(s, buf, offset) { + var i = buf && offset || 0, ii = 0; + buf = buf || []; + s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) { + if (ii < 16) { + buf[i + ii++] = _hexToByte[oct]; + } + }); + while (ii < 16) { + buf[i + ii++] = 0; + } + return buf; + } + function unparse(buf, offset) { + var i = offset || 0, bth = _byteToHex; + return bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]]; + } + var _seedBytes = _rng(); + var _nodeId = [ _seedBytes[0] | 1, _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5] ]; + var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 16383; + var _lastMSecs = 0, _lastNSecs = 0; + function v1(options, buf, offset) { + var i = buf && offset || 0; + var b = buf || []; + options = options || {}; + var clockseq = options.clockseq != null ? options.clockseq : _clockseq; + var msecs = options.msecs != null ? options.msecs : new Date().getTime(); + var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1; + var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4; + if (dt < 0 && options.clockseq == null) { + clockseq = clockseq + 1 & 16383; + } + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) { + nsecs = 0; + } + if (nsecs >= 1e4) { + throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); + } + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; + msecs += 122192928e5; + var tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296; + b[i++] = tl >>> 24 & 255; + b[i++] = tl >>> 16 & 255; + b[i++] = tl >>> 8 & 255; + b[i++] = tl & 255; + var tmh = msecs / 4294967296 * 1e4 & 268435455; + b[i++] = tmh >>> 8 & 255; + b[i++] = tmh & 255; + b[i++] = tmh >>> 24 & 15 | 16; + b[i++] = tmh >>> 16 & 255; + b[i++] = clockseq >>> 8 | 128; + b[i++] = clockseq & 255; + var node = options.node || _nodeId; + for (var n = 0; n < 6; n++) { + b[i + n] = node[n]; + } + return buf ? buf : unparse(b); + } + function v4(options, buf, offset) { + var i = buf && offset || 0; + if (typeof options == 'string') { + buf = options == 'binary' ? new BufferClass(16) : null; + options = null; + } + options = options || {}; + var rnds = options.random || (options.rng || _rng)(); + rnds[6] = rnds[6] & 15 | 64; + rnds[8] = rnds[8] & 63 | 128; + if (buf) { + for (var ii = 0; ii < 16; ii++) { + buf[i + ii] = rnds[ii]; + } + } + return buf || unparse(rnds); + } + uuid = v4; + uuid.v1 = v1; + uuid.v4 = v4; + uuid.parse = parse; + uuid.unparse = unparse; + uuid.BufferClass = BufferClass; + })(window); + 'use strict'; + axe._load({ + data: { + rules: { + accesskeys: { + description: 'Ensures every accesskey attribute value is unique', + help: 'accesskey attribute value must be unique' + }, + 'area-alt': { + description: 'Ensures elements of image maps have alternate text', + help: 'Active elements must have alternate text' + }, + 'aria-allowed-attr': { + description: 'Ensures ARIA attributes are allowed for an element\'s role', + help: 'Elements must only use allowed ARIA attributes' + }, + 'aria-hidden-body': { + description: 'Ensures aria-hidden=\'true\' is not present on the document body.', + help: 'aria-hidden=\'true\' must not be present on the document body' + }, + 'aria-required-attr': { + description: 'Ensures elements with ARIA roles have all required ARIA attributes', + help: 'Required ARIA attributes must be provided' + }, + 'aria-required-children': { + description: 'Ensures elements with an ARIA role that require child roles contain them', + help: 'Certain ARIA roles must contain particular children' + }, + 'aria-required-parent': { + description: 'Ensures elements with an ARIA role that require parent roles are contained by them', + help: 'Certain ARIA roles must be contained by particular parents' + }, + 'aria-roles': { + description: 'Ensures all elements with a role attribute use a valid value', + help: 'ARIA roles used must conform to valid values' + }, + 'aria-valid-attr-value': { + description: 'Ensures all ARIA attributes have valid values', + help: 'ARIA attributes must conform to valid values' + }, + 'aria-valid-attr': { + description: 'Ensures attributes that begin with aria- are valid ARIA attributes', + help: 'ARIA attributes must conform to valid names' + }, + 'audio-caption': { + description: 'Ensures