From f513ee8c92cb32b765490819ab023eff636c1256 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Tue, 9 Apr 2019 08:23:06 -0600 Subject: [PATCH 01/14] feat(core): add WeakMap between HTMLElements and virtual nodes --- lib/core/public/run-rules.js | 2 ++ lib/core/utils/flattened-tree.js | 23 ++++++----------------- lib/core/utils/is-hidden.js | 12 +++++++++--- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/lib/core/public/run-rules.js b/lib/core/public/run-rules.js index 173b8aaaef..5166569ddb 100644 --- a/lib/core/public/run-rules.js +++ b/lib/core/public/run-rules.js @@ -3,6 +3,7 @@ // Clean up after resolve / reject function cleanup() { + axe._nodeMap = undefined; axe._tree = undefined; axe._selectorData = undefined; } @@ -18,6 +19,7 @@ function cleanup() { function runRules(context, options, resolve, reject) { 'use strict'; try { + // axe._nodeMap = new WeakMap(); context = new Context(context); axe._tree = context.flatTree; axe._selectorData = axe.utils.getSelectorData(context.flatTree); diff --git a/lib/core/utils/flattened-tree.js b/lib/core/utils/flattened-tree.js index fa97ec9150..e11f7b86d9 100644 --- a/lib/core/utils/flattened-tree.js +++ b/lib/core/utils/flattened-tree.js @@ -28,7 +28,7 @@ var axe = axe || { utils: {} }; */ function virtualDOMfromNode(node, shadowId) { const vNodeCache = {}; - return { + const vNode = { shadowId: shadowId, children: [], actualNode: node, @@ -47,6 +47,10 @@ function virtualDOMfromNode(node, shadowId) { return vNodeCache._tabbableElements; } }; + if (axe._nodeMap) { + axe._nodeMap.set(node, vNode); + } + return vNode; } /** @@ -151,20 +155,5 @@ axe.utils.getFlattenedTree = function(node, shadowId) { * @param {Node} node The HTML DOM node */ axe.utils.getNodeFromTree = function(vNode, node) { - var found; - - if (vNode.actualNode === node) { - return vNode; - } - vNode.children.forEach(candidate => { - if (found) { - return; - } - if (candidate.actualNode === node) { - found = candidate; - } else { - found = axe.utils.getNodeFromTree(candidate, node); - } - }); - return found; + return axe._nodeMap.get(node); }; diff --git a/lib/core/utils/is-hidden.js b/lib/core/utils/is-hidden.js index d56a531f44..d93b1725ac 100644 --- a/lib/core/utils/is-hidden.js +++ b/lib/core/utils/is-hidden.js @@ -8,7 +8,8 @@ */ axe.utils.isHidden = function isHidden(el, recursed) { 'use strict'; - var parent; + var node = axe.utils.getNodeFromTree(axe._tree[0], el); + var parent, isHidden; // 9 === Node.DOCUMENT if (el.nodeType === 9) { @@ -20,6 +21,10 @@ axe.utils.isHidden = function isHidden(el, recursed) { el = el.host; // grab the host Node } + if (typeof node.isHidden !== 'undefined') { + return node.isHidden; + } + var style = window.getComputedStyle(el, null); if ( @@ -35,6 +40,7 @@ axe.utils.isHidden = function isHidden(el, recursed) { } parent = el.assignedSlot ? el.assignedSlot : el.parentNode; - - return axe.utils.isHidden(parent, true); + isHidden = axe.utils.isHidden(parent, true); + node.isHidden = isHidden; + return isHidden; }; From fde7556a5fb47647ba5cff6d0b554aa5e8d301e3 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Wed, 17 Apr 2019 10:52:37 -0600 Subject: [PATCH 02/14] update to use new global cache --- lib/checks/aria/required-children.js | 2 +- lib/checks/aria/required-parent.js | 2 +- lib/commons/aria/get-owned-virtual.js | 2 +- lib/commons/aria/is-accessible-ref.js | 40 +++++---------------- lib/commons/aria/label-virtual.js | 4 +-- lib/commons/dom/find-up.js | 2 +- lib/commons/dom/has-content-virtual.js | 2 +- lib/commons/dom/is-in-text-block.js | 2 +- lib/commons/text/accessible-text-virtual.js | 2 +- lib/commons/text/label-virtual.js | 2 +- lib/commons/text/visible-virtual.js | 2 +- lib/core/base/context.js | 6 ++-- lib/core/public/run-rules.js | 8 +++-- lib/core/utils/flattened-tree.js | 32 +++++++++++++---- lib/core/utils/is-hidden.js | 2 +- lib/rules/color-contrast-matches.js | 5 +-- test/testutils.js | 4 +++ 17 files changed, 59 insertions(+), 60 deletions(-) diff --git a/lib/checks/aria/required-children.js b/lib/checks/aria/required-children.js index dbf02413c3..b9b6903735 100644 --- a/lib/checks/aria/required-children.js +++ b/lib/checks/aria/required-children.js @@ -30,7 +30,7 @@ function ariaOwns(nodes, role) { if (nodes[index] === null) { continue; } - let virtualTree = axe.utils.getNodeFromTree(axe._tree[0], nodes[index]); + let virtualTree = axe.utils.getNodeFromTree(nodes[index]); if (owns(nodes[index], virtualTree, role, true)) { return true; } diff --git a/lib/checks/aria/required-parent.js b/lib/checks/aria/required-parent.js index 45d1a646c7..21aa9ea14f 100644 --- a/lib/checks/aria/required-parent.js +++ b/lib/checks/aria/required-parent.js @@ -73,7 +73,7 @@ var owners = getAriaOwners(node); if (owners) { for (var i = 0, l = owners.length; i < l; i++) { missingParents = getMissingContext( - axe.utils.getNodeFromTree(axe._tree[0], owners[i]), + axe.utils.getNodeFromTree(owners[i]), missingParents, true ); diff --git a/lib/commons/aria/get-owned-virtual.js b/lib/commons/aria/get-owned-virtual.js index ec904786ce..0fc9e3391f 100644 --- a/lib/commons/aria/get-owned-virtual.js +++ b/lib/commons/aria/get-owned-virtual.js @@ -16,7 +16,7 @@ aria.getOwnedVirtual = function getOwned({ actualNode, children }) { return dom.idrefs(actualNode, 'aria-owns').reduce((ownedElms, element) => { if (element) { - const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], element); + const virtualNode = axe.utils.getNodeFromTree(element); ownedElms.push(virtualNode); } return ownedElms; diff --git a/lib/commons/aria/is-accessible-ref.js b/lib/commons/aria/is-accessible-ref.js index ed7e842648..8dc2f03f84 100644 --- a/lib/commons/aria/is-accessible-ref.js +++ b/lib/commons/aria/is-accessible-ref.js @@ -17,39 +17,15 @@ function findDomNode(node, functor) { * @returns {Boolean} */ aria.isAccessibleRef = function isAccessibleRef(node) { + + + // if while we generated the virtual node for each node we looked at + // the attributes of the node to see if it had any idref type attributes, + // we could store all those ids into a map and then this function would + // just have to look up the info in the map instead of the entire tree + node = node.actualNode || node; - let root = dom.getRootNode(node); - root = root.documentElement || root; // account for shadow roots const id = node.id; - // Get all idref(s) attributes on the lookup table - const refAttrs = Object.keys(aria.lookupTable.attributes).filter(attr => { - const { type } = aria.lookupTable.attributes[attr]; - return /^idrefs?$/.test(type); - }); - - // Find the first element that IDREF(S) the node - let refElm = findDomNode(root, elm => { - if (elm.nodeType !== 1) { - // Elements only - return; - } - if ( - elm.nodeName.toUpperCase() === 'LABEL' && - elm.getAttribute('for') === id - ) { - return true; - } - // See if there are any aria attributes that reference the node - return refAttrs - .filter(attr => elm.hasAttribute(attr)) - .some(attr => { - const attrValue = elm.getAttribute(attr); - if (aria.lookupTable.attributes[attr].type === 'idref') { - return attrValue === id; - } - return axe.utils.tokenList(attrValue).includes(id); - }); - }); - return typeof refElm !== 'undefined'; + return typeof axe._idRefCache[id] !== 'undefined'; }; diff --git a/lib/commons/aria/label-virtual.js b/lib/commons/aria/label-virtual.js index 2014254dba..97eb2eb5fb 100644 --- a/lib/commons/aria/label-virtual.js +++ b/lib/commons/aria/label-virtual.js @@ -17,7 +17,7 @@ aria.labelVirtual = function({ actualNode }) { ref = dom.idrefs(actualNode, 'aria-labelledby'); candidate = ref .map(function(thing) { - const vNode = axe.utils.getNodeFromTree(axe._tree[0], thing); + const vNode = axe.utils.getNodeFromTree(thing); return vNode ? text.visibleVirtual(vNode, true) : ''; }) .join(' ') @@ -49,6 +49,6 @@ aria.labelVirtual = function({ actualNode }) { * @return {Mixed} String of visible text, or `null` if no label is found */ aria.label = function(node) { - node = axe.utils.getNodeFromTree(axe._tree[0], node); + node = axe.utils.getNodeFromTree(node); return aria.labelVirtual(node); }; diff --git a/lib/commons/dom/find-up.js b/lib/commons/dom/find-up.js index dee05d72fd..4634d9f4f9 100644 --- a/lib/commons/dom/find-up.js +++ b/lib/commons/dom/find-up.js @@ -12,7 +12,7 @@ */ dom.findUp = function(element, target) { return dom.findUpVirtual( - axe.utils.getNodeFromTree(axe._tree[0], element), + axe.utils.getNodeFromTree(element), target ); }; diff --git a/lib/commons/dom/has-content-virtual.js b/lib/commons/dom/has-content-virtual.js index 450e25b12e..9b07d1e4b8 100644 --- a/lib/commons/dom/has-content-virtual.js +++ b/lib/commons/dom/has-content-virtual.js @@ -59,7 +59,7 @@ dom.hasContentVirtual = function(elm, noRecursion) { * @return {Boolean} */ dom.hasContent = function hasContent(elm, noRecursion) { - elm = axe.utils.getNodeFromTree(axe._tree[0], elm); + elm = axe.utils.getNodeFromTree(elm); return dom.hasContentVirtual(elm, noRecursion); }; diff --git a/lib/commons/dom/is-in-text-block.js b/lib/commons/dom/is-in-text-block.js index ad1e30ac6a..743c9aa97b 100644 --- a/lib/commons/dom/is-in-text-block.js +++ b/lib/commons/dom/is-in-text-block.js @@ -17,7 +17,7 @@ function getBlockParent(node) { while (parentBlock && !isBlock(parentBlock)) { parentBlock = dom.getComposedParent(parentBlock); } - return axe.utils.getNodeFromTree(axe._tree[0], parentBlock); + return axe.utils.getNodeFromTree(parentBlock); } /** diff --git a/lib/commons/text/accessible-text-virtual.js b/lib/commons/text/accessible-text-virtual.js index 446efdd7a6..dfd1eed129 100644 --- a/lib/commons/text/accessible-text-virtual.js +++ b/lib/commons/text/accessible-text-virtual.js @@ -11,7 +11,7 @@ * @return {string} */ text.accessibleText = function accessibleText(element, context) { - let virtualNode = axe.utils.getNodeFromTree(axe._tree[0], element); // throws an exception on purpose if axe._tree not correct + let virtualNode = axe.utils.getNodeFromTree(element); // throws an exception on purpose if axe._tree not correct return text.accessibleTextVirtual(virtualNode, context); }; diff --git a/lib/commons/text/label-virtual.js b/lib/commons/text/label-virtual.js index 10a5b5f9fb..87319f569c 100644 --- a/lib/commons/text/label-virtual.js +++ b/lib/commons/text/label-virtual.js @@ -48,6 +48,6 @@ text.labelVirtual = function(node) { * @return {Mixed} String of visible text, or `null` if no label is found */ text.label = function(node) { - node = axe.utils.getNodeFromTree(axe._tree[0], node); + node = axe.utils.getNodeFromTree(node); return text.labelVirtual(node); }; diff --git a/lib/commons/text/visible-virtual.js b/lib/commons/text/visible-virtual.js index f591d32c6f..5c62337d8b 100644 --- a/lib/commons/text/visible-virtual.js +++ b/lib/commons/text/visible-virtual.js @@ -41,6 +41,6 @@ text.visibleVirtual = function(element, screenReader, noRecursing) { * @return {String} */ text.visible = function(element, screenReader, noRecursing) { - element = axe.utils.getNodeFromTree(axe._tree[0], element); + element = axe.utils.getNodeFromTree(element); return text.visibleVirtual(element, screenReader, noRecursing); }; diff --git a/lib/core/base/context.js b/lib/core/base/context.js index d87e76c925..fae3fab416 100644 --- a/lib/core/base/context.js +++ b/lib/core/base/context.js @@ -135,7 +135,7 @@ function parseSelectorArray(context, type) { //eslint no-loop-func:0 result = result.concat( nodeList.map(node => { - return axe.utils.getNodeFromTree(context.flatTree[0], node); + return axe.utils.getNodeFromTree(node); }) ); break; @@ -147,7 +147,7 @@ function parseSelectorArray(context, type) { //eslint no-loop-func:0 result = result.concat( nodeList.map(node => { - return axe.utils.getNodeFromTree(context.flatTree[0], node); + return axe.utils.getNodeFromTree(node); }) ); } @@ -155,7 +155,7 @@ function parseSelectorArray(context, type) { if (item.documentElement instanceof Node) { result.push(context.flatTree[0]); } else { - result.push(axe.utils.getNodeFromTree(context.flatTree[0], item)); + result.push(axe.utils.getNodeFromTree(item)); } } } diff --git a/lib/core/public/run-rules.js b/lib/core/public/run-rules.js index 5166569ddb..f53dd779f9 100644 --- a/lib/core/public/run-rules.js +++ b/lib/core/public/run-rules.js @@ -3,7 +3,7 @@ // Clean up after resolve / reject function cleanup() { - axe._nodeMap = undefined; + axe._cache = undefined; axe._tree = undefined; axe._selectorData = undefined; } @@ -19,7 +19,11 @@ function cleanup() { function runRules(context, options, resolve, reject) { 'use strict'; try { - // axe._nodeMap = new WeakMap(); + axe._cache = { + nodeMap: new WeakMap(), + idRefs: {} + }; + context = new Context(context); axe._tree = context.flatTree; axe._selectorData = axe.utils.getSelectorData(context.flatTree); diff --git a/lib/core/utils/flattened-tree.js b/lib/core/utils/flattened-tree.js index e11f7b86d9..c03af978c3 100644 --- a/lib/core/utils/flattened-tree.js +++ b/lib/core/utils/flattened-tree.js @@ -1,6 +1,8 @@ /*eslint no-use-before-define: 0*/ var axe = axe || { utils: {} }; +const idRefRegex = /^idrefs?$/; + /** * This implemnts the flatten-tree algorithm specified: * Originally here https://drafts.csswg.org/css-scoping/#flat-tree @@ -27,6 +29,25 @@ var axe = axe || { utils: {} }; * @return {Object} - the wrapped node */ function virtualDOMfromNode(node, shadowId) { + const refAttrs = Object.keys(axe.commons.aria.lookupTable.attributes) + .filter(attr => { + const { type } = axe.commons.aria.lookupTable.attributes[attr]; + return /^idrefs?$/.test(type); + }); + + // cache all idref attribute values so we can look them up in + // aria.isAccessibleRef + if (node.hasAttribute) { + refAttrs + .filter(attr => node.hasAttribute(attr)) + .forEach(attr => { + const attrValue = elm.getAttribute(attr); + axe.utils.tokenList(attrValue).forEach(id => { + axe._cache.idRefs[id] = 1; + }); + }); + } + const vNodeCache = {}; const vNode = { shadowId: shadowId, @@ -47,9 +68,7 @@ function virtualDOMfromNode(node, shadowId) { return vNodeCache._tabbableElements; } }; - if (axe._nodeMap) { - axe._nodeMap.set(node, vNode); - } + axe._cahce.nodeMap.set(node, vNode); return vNode; } @@ -149,11 +168,10 @@ axe.utils.getFlattenedTree = function(node, shadowId) { }; /** - * Recursively return a single node from a virtual dom tree + * Return a single node from the virtual dom tree * - * @param {Object} vNode The flattened, virtual DOM tree * @param {Node} node The HTML DOM node */ -axe.utils.getNodeFromTree = function(vNode, node) { - return axe._nodeMap.get(node); +axe.utils.getNodeFromTree = function(node) { + return axe._cache.nodeMap.get(node); }; diff --git a/lib/core/utils/is-hidden.js b/lib/core/utils/is-hidden.js index d93b1725ac..d60ab5bd46 100644 --- a/lib/core/utils/is-hidden.js +++ b/lib/core/utils/is-hidden.js @@ -8,7 +8,7 @@ */ axe.utils.isHidden = function isHidden(el, recursed) { 'use strict'; - var node = axe.utils.getNodeFromTree(axe._tree[0], el); + var node = axe.utils.getNodeFromTree(el); var parent, isHidden; // 9 === Node.DOCUMENT diff --git a/lib/rules/color-contrast-matches.js b/lib/rules/color-contrast-matches.js index f5045aa459..bb7699ddc4 100644 --- a/lib/rules/color-contrast-matches.js +++ b/lib/rules/color-contrast-matches.js @@ -53,10 +53,7 @@ if (nodeName === 'LABEL' || nodeParentLabel) { if (nodeParentLabel) { relevantNode = nodeParentLabel; // we need an input candidate from a parent to account for label children - relevantVirtualNode = axe.utils.getNodeFromTree( - axe._tree[0], - nodeParentLabel - ); + relevantVirtualNode = axe.utils.getNodeFromTree(nodeParentLabel); } // explicit label of disabled input let doc = axe.commons.dom.getRootNode(relevantNode); diff --git a/test/testutils.js b/test/testutils.js index 438395d410..3cdd805fdd 100644 --- a/test/testutils.js +++ b/test/testutils.js @@ -92,6 +92,10 @@ testUtils.fixtureSetup = function(content) { } axe._tree = axe.utils.getFlattenedTree(fixture); axe._selectorData = axe.utils.getSelectorData(axe._tree); + axe._cache = { + nodeMap: new WeakMap(), + idRefs: {} + }; return fixture; }; From a50b91e840ede5d82784948bb5012bfdbc63ece9 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Wed, 17 Apr 2019 13:33:27 -0600 Subject: [PATCH 03/14] clean up elsint errors --- lib/commons/aria/is-accessible-ref.js | 49 ++-- lib/commons/dom/is-visible.js | 18 +- lib/core/imports/index.js | 6 + lib/core/public/run-rules.js | 3 +- lib/core/utils/flattened-tree.js | 31 +-- lib/core/utils/is-hidden.js | 14 +- package.json | 4 +- test/checks/aria/required-children.js | 12 +- test/checks/aria/required-parent.js | 12 +- test/checks/color/color-contrast.js | 2 +- test/checks/forms/fieldset.js | 38 +-- test/checks/forms/group-labelledby.js | 12 +- test/checks/keyboard/focusable-disabled.js | 2 +- .../checks/keyboard/focusable-not-tabbable.js | 2 +- test/checks/label/duplicate-img-label.js | 32 +-- test/checks/label/help-same-as-label.js | 16 +- test/checks/label/implicit.js | 8 +- test/checks/label/title-only.js | 12 +- test/checks/visibility/hidden-content.js | 8 +- test/commons/dom/get-tabbable-elements.js | 14 +- test/commons/text/accessible-text.js | 12 +- test/core/utils/flattened-tree.js | 4 +- .../document-title/document-title-fail.html | 2 +- .../document-title/document-title-pass.html | 2 +- .../full/frame-tested/frame-tested-fail.html | 2 +- .../frame-tested/frame-tested-incomplete.html | 2 +- .../full/frame-tested/frame-tested-pass.html | 2 +- .../full/frame-wait-time/frame-wait-time.html | 2 +- .../html-has-lang/html-has-lang-fail.html | 10 +- .../html-has-lang/html-has-lang-pass.html | 10 +- .../full/html-lang-valid/html-lang-valid.html | 2 +- .../full/incomplete/color-contrast.html | 2 +- .../full/incomplete/th-has-data-cells.html | 2 +- .../landmark-banner-is-top-level-fail.html | 2 +- .../landmark-banner-is-top-level-pass.html | 2 +- ...dmark-complementary-is-top-level-fail.html | 2 +- ...dmark-complementary-is-top-level-pass.html | 2 +- ...andmark-contentinfo-is-top-level-fail.html | 2 +- ...andmark-contentinfo-is-top-level-pass.html | 2 +- .../landmark-main-is-top-level-fail.html | 2 +- .../landmark-main-is-top-level-pass.html | 2 +- .../landmark-no-duplicate-banner-fail.html | 2 +- .../landmark-no-duplicate-banner-pass.html | 2 +- ...andmark-no-duplicate-contentinfo-fail.html | 2 +- ...andmark-no-duplicate-contentinfo-pass.html | 2 +- .../landmark-one-main-fail.html | 2 +- .../landmark-one-main-pass1.html | 2 +- .../landmark-one-main-pass2.html | 2 +- .../options-parameter/options-parameter.html | 2 +- .../page-has-heading-one-fail.html | 2 +- .../page-has-heading-one-pass1.html | 2 +- .../page-has-heading-one-pass2.html | 2 +- test/integration/full/rerun/rerun.html | 2 +- test/rule-matches/color-contrast-matches.js | 252 ++++++------------ test/testutils.js | 19 +- 55 files changed, 306 insertions(+), 354 deletions(-) diff --git a/lib/commons/aria/is-accessible-ref.js b/lib/commons/aria/is-accessible-ref.js index 8dc2f03f84..8c1e0a6765 100644 --- a/lib/commons/aria/is-accessible-ref.js +++ b/lib/commons/aria/is-accessible-ref.js @@ -1,13 +1,24 @@ /* global aria, axe, dom */ -function findDomNode(node, functor) { - if (functor(node)) { - return node; +const idRefsRegex = /^idrefs?$/; + +function cacheIdRefs(node, refAttrs) { + if (node.hasAttribute) { + if (node.nodeName.toUpperCase() === 'LABEL' && node.hasAttribute('for')) { + axe._cache.idRefs[node.getAttribute('for')] = 1; + } + + refAttrs + .filter(attr => node.hasAttribute(attr)) + .forEach(attr => { + const attrValue = node.getAttribute(attr); + axe.utils.tokenList(attrValue).forEach(id => { + axe._cache.idRefs[id] = 1; + }); + }); } + for (let i = 0; i < node.children.length; i++) { - const out = findDomNode(node.children[i], functor); - if (out) { - return out; - } + cacheIdRefs(node.children[i], refAttrs); } } @@ -17,15 +28,23 @@ function findDomNode(node, functor) { * @returns {Boolean} */ aria.isAccessibleRef = function isAccessibleRef(node) { - - - // if while we generated the virtual node for each node we looked at - // the attributes of the node to see if it had any idref type attributes, - // we could store all those ids into a map and then this function would - // just have to look up the info in the map instead of the entire tree - node = node.actualNode || node; + let root = dom.getRootNode(node); + root = root.documentElement || root; // account for shadow roots const id = node.id; - return typeof axe._idRefCache[id] !== 'undefined'; + // because axe.commons is not available in axe.utils, we can't do + // this caching when we build up the virtual tree + if (!axe._cache.idRefsCached) { + axe._cache.idRefsCached = true; + // Get all idref(s) attributes on the lookup table + const refAttrs = Object.keys(aria.lookupTable.attributes).filter(attr => { + const { type } = aria.lookupTable.attributes[attr]; + return idRefsRegex.test(type); + }); + + cacheIdRefs(root, refAttrs); + } + + return axe._cache.idRefs[id] === 1; }; diff --git a/lib/commons/dom/is-visible.js b/lib/commons/dom/is-visible.js index 4f4d4663ce..6cd31ecc14 100644 --- a/lib/commons/dom/is-visible.js +++ b/lib/commons/dom/is-visible.js @@ -33,7 +33,9 @@ function isClipped(clip) { */ dom.isVisible = function(el, screenReader, recursed) { 'use strict'; - var style, nodeName, parent; + const node = axe.utils.getNodeFromTree(el); + const cacheName = 'isVisible' + (screenReader ? 'ScreenReader' : ''); + let style, nodeName, parent, isVisible; // 9 === Node.DOCUMENT if (el.nodeType === 9) { @@ -45,6 +47,10 @@ dom.isVisible = function(el, screenReader, recursed) { el = el.host; // grab the host Node } + if (node && typeof node[cacheName] !== 'undefined') { + return node[cacheName]; + } + style = window.getComputedStyle(el, null); if (style === null) { return false; @@ -68,8 +74,14 @@ dom.isVisible = function(el, screenReader, recursed) { parent = el.assignedSlot ? el.assignedSlot : el.parentNode; if (parent) { - return dom.isVisible(parent, screenReader, true); + isVisible = dom.isVisible(parent, screenReader, true); + } else { + isVisible = false; } - return false; + if (node) { + node[cacheName] = isVisible; + } + + return isVisible; }; diff --git a/lib/core/imports/index.js b/lib/core/imports/index.js index 9b81dbf878..b49e962827 100644 --- a/lib/core/imports/index.js +++ b/lib/core/imports/index.js @@ -14,6 +14,12 @@ if (!('Promise' in window)) { require('es6-promise').polyfill(); } +/** + * Polyfill `WeakMap` + * Reference: https://github.com/polygonplanet/weakmap-polyfill + */ +require('weakmap-polyfill'); + /** * Namespace `axe.imports` which holds required external dependencies * diff --git a/lib/core/public/run-rules.js b/lib/core/public/run-rules.js index f53dd779f9..6004ae96ae 100644 --- a/lib/core/public/run-rules.js +++ b/lib/core/public/run-rules.js @@ -21,7 +21,8 @@ function runRules(context, options, resolve, reject) { try { axe._cache = { nodeMap: new WeakMap(), - idRefs: {} + idRefs: {}, + idRefsCached: false }; context = new Context(context); diff --git a/lib/core/utils/flattened-tree.js b/lib/core/utils/flattened-tree.js index 7d30857f0c..7562c080de 100644 --- a/lib/core/utils/flattened-tree.js +++ b/lib/core/utils/flattened-tree.js @@ -1,8 +1,6 @@ /*eslint no-use-before-define: 0*/ var axe = axe || { utils: {} }; -const idRefRegex = /^idrefs?$/; - /** * This implemnts the flatten-tree algorithm specified: * Originally here https://drafts.csswg.org/css-scoping/#flat-tree @@ -29,25 +27,6 @@ const idRefRegex = /^idrefs?$/; * @return {Object} - the wrapped node */ function virtualDOMfromNode(node, shadowId) { - const refAttrs = Object.keys(axe.commons.aria.lookupTable.attributes) - .filter(attr => { - const { type } = axe.commons.aria.lookupTable.attributes[attr]; - return /^idrefs?$/.test(type); - }); - - // cache all idref attribute values so we can look them up in - // aria.isAccessibleRef - if (node.hasAttribute) { - refAttrs - .filter(attr => node.hasAttribute(attr)) - .forEach(attr => { - const attrValue = elm.getAttribute(attr); - axe.utils.tokenList(attrValue).forEach(id => { - axe._cache.idRefs[id] = 1; - }); - }); - } - const vNodeCache = {}; const vNode = { shadowId: shadowId, @@ -68,7 +47,7 @@ function virtualDOMfromNode(node, shadowId) { return vNodeCache._tabbableElements; } }; - axe._cahce.nodeMap.set(node, vNode); + axe._cache.nodeMap.set(node, vNode); return vNode; } @@ -169,8 +148,12 @@ axe.utils.getFlattenedTree = function(node, shadowId) { /** * Return a single node from the virtual dom tree * + * @param {Object} vNode The flattened, virtual DOM tree (optional) * @param {Node} node The HTML DOM node */ -axe.utils.getNodeFromTree = function(node) { - return axe._cache.nodeMap.get(node); +axe.utils.getNodeFromTree = function(vNode, node) { + // TODO: removing vNode is a breaking change, but we can skirt that + // for now by ignoring it if passed in + let el = node || vNode; + return axe._cache.nodeMap.get(el); }; diff --git a/lib/core/utils/is-hidden.js b/lib/core/utils/is-hidden.js index d60ab5bd46..d70673346e 100644 --- a/lib/core/utils/is-hidden.js +++ b/lib/core/utils/is-hidden.js @@ -8,8 +8,8 @@ */ axe.utils.isHidden = function isHidden(el, recursed) { 'use strict'; - var node = axe.utils.getNodeFromTree(el); - var parent, isHidden; + const node = axe.utils.getNodeFromTree(el); + let parent, isHidden; // 9 === Node.DOCUMENT if (el.nodeType === 9) { @@ -21,11 +21,11 @@ axe.utils.isHidden = function isHidden(el, recursed) { el = el.host; // grab the host Node } - if (typeof node.isHidden !== 'undefined') { + if (node && typeof node.isHidden !== 'undefined') { return node.isHidden; } - var style = window.getComputedStyle(el, null); + const style = window.getComputedStyle(el, null); if ( !style || @@ -41,6 +41,10 @@ axe.utils.isHidden = function isHidden(el, recursed) { parent = el.assignedSlot ? el.assignedSlot : el.parentNode; isHidden = axe.utils.isHidden(parent, true); - node.isHidden = isHidden; + + if (node) { + node.isHidden = isHidden; + } + return isHidden; }; diff --git a/package.json b/package.json index c29bd6342c..fee3947629 100644 --- a/package.json +++ b/package.json @@ -124,7 +124,9 @@ "typescript": "^2.9.2", "uglify-js": "^3.4.4" }, - "dependencies": {}, + "dependencies": { + "weakmap-polyfill": "^2.0.0" + }, "lint-staged": { "*.{md,json,ts}": [ "prettier --write", diff --git a/test/checks/aria/required-children.js b/test/checks/aria/required-children.js index eeb51ff1ad..4aa97dc5d8 100644 --- a/test/checks/aria/required-children.js +++ b/test/checks/aria/required-children.js @@ -32,8 +32,8 @@ describe('aria-required-children', function() { var shadowRoot = target.attachShadow({ mode: 'open' }); shadowRoot.innerHTML = '

Nothing here.

'; - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - var virtualTarget = axe.utils.getNodeFromTree(tree[0], target); + axe._tree = axe.utils.getFlattenedTree(fixture); + var virtualTarget = axe.utils.getNodeFromTree(target); var params = [target, undefined, virtualTarget]; assert.isFalse( @@ -63,8 +63,8 @@ describe('aria-required-children', function() { var shadowRoot = target.attachShadow({ mode: 'open' }); shadowRoot.innerHTML = '

Nothing here.

'; - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - var virtualTarget = axe.utils.getNodeFromTree(tree[0], target); + axe._tree = axe.utils.getFlattenedTree(fixture); + var virtualTarget = axe.utils.getNodeFromTree(target); var params = [target, undefined, virtualTarget]; assert.isFalse( @@ -113,8 +113,8 @@ describe('aria-required-children', function() { shadowRoot.innerHTML = '

Nothing here.

Textbox

'; - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - var virtualTarget = axe.utils.getNodeFromTree(tree[0], target); + axe._tree = axe.utils.getFlattenedTree(fixture); + var virtualTarget = axe.utils.getNodeFromTree(target); var params = [target, undefined, virtualTarget]; assert.isTrue( diff --git a/test/checks/aria/required-parent.js b/test/checks/aria/required-parent.js index 07fa75e0f2..de637fde32 100644 --- a/test/checks/aria/required-parent.js +++ b/test/checks/aria/required-parent.js @@ -32,9 +32,9 @@ describe('aria-required-parent', function() { .attachShadow({ mode: 'open' }); shadowRoot.innerHTML = '

Nothing here.

'; - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); var shadowContent = shadowRoot.querySelector('#target'); - var virtualTarget = axe.utils.getNodeFromTree(tree[0], shadowContent); + var virtualTarget = axe.utils.getNodeFromTree(shadowContent); var params = [shadowContent, undefined, virtualTarget]; assert.isFalse( @@ -102,9 +102,9 @@ describe('aria-required-parent', function() { .attachShadow({ mode: 'open' }); shadowRoot.innerHTML = '

Nothing here.

'; - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); var shadowContent = shadowRoot.querySelector('#target'); - var virtualTarget = axe.utils.getNodeFromTree(tree[0], shadowContent); + var virtualTarget = axe.utils.getNodeFromTree(shadowContent); var params = [shadowContent, undefined, virtualTarget]; assert.isTrue( @@ -124,9 +124,9 @@ describe('aria-required-parent', function() { .attachShadow({ mode: 'open' }); shadowRoot.innerHTML = '

Nothing here.

'; - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); var shadowContent = shadowRoot.querySelector('#target'); - var virtualTarget = axe.utils.getNodeFromTree(tree[0], shadowContent); + var virtualTarget = axe.utils.getNodeFromTree(shadowContent); var params = [shadowContent, undefined, virtualTarget]; assert.isFalse( diff --git a/test/checks/color/color-contrast.js b/test/checks/color/color-contrast.js index e9bde325a2..5b80b48a70 100644 --- a/test/checks/color/color-contrast.js +++ b/test/checks/color/color-contrast.js @@ -227,7 +227,7 @@ describe('color-contrast', function() { it('should return true when a label wraps a text input', function() { fixtureSetup(''); var target = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], target); + var virtualNode = axe.utils.getNodeFromTree(target); if (window.PHANTOMJS) { assert.ok('PhantomJS is a liar'); } else { diff --git a/test/checks/forms/fieldset.js b/test/checks/forms/fieldset.js index c60d82c812..5575ba1060 100644 --- a/test/checks/forms/fieldset.js +++ b/test/checks/forms/fieldset.js @@ -27,7 +27,7 @@ describe('fieldset', function() { ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -49,7 +49,7 @@ describe('fieldset', function() { ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isFalse( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -76,7 +76,7 @@ describe('fieldset', function() { '" name="uniqueyname">' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isFalse( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -103,7 +103,7 @@ describe('fieldset', function() { '" name="uniqueyname">' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isFalse( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -131,7 +131,7 @@ describe('fieldset', function() { '" name="uniqueyname">' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isFalse( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -158,7 +158,7 @@ describe('fieldset', function() { '" name="uniqueyname">' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -176,7 +176,7 @@ describe('fieldset', function() { ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isFalse( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -202,7 +202,7 @@ describe('fieldset', function() { ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isFalse( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -230,7 +230,7 @@ describe('fieldset', function() { '" name="uniqueyname">' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isFalse( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -259,7 +259,7 @@ describe('fieldset', function() { ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -282,7 +282,7 @@ describe('fieldset', function() { ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -304,7 +304,7 @@ describe('fieldset', function() { '" name="uniqueyname">' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -322,7 +322,7 @@ describe('fieldset', function() { '' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -348,7 +348,7 @@ describe('fieldset', function() { '' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -374,7 +374,7 @@ describe('fieldset', function() { '' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -398,7 +398,7 @@ describe('fieldset', function() { fixtureSetup(fieldset); var node = shadow.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -423,7 +423,7 @@ describe('fieldset', function() { fixtureSetup(div); var node = div.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -448,7 +448,7 @@ describe('fieldset', function() { ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); @@ -471,7 +471,7 @@ describe('fieldset', function() { '" name="s.%$#n">' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isFalse( checks.fieldset.evaluate.call(checkContext, node, {}, virtualNode) ); diff --git a/test/checks/forms/group-labelledby.js b/test/checks/forms/group-labelledby.js index daca2f19f6..340fd3f6cb 100644 --- a/test/checks/forms/group-labelledby.js +++ b/test/checks/forms/group-labelledby.js @@ -317,9 +317,9 @@ describe('group-labelledby', function() { type + '" aria-labelledby="shared three" name="groupname">'; - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); var shadowContent = shadowRoot.querySelector('#target'); - var virtualTarget = axe.utils.getNodeFromTree(tree[0], shadowContent); + var virtualTarget = axe.utils.getNodeFromTree(shadowContent); var params = [shadowContent, undefined, virtualTarget]; assert.isFalse(check.evaluate.apply(checkContext, params)); @@ -355,9 +355,9 @@ describe('group-labelledby', function() { type + '" aria-labelledby="shared three" name="groupname">'; - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); var shadowContent = shadowRoot.querySelector('#target'); - var virtualTarget = axe.utils.getNodeFromTree(tree[0], shadowContent); + var virtualTarget = axe.utils.getNodeFromTree(shadowContent); var params = [shadowContent, undefined, virtualTarget]; assert.isFalse(check.evaluate.apply(checkContext, params)); @@ -394,9 +394,9 @@ describe('group-labelledby', function() { type + '" id="target" name="samename" aria-labelledby="shared three">'; - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); var shadowContent = shadowRoot.querySelector('#target'); - var virtualTarget = axe.utils.getNodeFromTree(tree[0], shadowContent); + var virtualTarget = axe.utils.getNodeFromTree(shadowContent); var params = [shadowContent, undefined, virtualTarget]; assert.isTrue(check.evaluate.apply(checkContext, params)); diff --git a/test/checks/keyboard/focusable-disabled.js b/test/checks/keyboard/focusable-disabled.js index b2bf0fed78..6cfe5fe265 100644 --- a/test/checks/keyboard/focusable-disabled.js +++ b/test/checks/keyboard/focusable-disabled.js @@ -108,7 +108,7 @@ describe('focusable-disabled', function() { shadow.innerHTML = ''; axe._tree = axe.utils.getFlattenedTree(fixture); axe._selectorData = axe.utils.getSelectorData(axe._tree); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); var actual = check.evaluate.call(checkContext, node, {}, virtualNode); assert.isFalse(actual); } diff --git a/test/checks/keyboard/focusable-not-tabbable.js b/test/checks/keyboard/focusable-not-tabbable.js index c83e0aa960..f3b4af4c99 100644 --- a/test/checks/keyboard/focusable-not-tabbable.js +++ b/test/checks/keyboard/focusable-not-tabbable.js @@ -104,7 +104,7 @@ describe('focusable-not-tabbable', function() { shadow.innerHTML = '

btn

'; axe._tree = axe.utils.getFlattenedTree(fixture); axe._selectorData = axe.utils.getSelectorData(axe._tree); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); var actual = check.evaluate.call(checkContext, node, {}, virtualNode); assert.isFalse(actual); } diff --git a/test/checks/label/duplicate-img-label.js b/test/checks/label/duplicate-img-label.js index 60e0aba6b0..d7f8681ab8 100644 --- a/test/checks/label/duplicate-img-label.js +++ b/test/checks/label/duplicate-img-label.js @@ -13,12 +13,12 @@ describe('duplicate-img-label', function() { it('should return false if no img is present', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isFalse( checks['duplicate-img-label'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); }); @@ -26,11 +26,11 @@ describe('duplicate-img-label', function() { it('should return false if no text is present', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); var result = checks['duplicate-img-label'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ); assert.isFalse(result); }); @@ -39,12 +39,12 @@ describe('duplicate-img-label', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isFalse( checks['duplicate-img-label'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); }); @@ -53,12 +53,12 @@ describe('duplicate-img-label', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isFalse( checks['duplicate-img-label'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); }); @@ -67,12 +67,12 @@ describe('duplicate-img-label', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isTrue( checks['duplicate-img-label'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); }); @@ -81,12 +81,12 @@ describe('duplicate-img-label', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isTrue( checks['duplicate-img-label'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); }); @@ -94,12 +94,12 @@ describe('duplicate-img-label', function() { it('should return false if img and text are both blank', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isFalse( checks['duplicate-img-label'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); }); @@ -108,12 +108,12 @@ describe('duplicate-img-label', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isFalse( checks['duplicate-img-label'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); }); diff --git a/test/checks/label/help-same-as-label.js b/test/checks/label/help-same-as-label.js index 9cc371dae2..018d9e1beb 100644 --- a/test/checks/label/help-same-as-label.js +++ b/test/checks/label/help-same-as-label.js @@ -15,12 +15,12 @@ describe('help-same-as-label', function() { node.setAttribute('aria-label', 'Duplicate'); fixture.appendChild(node); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isTrue( checks['help-same-as-label'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); }); @@ -37,12 +37,12 @@ describe('help-same-as-label', function() { fixture.appendChild(node); fixture.appendChild(dby); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isTrue( checks['help-same-as-label'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); }); @@ -54,12 +54,12 @@ describe('help-same-as-label', function() { fixture.appendChild(node); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isFalse( checks['help-same-as-label'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); }); @@ -75,12 +75,12 @@ describe('help-same-as-label', function() { fixture.appendChild(node); fixture.appendChild(dby); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isFalse( checks['help-same-as-label'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); }); diff --git a/test/checks/label/implicit.js b/test/checks/label/implicit.js index b292418035..e2100cd50e 100644 --- a/test/checks/label/implicit.js +++ b/test/checks/label/implicit.js @@ -12,7 +12,7 @@ describe('implicit-label', function() { it('should return false if an empty label is present', function() { fixtureSetup(''); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isFalse(checks['implicit-label'].evaluate(node, {}, virtualNode)); }); @@ -21,14 +21,14 @@ describe('implicit-label', function() { '' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isFalse(checks['implicit-label'].evaluate(node, {}, virtualNode)); }); it('should return true if a non-empty label is present', function() { fixtureSetup(''); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue(checks['implicit-label'].evaluate(node, {}, virtualNode)); }); @@ -37,7 +37,7 @@ describe('implicit-label', function() { node.type = 'text'; fixtureSetup(node); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isFalse(checks['implicit-label'].evaluate(node, {}, virtualNode)); }); }); diff --git a/test/checks/label/title-only.js b/test/checks/label/title-only.js index 35f93cf152..089456d35d 100644 --- a/test/checks/label/title-only.js +++ b/test/checks/label/title-only.js @@ -15,13 +15,13 @@ describe('title-only', function() { fixture.appendChild(node); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isTrue( checks['title-only'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); node.setAttribute('aria-label', 'woop'); @@ -29,7 +29,7 @@ describe('title-only', function() { checks['title-only'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); }); @@ -45,13 +45,13 @@ describe('title-only', function() { fixture.appendChild(node); fixture.appendChild(dby); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isTrue( checks['title-only'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); node.setAttribute('aria-label', 'woop'); @@ -59,7 +59,7 @@ describe('title-only', function() { checks['title-only'].evaluate( node, undefined, - axe.utils.getNodeFromTree(tree[0], node) + axe.utils.getNodeFromTree(node) ) ); }); diff --git a/test/checks/visibility/hidden-content.js b/test/checks/visibility/hidden-content.js index 3319abb4d6..770d2a68a1 100644 --- a/test/checks/visibility/hidden-content.js +++ b/test/checks/visibility/hidden-content.js @@ -52,7 +52,7 @@ describe('hidden content', function() { it('should skip whitelisted elements', function() { var node = document.querySelector('head'); axe._tree = axe.utils.getFlattenedTree(document.documentElement); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue( checks['hidden-content'].evaluate(node, undefined, virtualNode) ); @@ -68,19 +68,19 @@ describe('hidden content', function() { axe._tree = axe.utils.getFlattenedTree(fixture); var shadow = document.querySelector('#shadow'); - var virtualShadow = axe.utils.getNodeFromTree(axe._tree[0], shadow); + var virtualShadow = axe.utils.getNodeFromTree(shadow); assert.isTrue( checks['hidden-content'].evaluate(shadow, undefined, virtualShadow) ); var target = shadowRoot.querySelector('#target'); - var virtualTarget = axe.utils.getNodeFromTree(axe._tree[0], target); + var virtualTarget = axe.utils.getNodeFromTree(target); assert.isUndefined( checks['hidden-content'].evaluate(target, undefined, virtualTarget) ); var content = document.querySelector('#content'); - var virtualContent = axe.utils.getNodeFromTree(axe._tree[0], content); + var virtualContent = axe.utils.getNodeFromTree(content); assert.isTrue( checks['hidden-content'].evaluate(content, undefined, virtualContent) ); diff --git a/test/commons/dom/get-tabbable-elements.js b/test/commons/dom/get-tabbable-elements.js index f5f5f53318..27b9dfa8b4 100644 --- a/test/commons/dom/get-tabbable-elements.js +++ b/test/commons/dom/get-tabbable-elements.js @@ -18,7 +18,7 @@ describe('dom.getTabbableElements', function() { '' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); var actual = getTabbableElementsFn(virtualNode); assert.lengthOf(actual, 1); assert.equal(actual[0].actualNode.nodeName.toUpperCase(), 'TEXTAREA'); @@ -29,7 +29,7 @@ describe('dom.getTabbableElements', function() { '
' + '' + '
' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); var actual = getTabbableElementsFn(virtualNode); assert.lengthOf(actual, 0); }); @@ -39,7 +39,7 @@ describe('dom.getTabbableElements', function() { '
' + '' + '
' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); var actual = getTabbableElementsFn(virtualNode); assert.lengthOf(actual, 0); }); @@ -49,7 +49,7 @@ describe('dom.getTabbableElements', function() { '
' + '

Some text

' + '
' ); var node = fixture.querySelector('#target'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); var actual = getTabbableElementsFn(virtualNode); assert.lengthOf(actual, 0); }); @@ -64,7 +64,7 @@ describe('dom.getTabbableElements', function() { // re build tree after shadowDOM is constructed axe._tree = axe.utils.getFlattenedTree(fixture); axe._selectorData = axe.utils.getSelectorData(axe._tree); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); var actual = getTabbableElementsFn(virtualNode); assert.lengthOf(actual, 1); assert.equal(actual[0].actualNode.nodeName.toUpperCase(), 'BUTTON'); @@ -81,7 +81,7 @@ describe('dom.getTabbableElements', function() { // re build tree after shadowDOM is constructed axe._tree = axe.utils.getFlattenedTree(fixture); axe._selectorData = axe.utils.getSelectorData(axe._tree); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); var actual = getTabbableElementsFn(virtualNode); assert.lengthOf(actual, 0); } @@ -97,7 +97,7 @@ describe('dom.getTabbableElements', function() { // re build tree after shadowDOM is constructed axe._tree = axe.utils.getFlattenedTree(fixture); axe._selectorData = axe.utils.getSelectorData(axe._tree); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + var virtualNode = axe.utils.getNodeFromTree(node); var actual = getTabbableElementsFn(virtualNode); assert.lengthOf(actual, 0); } diff --git a/test/commons/text/accessible-text.js b/test/commons/text/accessible-text.js index 9280a82b6f..60c5077952 100644 --- a/test/commons/text/accessible-text.js +++ b/test/commons/text/accessible-text.js @@ -1371,7 +1371,7 @@ describe('text.accessibleTextVirtual', function() { fixture.appendChild(elm); axe._tree = axe.utils.getFlattenedTree(fixture); - var target = axe.utils.getNodeFromTree(axe._tree[0], elm); + var target = axe.utils.getNodeFromTree(elm); var result = axe.commons.text.accessibleTextVirtual(target); assert.equal(result, 'Hello World', tag); }); @@ -1385,7 +1385,7 @@ describe('text.accessibleTextVirtual', function() { fixture.appendChild(elm); axe._tree = axe.utils.getFlattenedTree(fixture); - var target = axe.utils.getNodeFromTree(axe._tree[0], elm); + var target = axe.utils.getNodeFromTree(elm); var result = axe.commons.text.accessibleTextVirtual(target); assert.equal(result, 'Hello World', tag); }); @@ -1399,7 +1399,7 @@ describe('text.accessibleTextVirtual', function() { fixture.appendChild(elm); axe._tree = axe.utils.getFlattenedTree(fixture); - var target = axe.utils.getNodeFromTree(axe._tree[0], elm); + var target = axe.utils.getNodeFromTree(elm); var result = axe.commons.text.accessibleTextVirtual(target); assert.equal(result, 'Hello World', tag); }); @@ -3214,7 +3214,7 @@ describe('text.accessibleTextVirtual', function() { assert.equal(accessibleText(target), 'Country of origin: United States'); }); - /** + /** // In case anyone even wants it, here's the script used to generate these test cases function getTestCase(content, index = 0) { const regex = new RegExp('if given\n([^]*)\nthen the accessible name of the element with id of "(.*)" is "(.*)"') @@ -3222,12 +3222,12 @@ describe('text.accessibleTextVirtual', function() { if (!out || out.length !== 4) { return; } - + const [, html, id, expected] = out; const strings = html.split(/\n/g).map( line => `'${line.substr(2)}'` ).join(' +\n ') + ';' - + return ` it('passes test ${index + 1}', function () { fixture.innerHTML = ${strings} diff --git a/test/core/utils/flattened-tree.js b/test/core/utils/flattened-tree.js index 287e208a42..06460555fc 100644 --- a/test/core/utils/flattened-tree.js +++ b/test/core/utils/flattened-tree.js @@ -269,9 +269,9 @@ describe('axe.utils.getFlattenedTree', function() { fixture.querySelectorAll('.stories').forEach(makeShadowTree); }); it('should find the virtual node that matches the real node passed in', function() { - var virtualDOM = axe.utils.getFlattenedTree(fixture); + axe.utils.getFlattenedTree(fixture); var node = document.querySelector('.stories li'); - var vNode = axe.utils.getNodeFromTree(virtualDOM[0], node); + var vNode = axe.utils.getNodeFromTree(node); assert.isDefined(vNode); assert.equal(node, vNode.actualNode); assert.equal(vNode.actualNode.textContent, '1'); diff --git a/test/integration/full/document-title/document-title-fail.html b/test/integration/full/document-title/document-title-fail.html index a5628d457c..62fda33da5 100644 --- a/test/integration/full/document-title/document-title-fail.html +++ b/test/integration/full/document-title/document-title-fail.html @@ -6,7 +6,6 @@ - diff --git a/test/integration/full/document-title/document-title-pass.html b/test/integration/full/document-title/document-title-pass.html index 6dbbddaa2a..3dae0d87fd 100644 --- a/test/integration/full/document-title/document-title-pass.html +++ b/test/integration/full/document-title/document-title-pass.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/frame-tested/frame-tested-fail.html b/test/integration/full/frame-tested/frame-tested-fail.html index 796d70cccc..687397d5ee 100644 --- a/test/integration/full/frame-tested/frame-tested-fail.html +++ b/test/integration/full/frame-tested/frame-tested-fail.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/frame-tested/frame-tested-incomplete.html b/test/integration/full/frame-tested/frame-tested-incomplete.html index ca9c00e10a..c31fdac367 100644 --- a/test/integration/full/frame-tested/frame-tested-incomplete.html +++ b/test/integration/full/frame-tested/frame-tested-incomplete.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/frame-tested/frame-tested-pass.html b/test/integration/full/frame-tested/frame-tested-pass.html index 77ca1dece9..5d44c160e4 100644 --- a/test/integration/full/frame-tested/frame-tested-pass.html +++ b/test/integration/full/frame-tested/frame-tested-pass.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/frame-wait-time/frame-wait-time.html b/test/integration/full/frame-wait-time/frame-wait-time.html index 635ded7f31..235790306d 100644 --- a/test/integration/full/frame-wait-time/frame-wait-time.html +++ b/test/integration/full/frame-wait-time/frame-wait-time.html @@ -8,7 +8,6 @@ - diff --git a/test/integration/full/html-has-lang/html-has-lang-fail.html b/test/integration/full/html-has-lang/html-has-lang-fail.html index 738cdd41d5..f8bf5a255f 100644 --- a/test/integration/full/html-has-lang/html-has-lang-fail.html +++ b/test/integration/full/html-has-lang/html-has-lang-fail.html @@ -8,7 +8,6 @@ - diff --git a/test/integration/full/html-has-lang/html-has-lang-pass.html b/test/integration/full/html-has-lang/html-has-lang-pass.html index eb3f94b23b..10ce071e99 100644 --- a/test/integration/full/html-has-lang/html-has-lang-pass.html +++ b/test/integration/full/html-has-lang/html-has-lang-pass.html @@ -8,7 +8,6 @@ - diff --git a/test/integration/full/html-lang-valid/html-lang-valid.html b/test/integration/full/html-lang-valid/html-lang-valid.html index e1cb33dee1..6c3e28e16e 100644 --- a/test/integration/full/html-lang-valid/html-lang-valid.html +++ b/test/integration/full/html-lang-valid/html-lang-valid.html @@ -8,7 +8,6 @@ - diff --git a/test/integration/full/incomplete/color-contrast.html b/test/integration/full/incomplete/color-contrast.html index 4dc6e7ac62..4f353b12e2 100644 --- a/test/integration/full/incomplete/color-contrast.html +++ b/test/integration/full/incomplete/color-contrast.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/incomplete/th-has-data-cells.html b/test/integration/full/incomplete/th-has-data-cells.html index 268677033d..bd441c54a8 100644 --- a/test/integration/full/incomplete/th-has-data-cells.html +++ b/test/integration/full/incomplete/th-has-data-cells.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/landmark-banner-is-top-level/landmark-banner-is-top-level-fail.html b/test/integration/full/landmark-banner-is-top-level/landmark-banner-is-top-level-fail.html index fc6983096e..4e45052994 100644 --- a/test/integration/full/landmark-banner-is-top-level/landmark-banner-is-top-level-fail.html +++ b/test/integration/full/landmark-banner-is-top-level/landmark-banner-is-top-level-fail.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/landmark-banner-is-top-level/landmark-banner-is-top-level-pass.html b/test/integration/full/landmark-banner-is-top-level/landmark-banner-is-top-level-pass.html index 995cc3ed92..3f06dc0300 100644 --- a/test/integration/full/landmark-banner-is-top-level/landmark-banner-is-top-level-pass.html +++ b/test/integration/full/landmark-banner-is-top-level/landmark-banner-is-top-level-pass.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/landmark-complementary-is-top-level/landmark-complementary-is-top-level-fail.html b/test/integration/full/landmark-complementary-is-top-level/landmark-complementary-is-top-level-fail.html index 2ed534899f..7b7043aa80 100644 --- a/test/integration/full/landmark-complementary-is-top-level/landmark-complementary-is-top-level-fail.html +++ b/test/integration/full/landmark-complementary-is-top-level/landmark-complementary-is-top-level-fail.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/landmark-complementary-is-top-level/landmark-complementary-is-top-level-pass.html b/test/integration/full/landmark-complementary-is-top-level/landmark-complementary-is-top-level-pass.html index 9d014ace37..f798b32870 100644 --- a/test/integration/full/landmark-complementary-is-top-level/landmark-complementary-is-top-level-pass.html +++ b/test/integration/full/landmark-complementary-is-top-level/landmark-complementary-is-top-level-pass.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/landmark-contentinfo-is-top-level/landmark-contentinfo-is-top-level-fail.html b/test/integration/full/landmark-contentinfo-is-top-level/landmark-contentinfo-is-top-level-fail.html index d201fbd398..83f68c96e4 100644 --- a/test/integration/full/landmark-contentinfo-is-top-level/landmark-contentinfo-is-top-level-fail.html +++ b/test/integration/full/landmark-contentinfo-is-top-level/landmark-contentinfo-is-top-level-fail.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/landmark-contentinfo-is-top-level/landmark-contentinfo-is-top-level-pass.html b/test/integration/full/landmark-contentinfo-is-top-level/landmark-contentinfo-is-top-level-pass.html index 0581d1df52..5c255c256f 100644 --- a/test/integration/full/landmark-contentinfo-is-top-level/landmark-contentinfo-is-top-level-pass.html +++ b/test/integration/full/landmark-contentinfo-is-top-level/landmark-contentinfo-is-top-level-pass.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/landmark-main-is-top-level/landmark-main-is-top-level-fail.html b/test/integration/full/landmark-main-is-top-level/landmark-main-is-top-level-fail.html index 26b71d1db3..a34e249da4 100644 --- a/test/integration/full/landmark-main-is-top-level/landmark-main-is-top-level-fail.html +++ b/test/integration/full/landmark-main-is-top-level/landmark-main-is-top-level-fail.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/landmark-main-is-top-level/landmark-main-is-top-level-pass.html b/test/integration/full/landmark-main-is-top-level/landmark-main-is-top-level-pass.html index 1110310c88..4e235c30fc 100644 --- a/test/integration/full/landmark-main-is-top-level/landmark-main-is-top-level-pass.html +++ b/test/integration/full/landmark-main-is-top-level/landmark-main-is-top-level-pass.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/landmark-no-duplicate-banner/landmark-no-duplicate-banner-fail.html b/test/integration/full/landmark-no-duplicate-banner/landmark-no-duplicate-banner-fail.html index 777cb458d7..e6a04b3ee6 100644 --- a/test/integration/full/landmark-no-duplicate-banner/landmark-no-duplicate-banner-fail.html +++ b/test/integration/full/landmark-no-duplicate-banner/landmark-no-duplicate-banner-fail.html @@ -6,7 +6,6 @@ - diff --git a/test/integration/full/landmark-no-duplicate-banner/landmark-no-duplicate-banner-pass.html b/test/integration/full/landmark-no-duplicate-banner/landmark-no-duplicate-banner-pass.html index 6fc6a048df..48f057f6e9 100644 --- a/test/integration/full/landmark-no-duplicate-banner/landmark-no-duplicate-banner-pass.html +++ b/test/integration/full/landmark-no-duplicate-banner/landmark-no-duplicate-banner-pass.html @@ -6,7 +6,6 @@ - diff --git a/test/integration/full/landmark-no-duplicate-contentinfo/landmark-no-duplicate-contentinfo-fail.html b/test/integration/full/landmark-no-duplicate-contentinfo/landmark-no-duplicate-contentinfo-fail.html index 48797e8a9b..6769471ea1 100644 --- a/test/integration/full/landmark-no-duplicate-contentinfo/landmark-no-duplicate-contentinfo-fail.html +++ b/test/integration/full/landmark-no-duplicate-contentinfo/landmark-no-duplicate-contentinfo-fail.html @@ -6,7 +6,6 @@ - diff --git a/test/integration/full/landmark-no-duplicate-contentinfo/landmark-no-duplicate-contentinfo-pass.html b/test/integration/full/landmark-no-duplicate-contentinfo/landmark-no-duplicate-contentinfo-pass.html index 86377c7707..3fe864b7f2 100644 --- a/test/integration/full/landmark-no-duplicate-contentinfo/landmark-no-duplicate-contentinfo-pass.html +++ b/test/integration/full/landmark-no-duplicate-contentinfo/landmark-no-duplicate-contentinfo-pass.html @@ -6,7 +6,6 @@ - diff --git a/test/integration/full/landmark-one-main/landmark-one-main-fail.html b/test/integration/full/landmark-one-main/landmark-one-main-fail.html index 31e7549458..6b8c7d489e 100644 --- a/test/integration/full/landmark-one-main/landmark-one-main-fail.html +++ b/test/integration/full/landmark-one-main/landmark-one-main-fail.html @@ -6,7 +6,6 @@ - diff --git a/test/integration/full/landmark-one-main/landmark-one-main-pass1.html b/test/integration/full/landmark-one-main/landmark-one-main-pass1.html index f797234034..da137d3140 100644 --- a/test/integration/full/landmark-one-main/landmark-one-main-pass1.html +++ b/test/integration/full/landmark-one-main/landmark-one-main-pass1.html @@ -6,7 +6,6 @@ - diff --git a/test/integration/full/landmark-one-main/landmark-one-main-pass2.html b/test/integration/full/landmark-one-main/landmark-one-main-pass2.html index 44c6c92166..a65955ac78 100644 --- a/test/integration/full/landmark-one-main/landmark-one-main-pass2.html +++ b/test/integration/full/landmark-one-main/landmark-one-main-pass2.html @@ -6,7 +6,6 @@ - diff --git a/test/integration/full/options-parameter/options-parameter.html b/test/integration/full/options-parameter/options-parameter.html index ec5fe20a87..cec78e0701 100644 --- a/test/integration/full/options-parameter/options-parameter.html +++ b/test/integration/full/options-parameter/options-parameter.html @@ -7,7 +7,6 @@ - diff --git a/test/integration/full/page-has-heading-one/page-has-heading-one-fail.html b/test/integration/full/page-has-heading-one/page-has-heading-one-fail.html index 0e9b14ae67..b5f65e99d0 100644 --- a/test/integration/full/page-has-heading-one/page-has-heading-one-fail.html +++ b/test/integration/full/page-has-heading-one/page-has-heading-one-fail.html @@ -6,7 +6,6 @@ - diff --git a/test/integration/full/page-has-heading-one/page-has-heading-one-pass1.html b/test/integration/full/page-has-heading-one/page-has-heading-one-pass1.html index 52e9eb8798..f5c2e9544f 100644 --- a/test/integration/full/page-has-heading-one/page-has-heading-one-pass1.html +++ b/test/integration/full/page-has-heading-one/page-has-heading-one-pass1.html @@ -6,7 +6,6 @@ - diff --git a/test/integration/full/page-has-heading-one/page-has-heading-one-pass2.html b/test/integration/full/page-has-heading-one/page-has-heading-one-pass2.html index c8a8cc91ea..dad848a07d 100644 --- a/test/integration/full/page-has-heading-one/page-has-heading-one-pass2.html +++ b/test/integration/full/page-has-heading-one/page-has-heading-one-pass2.html @@ -6,7 +6,6 @@ - diff --git a/test/integration/full/rerun/rerun.html b/test/integration/full/rerun/rerun.html index bb8929eb6e..94067e2ab0 100644 --- a/test/integration/full/rerun/rerun.html +++ b/test/integration/full/rerun/rerun.html @@ -7,7 +7,6 @@ - diff --git a/test/rule-matches/color-contrast-matches.js b/test/rule-matches/color-contrast-matches.js index ab5fb3db50..69e112de4c 100644 --- a/test/rule-matches/color-contrast-matches.js +++ b/test/rule-matches/color-contrast-matches.js @@ -26,10 +26,8 @@ describe('color-contrast-matches', function() { '
' + '
'; var target = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should match when there is text', function() { @@ -37,10 +35,8 @@ describe('color-contrast-matches', function() { '
' + 'My text
'; var target = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isTrue( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isTrue(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match when there is text that is out of the container', function() { @@ -48,10 +44,8 @@ describe('color-contrast-matches', function() { '
' + 'My text
'; var target = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match when there is text that is out of the container with overflow hidden', function() { @@ -59,10 +53,8 @@ describe('color-contrast-matches', function() { '
' + 'text
'; var target = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should match when there is text that is in the scroll reach of container', function() { @@ -70,10 +62,8 @@ describe('color-contrast-matches', function() { '
' + 'text
'; var target = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isTrue( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isTrue(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should match when there is text that is only partially out of the container', function() { @@ -81,115 +71,91 @@ describe('color-contrast-matches', function() { '
' + 'My text
'; var target = fixture.querySelector('#target'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isTrue( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isTrue(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should match ', function() { fixture.innerHTML = ''; var target = fixture.querySelector('input'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isTrue( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isTrue(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match ', function() { fixture.innerHTML = ''; var target = fixture.querySelector('input'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match ', function() { fixture.innerHTML = ''; var target = fixture.querySelector('input'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match ', function() { fixture.innerHTML = ''; var target = fixture.querySelector('input'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match ', function() { fixture.innerHTML = ''; var target = fixture.querySelector('input'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); // Some browsers will fallback to type=text for unknown input types (looking at you IE) if (target.type === 'color') { - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); } }); it('should not match ', function() { fixture.innerHTML = ''; var target = fixture.querySelector('input'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); // Some browsers will fallback to type=text for unknown input types (looking at you IE) if (target.type === 'range') { - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); } }); it('should match '; var target = fixture.querySelector('select'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isTrue( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isTrue(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match '; var target = fixture.querySelector('select'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should match '; var target = fixture.querySelector('textarea'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isTrue( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isTrue(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match '; var target = fixture.querySelector('select'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should match '; var target = fixture.querySelector('button'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isTrue( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isTrue(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match '; var target = fixture.querySelector('button'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match ', function() { fixture.innerHTML = ''; var target = fixture.querySelector('button'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isFalse( rule.matches( target.querySelector('span'), - axe.utils.getNodeFromTree(tree[0], target.querySelector('span')) + axe.utils.getNodeFromTree(target.querySelector('span')) ) ); }); @@ -259,11 +214,11 @@ describe('color-contrast-matches', function() { it('should not match ', function() { fixture.innerHTML = ''; var target = fixture.querySelector('button'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isFalse( rule.matches( target.querySelector('i'), - axe.utils.getNodeFromTree(tree[0], target.querySelector('i')) + axe.utils.getNodeFromTree(target.querySelector('i')) ) ); }); @@ -271,106 +226,84 @@ describe('color-contrast-matches', function() { it('should not match ', function() { fixture.innerHTML = ''; var target = fixture.querySelector('input'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it("should not match a disabled input's label - explicit label", function() { fixture.innerHTML = ''; var target = fixture.querySelector('label'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it("should not match a disabled input's label - implicit label (input)", function() { fixture.innerHTML = ''; var target = fixture.querySelector('label'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it("should not match a disabled input's label - implicit label (textarea)", function() { fixture.innerHTML = ''; var target = fixture.querySelector('label'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it("should not match a disabled input's label - implicit label (select)", function() { fixture.innerHTML = ''; var target = fixture.querySelector('label'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it("should not match a disabled input's label - aria-labelledby", function() { fixture.innerHTML = '
Test
'; var target = fixture.querySelector('div'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match aria-disabled=true', function() { fixture.innerHTML = '
hi
'; var target = fixture.querySelector('div'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match a descendant of aria-disabled=true', function() { fixture.innerHTML = '
hi
'; var target = fixture.querySelector('span'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match a descendant of a disabled fieldset', function() { fixture.innerHTML = '
'; var target = fixture.querySelector('label'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match a descendant of an explicit label for a disabled input', function() { fixture.innerHTML = ''; var target = fixture.querySelector('span'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); it('should not match a descendant of an implicit label for a disabled input', function() { fixture.innerHTML = ''; var target = fixture.querySelector('span'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isFalse( - rule.matches(target, axe.utils.getNodeFromTree(tree[0], target)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); if (shadowSupport) { @@ -387,12 +320,9 @@ describe('color-contrast-matches', function() { var shadowTarget = fixture.firstChild.shadowRoot.querySelector( '#shadowTarget' ); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isTrue( - rule.matches( - shadowTarget, - axe.utils.getNodeFromTree(tree[0], shadowTarget) - ) + rule.matches(shadowTarget, axe.utils.getNodeFromTree(shadowTarget)) ); }); @@ -411,12 +341,9 @@ describe('color-contrast-matches', function() { var shadowLabel = fixture.firstChild.shadowRoot.querySelector( '#shadowLabel' ); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isFalse( - rule.matches( - shadowLabel, - axe.utils.getNodeFromTree(tree[0], shadowLabel) - ) + rule.matches(shadowLabel, axe.utils.getNodeFromTree(shadowLabel)) ); }); @@ -434,12 +361,9 @@ describe('color-contrast-matches', function() { var shadowLabel = fixture.firstChild.shadowRoot.querySelector( '#shadowLabel' ); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isFalse( - rule.matches( - shadowLabel, - axe.utils.getNodeFromTree(tree[0], shadowLabel) - ) + rule.matches(shadowLabel, axe.utils.getNodeFromTree(shadowLabel)) ); }); @@ -458,12 +382,9 @@ describe('color-contrast-matches', function() { var shadowLabel = fixture.firstChild.shadowRoot.querySelector( '#shadowLabel' ); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isFalse( - rule.matches( - shadowLabel, - axe.utils.getNodeFromTree(tree[0], shadowLabel) - ) + rule.matches(shadowLabel, axe.utils.getNodeFromTree(shadowLabel)) ); }); @@ -475,12 +396,9 @@ describe('color-contrast-matches', function() { shadowRoot.innerHTML = ''; var shadowTarget = container.shadowRoot.querySelector('#input'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isFalse( - rule.matches( - shadowTarget, - axe.utils.getNodeFromTree(tree[0], shadowTarget) - ) + rule.matches(shadowTarget, axe.utils.getNodeFromTree(shadowTarget)) ); }); @@ -498,9 +416,9 @@ describe('color-contrast-matches', function() { '

Other text

'; var firstChild = fixture.querySelector('#firstChild'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); + axe._tree = axe.utils.getFlattenedTree(fixture); assert.isTrue( - rule.matches(firstChild, axe.utils.getNodeFromTree(tree[0], firstChild)) + rule.matches(firstChild, axe.utils.getNodeFromTree(firstChild)) ); }); @@ -521,10 +439,8 @@ describe('color-contrast-matches', function() { shadowRoot.appendChild(createContentSlotted()); var input = slotted.querySelector('input'); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture)); - assert.isTrue( - rule.matches(input, axe.utils.getNodeFromTree(tree[0], input)) - ); + axe._tree = axe.utils.getFlattenedTree(fixture); + assert.isTrue(rule.matches(input, axe.utils.getNodeFromTree(input))); }); } }); diff --git a/test/testutils.js b/test/testutils.js index 3cdd805fdd..29d6d7e304 100644 --- a/test/testutils.js +++ b/test/testutils.js @@ -90,12 +90,13 @@ testUtils.fixtureSetup = function(content) { fixture.appendChild(node); }); } - axe._tree = axe.utils.getFlattenedTree(fixture); - axe._selectorData = axe.utils.getSelectorData(axe._tree); axe._cache = { nodeMap: new WeakMap(), - idRefs: {} + idRefs: {}, + idRefsCached: false }; + axe._tree = axe.utils.getFlattenedTree(fixture); + axe._selectorData = axe.utils.getSelectorData(axe._tree); return fixture; }; @@ -123,7 +124,7 @@ testUtils.checkSetup = function(content, options, target) { if (typeof target === 'string') { node = axe.utils.querySelectorAll(axe._tree[0], target)[0]; } else if (target instanceof Node) { - node = axe.utils.getNodeFromTree(axe._tree[0], target); + node = axe.utils.getNodeFromTree(target); } else { node = target; } @@ -185,7 +186,7 @@ testUtils.shadowCheckSetup = function( // query the composed tree AFTER shadowDOM has been attached axe._tree = axe.utils.getFlattenedTree(fixture); - var node = axe.utils.getNodeFromTree(axe._tree[0], targetCandidate); + var node = axe.utils.getNodeFromTree(targetCandidate); return [node.actualNode, options, node]; }; @@ -301,3 +302,11 @@ testUtils.isIE11 = (function isIE11(navigator) { })(navigator); axe.testUtils = testUtils; + +beforeEach(function() { + axe._cache = { + nodeMap: new WeakMap(), + idRefs: {}, + idRefsCached: false + }; +}); From 0324acbf9f93722f7fe4760e7279230347f9782c Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Wed, 17 Apr 2019 16:11:18 -0600 Subject: [PATCH 04/14] remove redundant idRefsCached --- lib/commons/aria/is-accessible-ref.js | 4 ++-- lib/core/public/run-rules.js | 4 +--- test/testutils.js | 9 +-------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/commons/aria/is-accessible-ref.js b/lib/commons/aria/is-accessible-ref.js index 8c1e0a6765..62403760ea 100644 --- a/lib/commons/aria/is-accessible-ref.js +++ b/lib/commons/aria/is-accessible-ref.js @@ -35,8 +35,8 @@ aria.isAccessibleRef = function isAccessibleRef(node) { // because axe.commons is not available in axe.utils, we can't do // this caching when we build up the virtual tree - if (!axe._cache.idRefsCached) { - axe._cache.idRefsCached = true; + if (!axe._cache.idRefs) { + axe._cache.idRefs = {}; // Get all idref(s) attributes on the lookup table const refAttrs = Object.keys(aria.lookupTable.attributes).filter(attr => { const { type } = aria.lookupTable.attributes[attr]; diff --git a/lib/core/public/run-rules.js b/lib/core/public/run-rules.js index 6004ae96ae..d740531371 100644 --- a/lib/core/public/run-rules.js +++ b/lib/core/public/run-rules.js @@ -20,9 +20,7 @@ function runRules(context, options, resolve, reject) { 'use strict'; try { axe._cache = { - nodeMap: new WeakMap(), - idRefs: {}, - idRefsCached: false + nodeMap: new WeakMap() }; context = new Context(context); diff --git a/test/testutils.js b/test/testutils.js index 29d6d7e304..6114340f3f 100644 --- a/test/testutils.js +++ b/test/testutils.js @@ -90,11 +90,6 @@ testUtils.fixtureSetup = function(content) { fixture.appendChild(node); }); } - axe._cache = { - nodeMap: new WeakMap(), - idRefs: {}, - idRefsCached: false - }; axe._tree = axe.utils.getFlattenedTree(fixture); axe._selectorData = axe.utils.getSelectorData(axe._tree); @@ -305,8 +300,6 @@ axe.testUtils = testUtils; beforeEach(function() { axe._cache = { - nodeMap: new WeakMap(), - idRefs: {}, - idRefsCached: false + nodeMap: new WeakMap() }; }); From b6adc565b12548363d69fb3456b42dc788f386a7 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Wed, 17 Apr 2019 16:14:43 -0600 Subject: [PATCH 05/14] use const --- lib/core/utils/flattened-tree.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/utils/flattened-tree.js b/lib/core/utils/flattened-tree.js index 7562c080de..dcccdf1126 100644 --- a/lib/core/utils/flattened-tree.js +++ b/lib/core/utils/flattened-tree.js @@ -154,6 +154,6 @@ axe.utils.getFlattenedTree = function(node, shadowId) { axe.utils.getNodeFromTree = function(vNode, node) { // TODO: removing vNode is a breaking change, but we can skirt that // for now by ignoring it if passed in - let el = node || vNode; + const el = node || vNode; return axe._cache.nodeMap.get(el); }; From 6698717702cdae8bfc818e50613b87bc4e4c4af8 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Thu, 18 Apr 2019 12:08:53 -0600 Subject: [PATCH 06/14] add deprecation comment to getNodeFromTree, move dep to dev, add testutils function to setup axe._tree --- lib/core/utils/flattened-tree.js | 6 +- lib/core/utils/is-hidden.js | 9 +- package.json | 5 +- test/checks/aria/required-children.js | 6 +- test/checks/aria/required-parent.js | 6 +- test/checks/forms/group-labelledby.js | 6 +- test/checks/keyboard/focusable-disabled.js | 2 +- .../checks/keyboard/focusable-not-tabbable.js | 2 +- test/checks/label/duplicate-img-label.js | 16 +- test/checks/label/help-same-as-label.js | 8 +- test/checks/label/title-only.js | 4 +- test/checks/tables/td-has-header.js | 28 +- test/checks/tables/th-has-data-cells.js | 20 +- test/checks/visibility/hidden-content.js | 4 +- test/commons/color/get-background-color.js | 92 ++-- test/commons/dom/find-up.js | 20 +- test/commons/dom/get-tabbable-elements.js | 6 +- test/commons/dom/has-content-virtual.js | 4 +- test/commons/table/get-cell-position.js | 10 +- test/commons/table/get-headers.js | 16 +- test/commons/table/get-scope.js | 22 +- test/commons/table/is-data-table.js | 86 +-- test/commons/text/accessible-text.js | 502 +++++++++--------- test/commons/text/label-virtual.js | 32 +- test/rule-matches/color-contrast-matches.js | 84 +-- test/testutils.js | 10 + 26 files changed, 509 insertions(+), 497 deletions(-) diff --git a/lib/core/utils/flattened-tree.js b/lib/core/utils/flattened-tree.js index dcccdf1126..e13a649c0e 100644 --- a/lib/core/utils/flattened-tree.js +++ b/lib/core/utils/flattened-tree.js @@ -32,6 +32,7 @@ function virtualDOMfromNode(node, shadowId) { shadowId: shadowId, children: [], actualNode: node, + _isHidden: null, // will be populated by axe.utils.isHidden get isFocusable() { if (!vNodeCache._isFocusable) { vNodeCache._isFocusable = axe.commons.dom.isFocusable(node); @@ -148,12 +149,11 @@ axe.utils.getFlattenedTree = function(node, shadowId) { /** * Return a single node from the virtual dom tree * - * @param {Object} vNode The flattened, virtual DOM tree (optional) + * @param {Object} vNode The flattened, virtual DOM tree (deprecated) * @param {Node} node The HTML DOM node */ axe.utils.getNodeFromTree = function(vNode, node) { - // TODO: removing vNode is a breaking change, but we can skirt that - // for now by ignoring it if passed in + // TODO: remove vNode parameter in next major release const el = node || vNode; return axe._cache.nodeMap.get(el); }; diff --git a/lib/core/utils/is-hidden.js b/lib/core/utils/is-hidden.js index d70673346e..4e682fc3c4 100644 --- a/lib/core/utils/is-hidden.js +++ b/lib/core/utils/is-hidden.js @@ -21,8 +21,8 @@ axe.utils.isHidden = function isHidden(el, recursed) { el = el.host; // grab the host Node } - if (node && typeof node.isHidden !== 'undefined') { - return node.isHidden; + if (node && node._isHidden !== null) { + return node._isHidden; } const style = window.getComputedStyle(el, null); @@ -42,8 +42,11 @@ axe.utils.isHidden = function isHidden(el, recursed) { parent = el.assignedSlot ? el.assignedSlot : el.parentNode; isHidden = axe.utils.isHidden(parent, true); + // cache the results of the isHidden check on the parent tree + // so we don't have to look at the parent tree again for all its + // descendants if (node) { - node.isHidden = isHidden; + node._isHidden = isHidden; } return isHidden; diff --git a/package.json b/package.json index fee3947629..69bc794eab 100644 --- a/package.json +++ b/package.json @@ -122,11 +122,10 @@ "sri-toolbox": "^0.2.0", "standard-version": "^5.0.0", "typescript": "^2.9.2", - "uglify-js": "^3.4.4" - }, - "dependencies": { + "uglify-js": "^3.4.4", "weakmap-polyfill": "^2.0.0" }, + "dependencies": {}, "lint-staged": { "*.{md,json,ts}": [ "prettier --write", diff --git a/test/checks/aria/required-children.js b/test/checks/aria/required-children.js index 4aa97dc5d8..7ebb0dbefc 100644 --- a/test/checks/aria/required-children.js +++ b/test/checks/aria/required-children.js @@ -32,7 +32,7 @@ describe('aria-required-children', function() { var shadowRoot = target.attachShadow({ mode: 'open' }); shadowRoot.innerHTML = '

Nothing here.

'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var virtualTarget = axe.utils.getNodeFromTree(target); var params = [target, undefined, virtualTarget]; @@ -63,7 +63,7 @@ describe('aria-required-children', function() { var shadowRoot = target.attachShadow({ mode: 'open' }); shadowRoot.innerHTML = '

Nothing here.

'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var virtualTarget = axe.utils.getNodeFromTree(target); var params = [target, undefined, virtualTarget]; @@ -113,7 +113,7 @@ describe('aria-required-children', function() { shadowRoot.innerHTML = '

Nothing here.

Textbox

'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var virtualTarget = axe.utils.getNodeFromTree(target); var params = [target, undefined, virtualTarget]; diff --git a/test/checks/aria/required-parent.js b/test/checks/aria/required-parent.js index de637fde32..170094e6ee 100644 --- a/test/checks/aria/required-parent.js +++ b/test/checks/aria/required-parent.js @@ -32,7 +32,7 @@ describe('aria-required-parent', function() { .attachShadow({ mode: 'open' }); shadowRoot.innerHTML = '

Nothing here.

'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var shadowContent = shadowRoot.querySelector('#target'); var virtualTarget = axe.utils.getNodeFromTree(shadowContent); @@ -102,7 +102,7 @@ describe('aria-required-parent', function() { .attachShadow({ mode: 'open' }); shadowRoot.innerHTML = '

Nothing here.

'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var shadowContent = shadowRoot.querySelector('#target'); var virtualTarget = axe.utils.getNodeFromTree(shadowContent); @@ -124,7 +124,7 @@ describe('aria-required-parent', function() { .attachShadow({ mode: 'open' }); shadowRoot.innerHTML = '

Nothing here.

'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var shadowContent = shadowRoot.querySelector('#target'); var virtualTarget = axe.utils.getNodeFromTree(shadowContent); diff --git a/test/checks/forms/group-labelledby.js b/test/checks/forms/group-labelledby.js index 340fd3f6cb..de4b08f58a 100644 --- a/test/checks/forms/group-labelledby.js +++ b/test/checks/forms/group-labelledby.js @@ -317,7 +317,7 @@ describe('group-labelledby', function() { type + '" aria-labelledby="shared three" name="groupname">'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var shadowContent = shadowRoot.querySelector('#target'); var virtualTarget = axe.utils.getNodeFromTree(shadowContent); @@ -355,7 +355,7 @@ describe('group-labelledby', function() { type + '" aria-labelledby="shared three" name="groupname">'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var shadowContent = shadowRoot.querySelector('#target'); var virtualTarget = axe.utils.getNodeFromTree(shadowContent); @@ -394,7 +394,7 @@ describe('group-labelledby', function() { type + '" id="target" name="samename" aria-labelledby="shared three">'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var shadowContent = shadowRoot.querySelector('#target'); var virtualTarget = axe.utils.getNodeFromTree(shadowContent); diff --git a/test/checks/keyboard/focusable-disabled.js b/test/checks/keyboard/focusable-disabled.js index 6cfe5fe265..1c023fe289 100644 --- a/test/checks/keyboard/focusable-disabled.js +++ b/test/checks/keyboard/focusable-disabled.js @@ -106,7 +106,7 @@ describe('focusable-disabled', function() { var node = fixture.querySelector('#target'); var shadow = node.attachShadow({ mode: 'open' }); shadow.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); axe._selectorData = axe.utils.getSelectorData(axe._tree); var virtualNode = axe.utils.getNodeFromTree(node); var actual = check.evaluate.call(checkContext, node, {}, virtualNode); diff --git a/test/checks/keyboard/focusable-not-tabbable.js b/test/checks/keyboard/focusable-not-tabbable.js index f3b4af4c99..a0665adf6f 100644 --- a/test/checks/keyboard/focusable-not-tabbable.js +++ b/test/checks/keyboard/focusable-not-tabbable.js @@ -102,7 +102,7 @@ describe('focusable-not-tabbable', function() { var node = fixture.querySelector('#target'); var shadow = node.attachShadow({ mode: 'open' }); shadow.innerHTML = '

btn

'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); axe._selectorData = axe.utils.getSelectorData(axe._tree); var virtualNode = axe.utils.getNodeFromTree(node); var actual = check.evaluate.call(checkContext, node, {}, virtualNode); diff --git a/test/checks/label/duplicate-img-label.js b/test/checks/label/duplicate-img-label.js index d7f8681ab8..bd15675702 100644 --- a/test/checks/label/duplicate-img-label.js +++ b/test/checks/label/duplicate-img-label.js @@ -13,7 +13,7 @@ describe('duplicate-img-label', function() { it('should return false if no img is present', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isFalse( checks['duplicate-img-label'].evaluate( node, @@ -26,7 +26,7 @@ describe('duplicate-img-label', function() { it('should return false if no text is present', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var result = checks['duplicate-img-label'].evaluate( node, undefined, @@ -39,7 +39,7 @@ describe('duplicate-img-label', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isFalse( checks['duplicate-img-label'].evaluate( node, @@ -53,7 +53,7 @@ describe('duplicate-img-label', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isFalse( checks['duplicate-img-label'].evaluate( node, @@ -67,7 +67,7 @@ describe('duplicate-img-label', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isTrue( checks['duplicate-img-label'].evaluate( node, @@ -81,7 +81,7 @@ describe('duplicate-img-label', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isTrue( checks['duplicate-img-label'].evaluate( node, @@ -94,7 +94,7 @@ describe('duplicate-img-label', function() { it('should return false if img and text are both blank', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isFalse( checks['duplicate-img-label'].evaluate( node, @@ -108,7 +108,7 @@ describe('duplicate-img-label', function() { fixture.innerHTML = ''; var node = fixture.querySelector('#target'); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isFalse( checks['duplicate-img-label'].evaluate( node, diff --git a/test/checks/label/help-same-as-label.js b/test/checks/label/help-same-as-label.js index 018d9e1beb..145383dab6 100644 --- a/test/checks/label/help-same-as-label.js +++ b/test/checks/label/help-same-as-label.js @@ -15,7 +15,7 @@ describe('help-same-as-label', function() { node.setAttribute('aria-label', 'Duplicate'); fixture.appendChild(node); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isTrue( checks['help-same-as-label'].evaluate( node, @@ -37,7 +37,7 @@ describe('help-same-as-label', function() { fixture.appendChild(node); fixture.appendChild(dby); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isTrue( checks['help-same-as-label'].evaluate( node, @@ -54,7 +54,7 @@ describe('help-same-as-label', function() { fixture.appendChild(node); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isFalse( checks['help-same-as-label'].evaluate( node, @@ -75,7 +75,7 @@ describe('help-same-as-label', function() { fixture.appendChild(node); fixture.appendChild(dby); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isFalse( checks['help-same-as-label'].evaluate( node, diff --git a/test/checks/label/title-only.js b/test/checks/label/title-only.js index 089456d35d..0cd86e175d 100644 --- a/test/checks/label/title-only.js +++ b/test/checks/label/title-only.js @@ -15,7 +15,7 @@ describe('title-only', function() { fixture.appendChild(node); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isTrue( checks['title-only'].evaluate( @@ -45,7 +45,7 @@ describe('title-only', function() { fixture.appendChild(node); fixture.appendChild(dby); - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isTrue( checks['title-only'].evaluate( diff --git a/test/checks/tables/td-has-header.js b/test/checks/tables/td-has-header.js index ac023de37c..9761b60bd7 100644 --- a/test/checks/tables/td-has-header.js +++ b/test/checks/tables/td-has-header.js @@ -37,7 +37,7 @@ describe('td-has-header', function() { ' ' + ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); var result = checks['td-has-header'].evaluate.call(checkContext, node); @@ -49,7 +49,7 @@ describe('td-has-header', function() { fixture.innerHTML = '' + ' ' + '
hi hello
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isTrue(checks['td-has-header'].evaluate.call(checkContext, node)); }); @@ -61,7 +61,7 @@ describe('td-has-header', function() { ' hi hello ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isTrue(checks['td-has-header'].evaluate.call(checkContext, node)); }); @@ -73,7 +73,7 @@ describe('td-has-header', function() { ' hi hello ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isTrue(checks['td-has-header'].evaluate.call(checkContext, node)); }); @@ -86,7 +86,7 @@ describe('td-has-header', function() { ' hi hello ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isTrue(checks['td-has-header'].evaluate.call(checkContext, node)); }); @@ -100,7 +100,7 @@ describe('td-has-header', function() { ' hi hello ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isTrue(checks['td-has-header'].evaluate.call(checkContext, node)); }); @@ -112,7 +112,7 @@ describe('td-has-header', function() { ' hello ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isTrue(checks['td-has-header'].evaluate.call(checkContext, node)); }); @@ -121,7 +121,7 @@ describe('td-has-header', function() { fixture.innerHTML = '' + ' ' + '
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isTrue(checks['td-has-header'].evaluate.call(checkContext, node)); }); @@ -130,7 +130,7 @@ describe('td-has-header', function() { fixture.innerHTML = '' + ' ' + '
hi hello
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isFalse(checks['td-has-header'].evaluate.call(checkContext, node)); @@ -147,7 +147,7 @@ describe('td-has-header', function() { ' hi hello Ok ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isFalse(checks['td-has-header'].evaluate.call(checkContext, node)); @@ -165,7 +165,7 @@ describe('td-has-header', function() { ' Hello goodbye ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isFalse(checks['td-has-header'].evaluate.call(checkContext, node)); @@ -177,7 +177,7 @@ describe('td-has-header', function() { ' Hello goodbye ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isFalse(checks['td-has-header'].evaluate.call(checkContext, node)); @@ -190,7 +190,7 @@ describe('td-has-header', function() { ' hi hello ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isFalse(checks['td-has-header'].evaluate.call(checkContext, node)); }); @@ -206,7 +206,7 @@ describe('td-has-header', function() { ' data ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = axe.utils.querySelectorAll(axe._tree, 'table')[0].actualNode; assert.isTrue(checks['td-has-header'].evaluate.call(checkContext, node)); }); diff --git a/test/checks/tables/th-has-data-cells.js b/test/checks/tables/th-has-data-cells.js index 0270d33e18..3507734a16 100644 --- a/test/checks/tables/th-has-data-cells.js +++ b/test/checks/tables/th-has-data-cells.js @@ -17,7 +17,7 @@ describe('th-has-data-cells', function() { ' hi hello ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isTrue( checks['th-has-data-cells'].evaluate.call(checkContext, node) @@ -31,7 +31,7 @@ describe('th-has-data-cells', function() { ' hi hello' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isTrue( checks['th-has-data-cells'].evaluate.call(checkContext, node) @@ -45,7 +45,7 @@ describe('th-has-data-cells', function() { ' H H ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isTrue( checks['th-has-data-cells'].evaluate.call(checkContext, node) @@ -59,7 +59,7 @@ describe('th-has-data-cells', function() { ' H H ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isTrue( checks['th-has-data-cells'].evaluate.call(checkContext, node) @@ -72,7 +72,7 @@ describe('th-has-data-cells', function() { ' ' + ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isTrue( checks['th-has-data-cells'].evaluate.call(checkContext, node) @@ -91,7 +91,7 @@ describe('th-has-data-cells', function() { ' hi ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isTrue( checks['th-has-data-cells'].evaluate.call(checkContext, node) @@ -105,7 +105,7 @@ describe('th-has-data-cells', function() { ' hi ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isUndefined( checks['th-has-data-cells'].evaluate.call(checkContext, node) @@ -119,7 +119,7 @@ describe('th-has-data-cells', function() { ' hi ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isUndefined( checks['th-has-data-cells'].evaluate.call(checkContext, node) @@ -132,7 +132,7 @@ describe('th-has-data-cells', function() { ' axe AXE ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = fixture.querySelector('table'); assert.isUndefined( checks['th-has-data-cells'].evaluate.call(checkContext, node) @@ -150,7 +150,7 @@ describe('th-has-data-cells', function() { ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var node = axe.utils.querySelectorAll(axe._tree, 'table')[0].actualNode; assert.isTrue( checks['th-has-data-cells'].evaluate.call(checkContext, node) diff --git a/test/checks/visibility/hidden-content.js b/test/checks/visibility/hidden-content.js index 770d2a68a1..95c356aa3e 100644 --- a/test/checks/visibility/hidden-content.js +++ b/test/checks/visibility/hidden-content.js @@ -51,7 +51,7 @@ describe('hidden content', function() { it('should skip whitelisted elements', function() { var node = document.querySelector('head'); - axe._tree = axe.utils.getFlattenedTree(document.documentElement); + axe.testUtils.flatTreeSetup(document.documentElement); var virtualNode = axe.utils.getNodeFromTree(node); assert.isTrue( checks['hidden-content'].evaluate(node, undefined, virtualNode) @@ -65,7 +65,7 @@ describe('hidden content', function() { .attachShadow({ mode: 'open' }); shadowRoot.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var shadow = document.querySelector('#shadow'); var virtualShadow = axe.utils.getNodeFromTree(shadow); diff --git a/test/commons/color/get-background-color.js b/test/commons/color/get-background-color.js index b6ed61dfe6..cecc58bcae 100644 --- a/test/commons/color/get-background-color.js +++ b/test/commons/color/get-background-color.js @@ -20,7 +20,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'); var parent = fixture.querySelector('#parent'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(128, 0, 0, 1); assert.closeTo(actual.red, expected.red, 0.5); @@ -44,7 +44,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'); var pos = fixture.querySelector('#pos'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(64, 64, 0, 1); @@ -64,7 +64,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'); var under = fixture.querySelector('#under'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(64, 64, 0, 1); assert.closeTo(actual.red, expected.red, 0.5); @@ -90,7 +90,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'); var under = fixture.querySelector('#under'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(64, 64, 0, 1); @@ -109,7 +109,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'); var parent = fixture.querySelector('#parent'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(64, 64, 0, 1); assert.closeTo(actual.red, expected.red, 0.5); @@ -127,7 +127,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'); var parent = fixture.querySelector('#parent'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(64, 64, 0, 1); assert.equal(actual.red, expected.red); @@ -146,7 +146,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'); var parent = fixture.querySelector('#parent'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); assert.isNull(actual); assert.deepEqual(bgNodes, [target, parent]); @@ -156,7 +156,7 @@ describe('color.getBackgroundColor', function() { it('should return white if transparency goes all the way up to document', function() { fixture.innerHTML = '
'; var target = fixture.querySelector('#target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target); var expected = new axe.commons.color.Color(255, 255, 255, 1); assert.equal(actual.red, expected.red); @@ -172,7 +172,7 @@ describe('color.getBackgroundColor', function() { '
'; var target = fixture.querySelector('#target'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); assert.isNull(actual); assert.deepEqual(bgNodes, [target]); @@ -183,7 +183,7 @@ describe('color.getBackgroundColor', function() { fixture.innerHTML = '
' + '
Hello
'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor( document.getElementById('target'), [] @@ -196,7 +196,7 @@ describe('color.getBackgroundColor', function() { fixture.innerHTML = '
' + '
Hello
'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor( document.getElementById('target'), [] @@ -214,7 +214,7 @@ describe('color.getBackgroundColor', function() { ''; var target = fixture.querySelector('#target'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(0, 128, 0, 1); assert.equal(actual.red, expected.red); @@ -230,7 +230,7 @@ describe('color.getBackgroundColor', function() { '
' + '

Text oh heyyyy and here\'s
a link

' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor( document.getElementById('target'), [] @@ -251,7 +251,7 @@ describe('color.getBackgroundColor', function() { '
' + '

Text oh heyyyy and here\'s
a link

' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor( document.getElementById('target'), [] @@ -306,7 +306,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'), parent = fixture.querySelector('#parent'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(243, 243, 243, 1); assert.equal(actual.red, expected.red); @@ -328,7 +328,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'), parent = fixture.querySelector('#parent'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(243, 243, 243, 1); assert.equal(actual.red, expected.red); @@ -350,7 +350,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'), parent = fixture.querySelector('#parent'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(243, 243, 243, 1); assert.equal(actual.red, expected.red); @@ -369,7 +369,7 @@ describe('color.getBackgroundColor', function() { var bgNodes = []; var target = fixture.querySelector('#target'); var parent = fixture.querySelector('#parent'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(255, 255, 255, 1); assert.equal(actual.red, expected.red); @@ -386,7 +386,7 @@ describe('color.getBackgroundColor', function() { ''; var target = fixture.querySelector('#target'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(0, 0, 0, 1); assert.equal(actual.red, expected.red); @@ -404,7 +404,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'); var parent = fixture.querySelector('#parent'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(255, 255, 255, 1); assert.equal(actual.red, expected.red); @@ -430,7 +430,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'), parent = fixture.querySelector('#parent'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(243, 243, 243, 1); assert.equal(actual.red, expected.red); @@ -452,7 +452,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'); var parent = fixture.querySelector('#parent'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(255, 255, 255, 1); @@ -473,7 +473,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'); var parent = fixture.querySelector('#parent'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes); var expected = new axe.commons.color.Color(255, 255, 255, 1); @@ -496,7 +496,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'); var shifted = fixture.querySelector('#shifted'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, bgNodes, false); var expected = new axe.commons.color.Color(0, 0, 0, 1); @@ -522,7 +522,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var outcome = axe.commons.color.getBackgroundColor(target, bgNodes, false); assert.isNull(outcome); assert.equal(axe.commons.color.incompleteData.get('bgColor'), 'bgImage'); @@ -542,7 +542,7 @@ describe('color.getBackgroundColor', function() { var target = fixture.querySelector('#target'); var bgNodes = []; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var outcome = axe.commons.color.getBackgroundColor(target, bgNodes, false); assert.isNull(outcome); assert.equal(axe.commons.color.incompleteData.get('bgColor'), 'imgNode'); @@ -559,7 +559,7 @@ describe('color.getBackgroundColor', function() { var bgNodes = []; window.scroll(0, 0); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); axe.commons.color.getBackgroundColor(targetEl, bgNodes, true); assert.equal(window.pageYOffset, 0); @@ -576,7 +576,7 @@ describe('color.getBackgroundColor', function() { var bgNodes = []; window.scroll(0, 0); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); axe.commons.color.getBackgroundColor(targetEl, bgNodes, false); assert.notEqual(window.pageYOffset, 0); @@ -588,7 +588,7 @@ describe('color.getBackgroundColor', function() { 'style="z-index:-1; position:absolute; width:100%; height:2em; background: #000">' + '
Some text
'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor( document.getElementById('target'), [] @@ -610,7 +610,7 @@ describe('color.getBackgroundColor', function() { var orig = document.body.style.background; document.body.style.background = '#FFF'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor( document.getElementById('target'), [] @@ -631,7 +631,7 @@ describe('color.getBackgroundColor', function() { var orig = document.body.style.background; document.body.style.background = '#F00'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor( document.getElementById('target'), [] @@ -650,7 +650,7 @@ describe('color.getBackgroundColor', function() { var orig = document.body.style.background; document.body.style.background = '#F00'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor( document.getElementById('target'), [] @@ -669,7 +669,7 @@ describe('color.getBackgroundColor', function() { var orig = document.documentElement.style.background; document.documentElement.style.background = '#0F0'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor( document.getElementById('target'), [] @@ -697,7 +697,7 @@ describe('color.getBackgroundColor', function() { // This shouldn't cause a scroll var target1 = document.getElementById('tgt1'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); axe.commons.color.getBackgroundColor(target1, []); // Otherwise this would not be on the black bg anymore: @@ -716,7 +716,7 @@ describe('color.getBackgroundColor', function() { html += 'foo
'; } fixture.innerHTML = '' + html + ''; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var outcome = axe.commons.color.getBackgroundColor(fixture.firstChild, []); assert.isNull(outcome); assert.equal( @@ -730,7 +730,7 @@ describe('color.getBackgroundColor', function() { '
' + '
Text' + '
'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var target = fixture.querySelector('#target'); var actual = axe.commons.color.getBackgroundColor(target, []); @@ -748,7 +748,7 @@ describe('color.getBackgroundColor', function() { '
' + 'Text' + '
'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var target = shadow.querySelector('#shadowTarget'); var actual = axe.commons.color.getBackgroundColor(target, []); @@ -768,7 +768,7 @@ describe('color.getBackgroundColor', function() { var shadow = container.attachShadow({ mode: 'open' }); shadow.innerHTML = 'Text'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var target = shadow.querySelector('#shadowTarget'); var actual = axe.commons.color.getBackgroundColor(target, [], false); @@ -790,7 +790,7 @@ describe('color.getBackgroundColor', function() { '
'; var target = shadow.querySelector('#target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, []); var expected = new axe.commons.color.Color(0, 0, 0, 1); @@ -810,10 +810,10 @@ describe('color.getBackgroundColor', function() { var shadow = container.attachShadow({ mode: 'open' }); shadow.innerHTML = '
Text
'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var target = shadow.querySelector('#shadowTarget'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(target, []); assert.equal(actual.red, 255); assert.equal(actual.green, 255); @@ -834,7 +834,7 @@ describe('color.getBackgroundColor', function() { shadow1.innerHTML = '
'; var elm2 = document.querySelector('#elm2'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(elm2, []); assert.equal(actual.red, 0); assert.equal(actual.blue, 0); @@ -863,7 +863,7 @@ describe('color.getBackgroundColor', function() { ''; var elm3 = shadow2.querySelector('#elm3'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var actual = axe.commons.color.getBackgroundColor(elm3, []); assert.closeTo(actual.red, 128, 2); assert.closeTo(actual.blue, 128, 2); @@ -881,7 +881,7 @@ describe('color.getBackgroundColor', function() { var shadow = container.attachShadow({ mode: 'open' }); shadow.innerHTML = '
Text
More text
'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var target = shadow.querySelector('#shadowTarget'); var actual = axe.commons.color.getBackgroundColor(target, []); assert.equal(actual.red, 0); @@ -900,7 +900,7 @@ describe('color.getBackgroundColor', function() { var shadow = container.attachShadow({ mode: 'open' }); shadow.innerHTML = '
Text
More text
'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var target = shadow.querySelector('#shadowTarget'); var actual = axe.commons.color.getBackgroundColor(target, []); assert.isNull(actual); @@ -915,7 +915,7 @@ describe('color.getBackgroundColor', function() { div.innerHTML = 'Link'; var shadow = div.attachShadow({ mode: 'open' }); shadow.innerHTML = '

'; - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); var linkElm = div.querySelector('a'); var actual = axe.commons.color.getBackgroundColor(linkElm, []); assert.equal(actual.red, 0); diff --git a/test/commons/dom/find-up.js b/test/commons/dom/find-up.js index 983c7b0125..ab2bc7704a 100644 --- a/test/commons/dom/find-up.js +++ b/test/commons/dom/find-up.js @@ -18,7 +18,7 @@ describe('dom.findUp', function() { var start = document.getElementById('start'), target = document.getElementById('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal( axe.commons.dom.findUp(start, '.target'), target, @@ -30,7 +30,7 @@ describe('dom.findUp', function() { fixture.innerHTML = '
'; var start = document.getElementById('start'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isNull(axe.commons.dom.findUp(start, '.nomatchyplzkthx')); }); @@ -38,7 +38,7 @@ describe('dom.findUp', function() { fixture.innerHTML = '
'; var start = document.getElementById('start'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isNull(axe.commons.dom.findUp(start, '.target')); }); @@ -60,7 +60,7 @@ describe('dom.findUp', function() { fixture.innerHTML = ''; makeShadowTree(fixture.querySelector('div')); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture.firstChild)); + var tree = axe.testUtils.flatTreeSetup(fixture.firstChild); var el = axe.utils.querySelectorAll(tree, 'a')[0]; assert.equal( axe.commons.dom.findUp(el.actualNode, 'label'), @@ -86,7 +86,7 @@ describe('dom.findUp', function() { fixture.innerHTML = ''; makeShadowTree(fixture.querySelector('div')); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture.firstChild)); + var tree = axe.testUtils.flatTreeSetup(fixture.firstChild); var el = axe.utils.querySelectorAll(tree, 'a')[0]; assert.equal( axe.commons.dom.findUp(el.actualNode, 'label'), @@ -104,7 +104,7 @@ describe('dom.findUp', function() { shadow.innerHTML = '
item 1
'; var listItem = shadow.querySelector('[role=listitem]'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal( axe.commons.dom.findUp(listItem, '[role=list]'), fixture.firstChild @@ -128,7 +128,7 @@ describe('dom.findUp', function() { fixture.innerHTML = ''; makeShadowTree(fixture.querySelector('div')); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture.firstChild)); + var tree = axe.testUtils.flatTreeSetup(fixture.firstChild); var el = axe.utils.querySelectorAll(tree, 'a')[0]; assert.equal( axe.commons.dom.findUp(el.actualNode, 'label'), @@ -155,7 +155,7 @@ describe('dom.findUp', function() { fixture.innerHTML = ''; makeShadowTree(fixture.querySelector('div')); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture.firstChild)); + var tree = axe.testUtils.flatTreeSetup(fixture.firstChild); var el = axe.utils.querySelectorAll(tree, 'a')[0]; var target = axe.utils.querySelectorAll(tree, '.target')[0]; assert.equal( @@ -180,7 +180,7 @@ describe('dom.findUp', function() { fixture.innerHTML = ''; makeShadowTree(fixture.querySelector('div')); - var tree = (axe._tree = axe.utils.getFlattenedTree(fixture.firstChild)); + var tree = axe.testUtils.flatTreeSetup(fixture.firstChild); var el = axe.utils.querySelectorAll(tree, 'a')[0]; assert.equal( axe.commons.dom.findUp(el.actualNode, 'label'), @@ -199,7 +199,7 @@ describe('dom.findUp', function() { shadow.innerHTML = '
item 1
'; var listItem = shadow.querySelector('[role=listitem]'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal( axe.commons.dom.findUp(listItem, '[role=list]'), fixture.firstChild diff --git a/test/commons/dom/get-tabbable-elements.js b/test/commons/dom/get-tabbable-elements.js index 27b9dfa8b4..da584767ba 100644 --- a/test/commons/dom/get-tabbable-elements.js +++ b/test/commons/dom/get-tabbable-elements.js @@ -62,7 +62,7 @@ describe('dom.getTabbableElements', function() { var shadow = node.attachShadow({ mode: 'open' }); shadow.innerHTML = ''; // re build tree after shadowDOM is constructed - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); axe._selectorData = axe.utils.getSelectorData(axe._tree); var virtualNode = axe.utils.getNodeFromTree(node); var actual = getTabbableElementsFn(virtualNode); @@ -79,7 +79,7 @@ describe('dom.getTabbableElements', function() { var shadow = node.attachShadow({ mode: 'open' }); shadow.innerHTML = ''; // re build tree after shadowDOM is constructed - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); axe._selectorData = axe.utils.getSelectorData(axe._tree); var virtualNode = axe.utils.getNodeFromTree(node); var actual = getTabbableElementsFn(virtualNode); @@ -95,7 +95,7 @@ describe('dom.getTabbableElements', function() { var shadow = node.attachShadow({ mode: 'open' }); shadow.innerHTML = '

I am not tabbable

'; // re build tree after shadowDOM is constructed - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); axe._selectorData = axe.utils.getSelectorData(axe._tree); var virtualNode = axe.utils.getNodeFromTree(node); var actual = getTabbableElementsFn(virtualNode); diff --git a/test/commons/dom/has-content-virtual.js b/test/commons/dom/has-content-virtual.js index 3016512711..43e0f3ac12 100644 --- a/test/commons/dom/has-content-virtual.js +++ b/test/commons/dom/has-content-virtual.js @@ -66,11 +66,11 @@ describe('dom.hasContentVirtual', function() { it('is called through hasContent, with a DOM node', function() { var hasContent = axe.commons.dom.hasContent; fixture.innerHTML = '
text
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isTrue(hasContent(fixture.querySelector('#target'))); fixture.innerHTML = '
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); assert.isFalse(hasContent(fixture.querySelector('#target'))); }); diff --git a/test/commons/table/get-cell-position.js b/test/commons/table/get-cell-position.js index 5d498f09d9..22ee8a4e10 100644 --- a/test/commons/table/get-cell-position.js +++ b/test/commons/table/get-cell-position.js @@ -17,7 +17,7 @@ describe('table.getCellPosition', function() { var target = document.getElementById('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.deepEqual(axe.commons.table.getCellPosition(target), { x: 1, y: 1 @@ -34,7 +34,7 @@ describe('table.getCellPosition', function() { var target = document.getElementById('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.deepEqual(axe.commons.table.getCellPosition(target), { x: 2, y: 1 @@ -51,7 +51,7 @@ describe('table.getCellPosition', function() { var target = document.getElementById('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.deepEqual(axe.commons.table.getCellPosition(target), { x: 2, y: 1 @@ -68,7 +68,7 @@ describe('table.getCellPosition', function() { var target = document.getElementById('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.deepEqual(axe.commons.table.getCellPosition(target), { x: 2, y: 1 @@ -87,7 +87,7 @@ describe('table.getCellPosition', function() { var target = document.getElementById('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.deepEqual(axe.commons.table.getCellPosition(target), { x: 1, y: 2 diff --git a/test/commons/table/get-headers.js b/test/commons/table/get-headers.js index b48b64ec9d..26829b8a57 100644 --- a/test/commons/table/get-headers.js +++ b/test/commons/table/get-headers.js @@ -20,7 +20,7 @@ describe('table.getHeaders', function() { var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.deepEqual(axe.commons.table.getHeaders(target), [ $id('t1'), $id('t2') @@ -36,7 +36,7 @@ describe('table.getHeaders', function() { var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.deepEqual(axe.commons.table.getHeaders(target), [ $id('t1'), $id('t2') @@ -53,7 +53,7 @@ describe('table.getHeaders', function() { var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.deepEqual(axe.commons.table.getHeaders(target), [ $id('t1'), $id('t2'), @@ -70,7 +70,7 @@ describe('table.getHeaders', function() { var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.deepEqual(axe.commons.table.getHeaders(target), [ $id('t1'), $id('t2'), @@ -87,7 +87,7 @@ describe('table.getHeaders', function() { var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.deepEqual(axe.commons.table.getHeaders(target), [$id('t1')]); }); @@ -100,7 +100,7 @@ describe('table.getHeaders', function() { var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.deepEqual(axe.commons.table.getHeaders(target), [ $id('t1'), $id('t2') @@ -116,7 +116,7 @@ describe('table.getHeaders', function() { var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.deepEqual(axe.commons.table.getHeaders(target), [ $id('t1'), $id('t2'), @@ -133,7 +133,7 @@ describe('table.getHeaders', function() { var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.deepEqual(axe.commons.table.getHeaders(target), []); }); }); diff --git a/test/commons/table/get-scope.js b/test/commons/table/get-scope.js index 93408f9c27..68f4153d67 100644 --- a/test/commons/table/get-scope.js +++ b/test/commons/table/get-scope.js @@ -46,7 +46,7 @@ describe('table.getScope', function() { ''; var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal(axe.commons.table.getScope(target), 'auto'); }); @@ -58,7 +58,7 @@ describe('table.getScope', function() { ''; var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal(axe.commons.table.getScope(target), 'auto'); }); @@ -70,7 +70,7 @@ describe('table.getScope', function() { ''; var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal(axe.commons.table.getScope(target), 'auto'); }); }); @@ -117,7 +117,7 @@ describe('table.getScope', function() { ''; var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal(axe.commons.table.getScope(target), 'col'); }); @@ -129,7 +129,7 @@ describe('table.getScope', function() { ''; var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal(axe.commons.table.getScope(target), 'col'); }); @@ -141,7 +141,7 @@ describe('table.getScope', function() { ' ' + ''; var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal(axe.commons.table.getScope(target), 'col'); }); @@ -152,7 +152,7 @@ describe('table.getScope', function() { ' ' + ''; var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal(axe.commons.table.getScope(target), 'col'); }); }); @@ -199,7 +199,7 @@ describe('table.getScope', function() { ''; var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal(axe.commons.table.getScope(target), 'row'); }); @@ -210,7 +210,7 @@ describe('table.getScope', function() { ' ' + ''; var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal(axe.commons.table.getScope(target), 'row'); }); @@ -222,7 +222,7 @@ describe('table.getScope', function() { ' ' + ''; var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal(axe.commons.table.getScope(target), 'row'); }); }); @@ -234,7 +234,7 @@ describe('table.getScope', function() { ' foo bar ' + ''; var target = $id('target'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.equal(axe.commons.table.getScope(target), 'auto'); }); }); diff --git a/test/commons/table/is-data-table.js b/test/commons/table/is-data-table.js index 0ce1f115f2..e2a7e6cb76 100644 --- a/test/commons/table/is-data-table.js +++ b/test/commons/table/is-data-table.js @@ -40,7 +40,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -48,7 +48,7 @@ describe('table.isDataTable', function() { fixture.innerHTML = '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -56,7 +56,7 @@ describe('table.isDataTable', function() { fixture.innerHTML = '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -64,7 +64,7 @@ describe('table.isDataTable', function() { fixture.innerHTML = '
'; var node = fixture.querySelector('[role="table"]'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -73,56 +73,56 @@ describe('table.isDataTable', function() { fixture.innerHTML = '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); it('banner', function() { fixture.innerHTML = '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); it('complementary', function() { fixture.innerHTML = '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); it('contentinfo', function() { fixture.innerHTML = '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); it('form', function() { fixture.innerHTML = '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); it('main', function() { fixture.innerHTML = '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); it('navigation', function() { fixture.innerHTML = '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); it('search', function() { fixture.innerHTML = '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); }); @@ -135,7 +135,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isFalse(axe.commons.table.isDataTable(node)); }); @@ -143,7 +143,7 @@ describe('table.isDataTable', function() { fixture.innerHTML = '' + '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -151,7 +151,7 @@ describe('table.isDataTable', function() { fixture.innerHTML = '' + '' + '
Hello
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -159,7 +159,7 @@ describe('table.isDataTable', function() { fixture.innerHTML = '' + '' + '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -167,7 +167,7 @@ describe('table.isDataTable', function() { fixture.innerHTML = '' + '' + '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -175,7 +175,7 @@ describe('table.isDataTable', function() { fixture.innerHTML = '' + '' + '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -183,7 +183,7 @@ describe('table.isDataTable', function() { fixture.innerHTML = '' + '' + '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -191,7 +191,7 @@ describe('table.isDataTable', function() { fixture.innerHTML = '' + '' + '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -200,7 +200,7 @@ describe('table.isDataTable', function() { '' + '' + '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -209,7 +209,7 @@ describe('table.isDataTable', function() { '' + '' + '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -218,7 +218,7 @@ describe('table.isDataTable', function() { '' + '' + '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -227,7 +227,7 @@ describe('table.isDataTable', function() { '' + '' + '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -236,7 +236,7 @@ describe('table.isDataTable', function() { '' + '' + '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -245,21 +245,21 @@ describe('table.isDataTable', function() { '' + '' + '
ok
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isFalse(axe.commons.table.isDataTable(node)); fixture.innerHTML = '' + '' + '
ok
'; node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isFalse(axe.commons.table.isDataTable(node)); fixture.innerHTML = '' + '' + '
ok
'; node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -270,7 +270,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('#out'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isFalse(axe.commons.table.isDataTable(node)); }); @@ -279,7 +279,7 @@ describe('table.isDataTable', function() { '' + '' + '' + '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isFalse(axe.commons.table.isDataTable(node)); }); @@ -287,7 +287,7 @@ describe('table.isDataTable', function() { fixture.innerHTML = '' + '' + '
'; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isFalse(axe.commons.table.isDataTable(node)); }); @@ -299,7 +299,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -311,7 +311,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -328,7 +328,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); @@ -348,7 +348,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); it('should be true if it has 20 or more rows', function() { @@ -358,7 +358,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); it('should be false if its width is 95% of the document width', function() { @@ -368,7 +368,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isFalse(axe.commons.table.isDataTable(node)); }); @@ -379,7 +379,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isFalse(axe.commons.table.isDataTable(node)); }); @@ -391,7 +391,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isFalse(axe.commons.table.isDataTable(node)); }); @@ -403,7 +403,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isFalse(axe.commons.table.isDataTable(node)); }); @@ -415,7 +415,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isFalse(axe.commons.table.isDataTable(node)); }); @@ -428,7 +428,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isFalse(axe.commons.table.isDataTable(node)); }); @@ -439,7 +439,7 @@ describe('table.isDataTable', function() { ''; var node = fixture.querySelector('table'); - axe._tree = axe.utils.getFlattenedTree(fixture.firstChild); + axe.testUtils.flatTreeSetup(fixture.firstChild); assert.isTrue(axe.commons.table.isDataTable(node)); }); }); diff --git a/test/commons/text/accessible-text.js b/test/commons/text/accessible-text.js index 60c5077952..18e072db83 100644 --- a/test/commons/text/accessible-text.js +++ b/test/commons/text/accessible-text.js @@ -12,7 +12,7 @@ describe('text.accessibleTextVirtual', function() { it('is called through accessibleText with a DOM node', function() { var accessibleText = axe.commons.text.accessibleText; fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('input'); assert.equal(accessibleText(target), ''); }); @@ -31,7 +31,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var rule2a = axe.utils.querySelectorAll(axe._tree, '#rule2a')[0]; var rule2c = axe.utils.querySelectorAll(axe._tree, '#rule2c')[0]; @@ -56,7 +56,7 @@ describe('text.accessibleTextVirtual', function() { ' times' + ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var rule2a = axe.utils.querySelectorAll(axe._tree, '#beep')[0]; var rule2b = axe.utils.querySelectorAll(axe._tree, '#flash')[0]; @@ -77,7 +77,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t1')[0]; assert.equal( @@ -93,7 +93,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t1')[0]; assert.equal( @@ -109,7 +109,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t1')[0]; assert.equal( @@ -121,7 +121,7 @@ describe('text.accessibleTextVirtual', function() { it('should allow setting the initial includeHidden value', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#lbl1')[0]; assert.equal( @@ -146,7 +146,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t1')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), 'ARIA Label'); @@ -160,7 +160,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#target')[0]; assert.equal( @@ -177,7 +177,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#target')[0]; assert.equal( @@ -194,7 +194,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#target')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), ''); @@ -207,7 +207,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t1')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), 'HTML Label'); @@ -220,7 +220,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t2label')[0]; assert.equal( @@ -236,7 +236,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t2label')[0]; assert.equal( @@ -254,7 +254,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t2label')[0]; // Chrome 72: This is This is a label of @@ -270,7 +270,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '
' + '
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#target')[0]; assert.equal( axe.commons.text.accessibleTextVirtual(target), @@ -283,7 +283,7 @@ describe('text.accessibleTextVirtual', function() { '
' + '
' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#target')[0]; assert.equal( axe.commons.text.accessibleTextVirtual(target), @@ -298,7 +298,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t2label')[0]; assert.equal( @@ -317,7 +317,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t2')[0]; assert.equal( @@ -333,7 +333,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t2')[0]; assert.equal( @@ -349,7 +349,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t2')[0]; // Chrome 70: "This is This is a label of everything" @@ -370,7 +370,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t2')[0]; // Chrome 70: "This is This is a label of everything" @@ -389,7 +389,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t2')[0]; // Chrome 70: "This is This is a label of everything" @@ -409,7 +409,7 @@ describe('text.accessibleTextVirtual', function() { '
This is a label
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#t2')[0]; assert.equal( @@ -427,7 +427,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#target')[0]; // Chrome 70: "" // Firefox 62: "Chosen" @@ -445,7 +445,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#target')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), ''); }); @@ -462,7 +462,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#target')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), ''); }); @@ -476,7 +476,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, '#target')[0]; // Chrome 70: "" // Firefox 62: "" @@ -486,7 +486,7 @@ describe('text.accessibleTextVirtual', function() { it('shoud properly fall back to title', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, 'a')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Hello'); @@ -494,7 +494,7 @@ describe('text.accessibleTextVirtual', function() { it('should give text even for role=presentation on anchors', function() { fixture.innerHTML = 'Hello'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, 'a')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Hello'); @@ -502,7 +502,7 @@ describe('text.accessibleTextVirtual', function() { it('should give text even for role=presentation on buttons', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, 'button')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Hello'); @@ -510,21 +510,21 @@ describe('text.accessibleTextVirtual', function() { it('should give text even for role=presentation on summary', function() { fixture.innerHTML = 'Hello'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, 'summary')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Hello'); }); it('shoud properly fall back to title', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, 'a')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Hello'); }); it('should give text even for role=none on anchors', function() { fixture.innerHTML = 'Hello'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, 'a')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Hello'); @@ -532,7 +532,7 @@ describe('text.accessibleTextVirtual', function() { it('should give text even for role=none on buttons', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, 'button')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Hello'); @@ -540,7 +540,7 @@ describe('text.accessibleTextVirtual', function() { it('should give text even for role=none on summary', function() { fixture.innerHTML = 'Hello'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, 'summary')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Hello'); @@ -548,7 +548,7 @@ describe('text.accessibleTextVirtual', function() { it('should not add extra spaces around phrasing elements', function() { fixture.innerHTML = 'HelloWorld'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, 'a')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), 'HelloWorld'); @@ -556,7 +556,7 @@ describe('text.accessibleTextVirtual', function() { it('should add spaces around non-phrasing elements', function() { fixture.innerHTML = 'Hello
World
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, 'a')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Hello World'); @@ -565,7 +565,7 @@ describe('text.accessibleTextVirtual', function() { it('should not look at scripts', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = axe.utils.querySelectorAll(axe._tree, 'a')[0]; assert.equal(axe.commons.text.accessibleTextVirtual(target), ''); @@ -573,7 +573,7 @@ describe('text.accessibleTextVirtual', function() { it('should use ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo David'); }); @@ -1518,7 +1518,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy'); }); @@ -1531,7 +1531,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy Monday'); }); @@ -1544,7 +1544,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy 4'); }); @@ -1552,7 +1552,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 12', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy'); }); @@ -1564,7 +1564,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'fancy fruit'); }); @@ -1576,14 +1576,14 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'test content'); }); it('passes test 15', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), '1'); }); @@ -1591,7 +1591,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 16', function() { fixture.innerHTML = 'a'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), '1'); }); @@ -1602,7 +1602,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), ''); }); @@ -1610,7 +1610,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 18', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), ''); }); @@ -1621,7 +1621,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), ''); }); @@ -1629,7 +1629,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 20', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), '1'); }); @@ -1640,7 +1640,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'peanuts popcorn apple jacks'); }); @@ -1649,7 +1649,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'l peanuts'); }); @@ -1659,7 +1659,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'l peanuts popcorn'); }); @@ -1670,7 +1670,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + 'a'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'l peanuts popcorn apple jacks'); }); @@ -1681,7 +1681,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 't peanuts popcorn apple jacks'); }); @@ -1690,14 +1690,14 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '
foo
' + 'bar'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'bar'); }); it('passes test 27', function() { fixture.innerHTML = '
foo
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Tag'); }); @@ -1706,7 +1706,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '
foo
' + 'bar'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'bar'); }); @@ -1716,7 +1716,7 @@ describe('text.accessibleTextVirtual', function() { '
foo
' + 'bar' + 'baz'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'bar baz'); }); @@ -1724,14 +1724,14 @@ describe('text.accessibleTextVirtual', function() { // Should only pass in strict mode it('passes test 30', function() { fixture.innerHTML = '
Div with text
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target, { strict: true }), ''); }); it('passes test 31', function() { fixture.innerHTML = '
foo
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -1740,7 +1740,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '
' + '
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Tag'); }); @@ -1749,7 +1749,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '
foo
' + 'bar'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -1757,7 +1757,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 34', function() { fixture.innerHTML = 'ABC'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Tag'); }); @@ -1766,7 +1766,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = 'foo' + '

bar

'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'bar'); }); @@ -1775,21 +1775,21 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + '

foo

'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Tag foo'); }); it('passes test 37', function() { fixture.innerHTML = 'ABC'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'ABC'); }); it('passes test 38', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Tag'); }); @@ -1800,7 +1800,7 @@ describe('text.accessibleTextVirtual', function() { '

foo

' + '

bar

' + '

baz

'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo bar baz'); }); @@ -1809,7 +1809,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + '
foo'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo bar'); }); @@ -1817,7 +1817,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 41', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -1825,7 +1825,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 42', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -1834,7 +1834,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -1842,7 +1842,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 44', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -1850,7 +1850,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 45', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -1858,7 +1858,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 46', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -1867,7 +1867,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo bar baz'); }); @@ -1876,7 +1876,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo bar baz'); }); @@ -1885,7 +1885,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo bar baz'); }); @@ -1894,7 +1894,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo bar baz'); }); @@ -1903,7 +1903,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo bar baz'); }); @@ -1917,7 +1917,7 @@ describe('text.accessibleTextVirtual', function() { '
' + ' ' + '
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo bar baz'); }); @@ -1931,7 +1931,7 @@ describe('text.accessibleTextVirtual', function() { '
' + ' ' + '
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo bar baz'); }); @@ -1945,7 +1945,7 @@ describe('text.accessibleTextVirtual', function() { '
' + ' ' + '
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo baz'); }); @@ -1959,7 +1959,7 @@ describe('text.accessibleTextVirtual', function() { '
' + ' ' + '
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo baz'); }); @@ -1973,7 +1973,7 @@ describe('text.accessibleTextVirtual', function() { '
' + ' ' + '
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo baz'); }); @@ -1987,7 +1987,7 @@ describe('text.accessibleTextVirtual', function() { '
' + ' ' + '
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo baz'); }); @@ -1996,7 +1996,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'States:'); }); @@ -2005,7 +2005,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'States:'); }); @@ -2013,7 +2013,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 60', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'States:'); }); @@ -2021,7 +2021,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 61', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'File:'); }); @@ -2030,7 +2030,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'States:'); }); @@ -2042,7 +2042,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo David'); }); @@ -2054,7 +2054,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo David'); }); @@ -2066,7 +2066,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo David'); }); @@ -2078,7 +2078,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo David'); }); @@ -2090,7 +2090,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo David'); }); @@ -2105,7 +2105,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy'); }); @@ -2120,7 +2120,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy'); }); @@ -2135,7 +2135,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy'); }); @@ -2150,7 +2150,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy'); }); @@ -2165,7 +2165,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy'); }); @@ -2178,7 +2178,7 @@ describe('text.accessibleTextVirtual', function() { '
' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy Monday'); }); @@ -2191,7 +2191,7 @@ describe('text.accessibleTextVirtual', function() { ' aria-valuemin="1" aria-valuemax="7" aria-valuenow="4">' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy Monday'); }); @@ -2204,7 +2204,7 @@ describe('text.accessibleTextVirtual', function() { ' aria-valuemin="1" aria-valuemax="7" aria-valuenow="4">' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy Monday'); }); @@ -2217,7 +2217,7 @@ describe('text.accessibleTextVirtual', function() { ' aria-valuemin="1" aria-valuemax="7" aria-valuenow="4">' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy Monday'); }); @@ -2230,7 +2230,7 @@ describe('text.accessibleTextVirtual', function() { ' aria-valuemax="7" aria-valuenow="4">' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy Monday'); }); @@ -2243,7 +2243,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy 4'); }); @@ -2256,7 +2256,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy 4'); }); @@ -2269,7 +2269,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy 4'); }); @@ -2282,7 +2282,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy 4'); }); @@ -2295,7 +2295,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy 4'); }); @@ -2303,28 +2303,28 @@ describe('text.accessibleTextVirtual', function() { it('passes test 83', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy'); }); it('passes test 84', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy'); }); it('passes test 85', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy'); }); it('passes test 86', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy'); }); @@ -2332,7 +2332,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 87', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'crazy'); }); @@ -2344,7 +2344,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'fancy fruit'); }); @@ -2356,7 +2356,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'fancy fruit'); }); @@ -2368,7 +2368,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'fancy fruit'); }); @@ -2380,7 +2380,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'fancy fruit'); }); @@ -2392,7 +2392,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'fancy fruit'); }); @@ -2404,7 +2404,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'fancy fruit'); }); @@ -2416,7 +2416,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'fancy fruit'); }); @@ -2428,7 +2428,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'fancy fruit'); }); @@ -2440,7 +2440,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'fancy fruit'); }); @@ -2452,7 +2452,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'fancy fruit'); }); @@ -2471,7 +2471,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); // Chrome 72: "Flash the screen 1 times" // Safari 12.0: "Flash the screen 1 times" @@ -2490,7 +2490,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen times.'); }); @@ -2506,7 +2506,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen 1 times.'); }); @@ -2516,7 +2516,7 @@ describe('text.accessibleTextVirtual', function() { '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo 5 baz'); }); @@ -2526,14 +2526,14 @@ describe('text.accessibleTextVirtual', function() { '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo 5 baz'); }); it('passes test 103', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -2552,7 +2552,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen 1 times.'); }); @@ -2568,7 +2568,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen times.'); }); @@ -2584,7 +2584,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen 1 times.'); }); @@ -2594,7 +2594,7 @@ describe('text.accessibleTextVirtual', function() { '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo 5 baz'); }); @@ -2604,14 +2604,14 @@ describe('text.accessibleTextVirtual', function() { '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo 5 baz'); }); it('passes test 109', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -2619,7 +2619,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 110', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -2638,7 +2638,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen 1 times.'); }); @@ -2654,7 +2654,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen times.'); }); @@ -2670,7 +2670,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen 1 times.'); }); @@ -2680,7 +2680,7 @@ describe('text.accessibleTextVirtual', function() { '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo 5 baz'); }); @@ -2690,14 +2690,14 @@ describe('text.accessibleTextVirtual', function() { '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo 5 baz'); }); it('passes test 116', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -2716,7 +2716,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen 1 times.'); }); @@ -2732,7 +2732,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen times.'); }); @@ -2748,7 +2748,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); // Chrome 72: "Flash the screen 1 times" // Firefox 62: "Flash the screen 1 times" @@ -2761,7 +2761,7 @@ describe('text.accessibleTextVirtual', function() { '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); // Chrome 70: Foo 5 baz // Firefox 62: Foo 5 baz @@ -2774,14 +2774,14 @@ describe('text.accessibleTextVirtual', function() { '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo 5 baz'); }); it('passes test 122', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -2800,7 +2800,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); // Chrome 72: "Flash the screen 1 times." // Firefox 62: "Flash the screen 1 times." @@ -2819,7 +2819,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen times.'); }); @@ -2835,7 +2835,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); // Chrome 72: Flash the screen 1 times // Firefox 62: Flash the screen 1 times @@ -2848,7 +2848,7 @@ describe('text.accessibleTextVirtual', function() { '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo 5 baz'); }); @@ -2858,14 +2858,14 @@ describe('text.accessibleTextVirtual', function() { '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo 5 baz'); }); it('passes test 128', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'foo'); }); @@ -2900,7 +2900,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); // Chrome 72: "My name is Eli the weird. (QED) Where are my marbles?" // Safari 12.0: "My name is Eli the weird. (QED) Where are my marbles?" @@ -2940,7 +2940,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal( accessibleText(target), @@ -2976,7 +2976,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal( accessibleText(target), @@ -3019,7 +3019,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' ' + ' '; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Important stuff'); }); @@ -3027,7 +3027,7 @@ describe('text.accessibleTextVirtual', function() { it('passes test 144', function() { fixture.innerHTML = ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Choose your language'); }); @@ -3037,7 +3037,7 @@ describe('text.accessibleTextVirtual', function() { '
' + ' English ' + '
'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Choose your language.'); }); @@ -3053,7 +3053,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen 1 times.'); }); @@ -3065,7 +3065,7 @@ describe('text.accessibleTextVirtual', function() { '
1
' + ' times.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen 1 times.'); }); @@ -3074,7 +3074,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'a test This is'); }); @@ -3083,7 +3083,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'This is a test'); }); @@ -3092,7 +3092,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'What is your name?'); }); @@ -3105,7 +3105,7 @@ describe('text.accessibleTextVirtual', function() { '' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'This is a test.'); }); @@ -3127,7 +3127,7 @@ describe('text.accessibleTextVirtual', function() { // ' 10' + ' 910' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), '2 4 6 8 10'); }); @@ -3148,7 +3148,7 @@ describe('text.accessibleTextVirtual', function() { '
  • 3
  • ' + ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen 2 times.'); }); @@ -3167,7 +3167,7 @@ describe('text.accessibleTextVirtual', function() { ' ' + ' ' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Flash the screen 1 times.'); }); @@ -3189,7 +3189,7 @@ describe('text.accessibleTextVirtual', function() { // ' ' + ' and don\'t you forget it.' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'My name is Eli the weird. (QED)'); }); @@ -3198,7 +3198,7 @@ describe('text.accessibleTextVirtual', function() { fixture.innerHTML = 'United States'; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'California'); }); @@ -3209,7 +3209,7 @@ describe('text.accessibleTextVirtual', function() { 'Country of origin:' + '' + ''; - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#test'); assert.equal(accessibleText(target), 'Country of origin: United States'); }); @@ -3231,7 +3231,7 @@ describe('text.accessibleTextVirtual', function() { return ` it('passes test ${index + 1}', function () { fixture.innerHTML = ${strings} - axe._tree = axe.utils.getFlattenedTree(fixture); + axe.testUtils.flatTreeSetup(fixture); var target = fixture.querySelector('#${id}'); assert.equal(accessibleText(target), '${expected}'); });` diff --git a/test/commons/text/label-virtual.js b/test/commons/text/label-virtual.js index d92ba7b69a..a704b65b04 100644 --- a/test/commons/text/label-virtual.js +++ b/test/commons/text/label-virtual.js @@ -11,7 +11,7 @@ describe('text.labelVirtual', function() { '
    monkeys
    bananas
    ' + ''; - axe._tree = axe.utils.getFlattenedTree(document.body); + axe.testUtils.flatTreeSetup(document.body); var target = fixture.querySelector('#target'); assert.equal(axe.commons.text.label(target), 'monkeys bananas'); }); @@ -22,7 +22,7 @@ describe('text.labelVirtual', function() { '
    monkeys
    bananas
    ' + ''; - var tree = (axe._tree = axe.utils.getFlattenedTree(document.body)); + var tree = axe.testUtils.flatTreeSetup(document.body); var target = axe.utils.querySelectorAll(tree, '#target')[0]; assert.equal(axe.commons.text.labelVirtual(target), 'monkeys bananas'); }); @@ -32,7 +32,7 @@ describe('text.labelVirtual', function() { '
    monkeys
    ' + ''; - var tree = (axe._tree = axe.utils.getFlattenedTree(document.body)); + var tree = axe.testUtils.flatTreeSetup(document.body); var target = axe.utils.querySelectorAll(tree, '#target')[0]; assert.equal(axe.commons.text.labelVirtual(target), 'monkeys'); }); @@ -42,7 +42,7 @@ describe('text.labelVirtual', function() { '
    monkeys
    bananas
    ' + ''; - var tree = (axe._tree = axe.utils.getFlattenedTree(document.body)); + var tree = axe.testUtils.flatTreeSetup(document.body); var target = axe.utils.querySelectorAll(tree, '#target')[0]; assert.equal(axe.commons.text.labelVirtual(target), 'monkeys bananas'); }); @@ -53,7 +53,7 @@ describe('text.labelVirtual', function() { '' + ''; - var tree = (axe._tree = axe.utils.getFlattenedTree(document.body)); + var tree = axe.testUtils.flatTreeSetup(document.body); var target = axe.utils.querySelectorAll(tree, '#target')[0]; assert.equal(axe.commons.text.labelVirtual(target), 'monkeys bananas'); }); @@ -64,7 +64,7 @@ describe('text.labelVirtual', function() { ''; - var tree = (axe._tree = axe.utils.getFlattenedTree(document.body)); + var tree = axe.testUtils.flatTreeSetup(document.body); var target = axe.utils.querySelectorAll(tree, '#target')[0]; assert.equal(axe.commons.text.labelVirtual(target), 'monkeys bananas'); }); @@ -74,7 +74,7 @@ describe('text.labelVirtual', function() { '
    \n
    ' + ''; - var tree = (axe._tree = axe.utils.getFlattenedTree(document.body)); + var tree = axe.testUtils.flatTreeSetup(document.body); var target = axe.utils.querySelectorAll(tree, '#target')[0]; assert.isNull(axe.commons.text.labelVirtual(target)); }); @@ -84,7 +84,7 @@ describe('text.labelVirtual', function() { it('should detect it', function() { fixture.innerHTML = ''; - var tree = (axe._tree = axe.utils.getFlattenedTree(document.body)); + var tree = axe.testUtils.flatTreeSetup(document.body); var target = axe.utils.querySelectorAll(tree, '#target')[0]; assert.equal(axe.commons.text.labelVirtual(target), 'monkeys'); }); @@ -92,7 +92,7 @@ describe('text.labelVirtual', function() { it('should ignore whitespace only labels', function() { fixture.innerHTML = ''; - var tree = (axe._tree = axe.utils.getFlattenedTree(document.body)); + var tree = axe.testUtils.flatTreeSetup(document.body); var target = axe.utils.querySelectorAll(tree, '#target')[0]; assert.isNull(axe.commons.text.labelVirtual(target)); }); @@ -102,7 +102,7 @@ describe('text.labelVirtual', function() { '' + ''; - var tree = (axe._tree = axe.utils.getFlattenedTree(document.body)); + var tree = axe.testUtils.flatTreeSetup(document.body); var target = axe.utils.querySelectorAll(tree, '#target')[0]; assert.equal(axe.commons.text.labelVirtual(target), 'monkeys'); }); @@ -111,7 +111,7 @@ describe('text.labelVirtual', function() { fixture.innerHTML = ''; - var tree = (axe._tree = axe.utils.getFlattenedTree(document.body)); + var tree = axe.testUtils.flatTreeSetup(document.body); var target = axe.utils.querySelectorAll(tree, '#target')[0]; assert.equal(axe.commons.text.labelVirtual(target), 'monkeys'); }); @@ -122,7 +122,7 @@ describe('text.labelVirtual', function() { fixture.innerHTML = '' + ''; - var tree = (axe._tree = axe.utils.getFlattenedTree(document.body)); + var tree = axe.testUtils.flatTreeSetup(document.body); var target = axe.utils.querySelectorAll(tree, '#target')[0]; assert.equal(axe.commons.text.labelVirtual(target), 'monkeys'); }); @@ -131,7 +131,7 @@ describe('text.labelVirtual', function() { fixture.innerHTML = '' + ''; - var tree = (axe._tree = axe.utils.getFlattenedTree(document.body)); + var tree = axe.testUtils.flatTreeSetup(document.body); var target = axe.utils.querySelectorAll(tree, '#target')[0]; assert.isNull(axe.commons.text.labelVirtual(target)); }); @@ -142,7 +142,7 @@ describe('text.labelVirtual', function() { ''; - var tree = (axe._tree = axe.utils.getFlattenedTree(document.body)); + var tree = axe.testUtils.flatTreeSetup(document.body); var target = axe.utils.querySelectorAll(tree, '#target')[0]; assert.equal(axe.commons.text.labelVirtual(target), 'monkeys'); }); @@ -152,7 +152,7 @@ describe('text.labelVirtual', function() { it('should detect it', function() { fixture.innerHTML = '