From 60a5ae6349dd92bf25a733a2c042aefa8301592d Mon Sep 17 00:00:00 2001
From: Dylan Barrell
Date: Sat, 19 Mar 2016 17:21:12 -0700
Subject: [PATCH] fix incompatibility with webpack and change all references to
utils and commons to use the axe object so that configure will be able to use
our standard rule and check definitions
---
.jshintrc | 4 +-
Gruntfile.js | 7 +-
doc/developer-guide.md | 2 +-
lib/.jshintrc | 3 +-
lib/checks/.jshintrc | 2 +-
lib/checks/aria/abstractrole.js | 2 +-
lib/checks/aria/allowed-attr-matches.js | 4 +-
lib/checks/aria/allowed-attr.js | 6 +-
lib/checks/aria/invalidrole.js | 2 +-
lib/checks/aria/required-attr.js | 2 +-
lib/checks/aria/required-children.js | 8 +-
lib/checks/aria/required-parent.js | 10 +-
lib/checks/aria/valid-attr-value.js | 2 +-
lib/checks/aria/valid-attr.js | 2 +-
lib/checks/color/color-contrast-matches.js | 8 +-
lib/checks/color/color-contrast.js | 6 +-
lib/checks/color/link-in-text-block.js | 4 +-
lib/checks/forms/fieldset.js | 20 +-
lib/checks/forms/labelledby.js | 4 +-
lib/checks/keyboard/focusable-no-name.js | 4 +-
lib/checks/label/duplicate-img-label.js | 6 +-
lib/checks/label/explicit.js | 4 +-
lib/checks/label/help-same-as-label.js | 8 +-
lib/checks/label/implicit.js | 4 +-
lib/checks/label/multiple-label.js | 2 +-
lib/checks/label/title-only.js | 2 +-
lib/checks/navigation/region.js | 10 +-
lib/checks/navigation/skip-link.js | 2 +-
lib/checks/shared/aria-label.js | 2 +-
lib/checks/shared/aria-labelledby.js | 4 +-
lib/checks/shared/doc-has-title.js | 2 +-
lib/checks/shared/duplicate-id.js | 2 +-
lib/checks/shared/has-visible-text.js | 2 +-
lib/checks/shared/non-empty-alt.js | 2 +-
lib/checks/shared/non-empty-if-present.js | 2 +-
lib/checks/shared/non-empty-title.js | 2 +-
lib/checks/shared/non-empty-value.js | 2 +-
lib/checks/tables/cell-no-header.js | 4 +-
lib/checks/tables/consistent-columns.js | 2 +-
lib/checks/tables/headers-attr-reference.js | 4 +-
lib/checks/tables/headers-visible-text.js | 2 +-
lib/checks/tables/html4-scope.js | 2 +-
lib/checks/tables/html5-scope.js | 2 +-
lib/checks/tables/same-caption-summary.js | 2 +-
lib/checks/tables/th-single-row-column.js | 6 +-
lib/commons/aria/attributes.js | 6 +-
lib/commons/aria/roles.js | 10 +-
lib/commons/dom/find-up.js | 4 +-
lib/commons/dom/idrefs.js | 4 +-
lib/commons/table/is-header.js | 4 +-
lib/commons/text/accessible-text.js | 4 +-
lib/commons/text/label.js | 4 +-
lib/commons/utils/index.js | 5 +-
lib/commons/utils/to-array.js | 4 +-
lib/commons/utils/token-list.js | 5 +-
lib/core/base/audit.js | 6 +-
lib/core/base/check.js | 32 ++-
lib/core/base/context.js | 10 +-
lib/core/base/rule.js | 28 ++-
lib/core/public/cleanup-plugins.js | 6 +-
lib/core/public/load.js | 4 +-
lib/core/public/plugins.js | 2 +-
lib/core/public/run-rules.js | 8 +-
lib/core/reporters/helpers/split-results.js | 2 +-
lib/core/utils/check-helper.js | 6 +-
lib/core/utils/clone.js | 6 +-
lib/core/utils/collect-results-from-frames.js | 24 +--
lib/core/utils/contains.js | 2 +-
lib/core/utils/dq-element.js | 4 +-
lib/core/utils/element-matches.js | 2 +-
lib/core/utils/escape-selector.js | 2 +-
lib/core/utils/extend-blacklist.js | 2 +-
lib/core/utils/extend-meta-data.js | 2 +-
lib/core/utils/finalize-result.js | 14 +-
lib/core/utils/find-by.js | 2 +-
lib/core/utils/get-all-checks.js | 2 +-
lib/core/utils/get-check-option.js | 2 +-
lib/core/utils/get-selector.js | 12 +-
lib/core/utils/inject-style.js | 4 +-
lib/core/utils/is-hidden.js | 4 +-
lib/core/utils/merge-results.js | 12 +-
lib/core/utils/node-sorter.js | 2 +-
lib/core/utils/publish-metadata.js | 12 +-
lib/core/utils/queue.js | 2 +-
lib/core/utils/respondable.js | 2 +-
lib/core/utils/rule-should-run.js | 2 +-
lib/core/utils/select.js | 14 +-
lib/core/utils/to-array.js | 2 +-
lib/outro.stub | 2 +-
lib/rules/.jshintrc | 2 +-
lib/rules/data-table-matches.js | 2 +-
lib/rules/layout-table-matches.js | 2 +-
lib/rules/link-in-text-block-matches.js | 4 +-
test/.jshintrc | 3 +-
test/checks/.jshintrc | 2 +-
test/checks/aria/allowed-attr.js | 20 +-
test/checks/aria/required-attr.js | 8 +-
test/checks/aria/valid-attr-value.js | 8 +-
test/checks/aria/valid-attr.js | 8 +-
test/checks/color/color-contrast.js | 4 +-
test/checks/color/link-in-text-block.js | 12 +-
test/checks/tables/html4-scope.js | 6 +-
test/checks/tables/html5-scope.js | 6 +-
test/commons/.jshintrc | 2 +-
test/commons/aria/attributes.js | 150 +++++++-------
test/commons/aria/label.js | 12 +-
test/commons/aria/roles.js | 86 ++++----
test/commons/color/contrast.js | 98 ++++-----
test/commons/color/element-is-distinct.js | 2 +-
test/commons/color/get-background-color.js | 68 +++----
test/commons/color/get-foreground-color.js | 14 +-
test/commons/dom/elements-from-point.js | 16 +-
test/commons/dom/find-up.js | 6 +-
test/commons/dom/get-element-by-reference.js | 12 +-
test/commons/dom/get-element-coordinates.js | 10 +-
test/commons/dom/get-scroll-offset.js | 8 +-
test/commons/dom/get-viewport-size.js | 8 +-
test/commons/dom/idrefs.js | 6 +-
test/commons/dom/is-focusable.js | 28 +--
test/commons/dom/is-html5.js | 6 +-
test/commons/dom/is-node.js | 28 +--
test/commons/dom/is-offscreen.js | 22 +-
test/commons/dom/is-visible.js | 72 +++----
test/commons/dom/is-visual-content.js | 34 ++--
test/commons/dom/visually-contains.js | 10 +-
test/commons/dom/visually-overlaps.js | 10 +-
test/commons/index.js | 4 +-
test/commons/table/get-cell-position.js | 10 +-
test/commons/table/get-headers.js | 16 +-
test/commons/table/is-column-header.js | 12 +-
test/commons/table/is-data-cell.js | 6 +-
test/commons/table/is-data-table.js | 86 ++++----
test/commons/table/is-header.js | 46 ++---
test/commons/table/is-row-header.js | 12 +-
test/commons/table/to-array.js | 10 +-
test/commons/text/accessible-text.js | 190 +++++++++---------
test/commons/text/label.js | 30 +--
test/commons/text/sanitize.js | 10 +-
test/commons/text/visible.js | 32 +--
test/commons/utils/index.js | 6 +-
test/commons/utils/to-array.js | 4 +-
test/commons/utils/token-list.js | 6 +-
test/core/base/audit.js | 4 +-
test/core/base/check.js | 9 +-
test/core/base/context.js | 18 +-
test/core/public/cleanup-plugins.js | 6 +-
test/core/public/load.js | 16 +-
test/core/utils/check-helper.js | 28 +--
.../core/utils/collect-results-from-frames.js | 8 +-
test/core/utils/contains.js | 12 +-
test/core/utils/dq-element.js | 10 +-
test/core/utils/extend-meta-data.js | 8 +-
test/core/utils/finalize-result.js | 18 +-
test/core/utils/find-by.js | 8 +-
test/core/utils/get-all-checks.js | 12 +-
test/core/utils/get-check-option.js | 10 +-
test/core/utils/get-selector.js | 34 ++--
test/core/utils/is-hidden.js | 16 +-
test/core/utils/merge-results.js | 4 +-
test/core/utils/node-sorter.js | 14 +-
test/core/utils/publish-metadata.js | 14 +-
test/core/utils/queue.js | 50 ++---
test/core/utils/respondable.js | 58 +++---
test/core/utils/rule-should-run.js | 42 ++--
test/core/utils/select.js | 20 +-
test/core/utils/send-command-to-frame.js | 10 +-
test/core/utils/to-array.js | 6 +-
167 files changed, 1087 insertions(+), 1095 deletions(-)
diff --git a/.jshintrc b/.jshintrc
index 5832986125..7f06dc0fe4 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -1,5 +1,7 @@
{
- "globals": {},
+ "globals": {
+ "axe": true
+ },
"browser" : false,
"node" : true,
diff --git a/Gruntfile.js b/Gruntfile.js
index 887129a4f8..35f0770e3c 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -32,8 +32,8 @@ module.exports = function (grunt) {
'lib/core/*/index.js',
'lib/core/**/index.js',
'lib/core/**/*.js',
- '<%= configure.rules.dest.auto %>',
'lib/core/export.js',
+ '<%= configure.rules.dest.auto %>',
'lib/outro.stub'
],
dest: 'axe.js',
@@ -114,7 +114,10 @@ module.exports = function (grunt) {
dest: 'axe.min.js'
}],
options: {
- preserveComments: 'some'
+ preserveComments: 'some',
+ mangle: {
+ except: ['commons', 'utils', 'axe']
+ }
}
}
},
diff --git a/doc/developer-guide.md b/doc/developer-guide.md
index 8b4d17d63b..4882481bbf 100644
--- a/doc/developer-guide.md
+++ b/doc/developer-guide.md
@@ -156,7 +156,7 @@ The DqElement is a "serialized" `HTMLElement`. It will calculate the CSS selecto
```javascript
var firstH1 = document.getElementByTagName('h1')[0];
-var dqH1 = new utils.DqElement(firstH1);
+var dqH1 = new axe.utils.DqElement(firstH1);
```
Elements returned by the DqElement class have the following methods and properties:
diff --git a/lib/.jshintrc b/lib/.jshintrc
index 9cb60fb7bd..7cf387a9a1 100644
--- a/lib/.jshintrc
+++ b/lib/.jshintrc
@@ -1,7 +1,6 @@
{
"globals": {
- "axe": true,
- "utils": true
+ "axe": true
},
"browser" : true,
diff --git a/lib/checks/.jshintrc b/lib/checks/.jshintrc
index 6232230ef8..8d6b6f53a3 100644
--- a/lib/checks/.jshintrc
+++ b/lib/checks/.jshintrc
@@ -3,7 +3,7 @@
"results": true,
"node": true,
"options": true,
- "commons": true,
+ "axe": true,
"document": true,
"window": true
},
diff --git a/lib/checks/aria/abstractrole.js b/lib/checks/aria/abstractrole.js
index 2bf0cfd560..e59b744034 100644
--- a/lib/checks/aria/abstractrole.js
+++ b/lib/checks/aria/abstractrole.js
@@ -1 +1 @@
-return commons.aria.getRoleType(node.getAttribute('role')) === 'abstract';
+return axe.commons.aria.getRoleType(node.getAttribute('role')) === 'abstract';
diff --git a/lib/checks/aria/allowed-attr-matches.js b/lib/checks/aria/allowed-attr-matches.js
index d8ed8d759e..6045df0f7d 100644
--- a/lib/checks/aria/allowed-attr-matches.js
+++ b/lib/checks/aria/allowed-attr-matches.js
@@ -1,9 +1,9 @@
var role = node.getAttribute('role');
if (!role) {
- role = commons.aria.implicitRole(node);
+ role = axe.commons.aria.implicitRole(node);
}
-var allowed = commons.aria.allowedAttr(role);
+var allowed = axe.commons.aria.allowedAttr(role);
if (role && allowed) {
var aria = /^aria-/;
if (node.hasAttributes()) {
diff --git a/lib/checks/aria/allowed-attr.js b/lib/checks/aria/allowed-attr.js
index bfa9a63331..3a9f614610 100644
--- a/lib/checks/aria/allowed-attr.js
+++ b/lib/checks/aria/allowed-attr.js
@@ -5,14 +5,14 @@ var attr, attrName, allowed,
attrs = node.attributes;
if (!role) {
- role = commons.aria.implicitRole(node);
+ role = axe.commons.aria.implicitRole(node);
}
-allowed = commons.aria.allowedAttr(role);
+allowed = axe.commons.aria.allowedAttr(role);
if (role && allowed) {
for (var i = 0, l = attrs.length; i < l; i++) {
attr = attrs[i];
attrName = attr.name;
- if (commons.aria.validateAttr(attrName) && allowed.indexOf(attrName) === -1) {
+ if (axe.commons.aria.validateAttr(attrName) && allowed.indexOf(attrName) === -1) {
invalid.push(attrName + '="' + attr.nodeValue + '"');
}
}
diff --git a/lib/checks/aria/invalidrole.js b/lib/checks/aria/invalidrole.js
index 0040ff5e0d..65b8243e51 100644
--- a/lib/checks/aria/invalidrole.js
+++ b/lib/checks/aria/invalidrole.js
@@ -1,3 +1,3 @@
-return !commons.aria.isValidRole(node.getAttribute('role'));
+return !axe.commons.aria.isValidRole(node.getAttribute('role'));
diff --git a/lib/checks/aria/required-attr.js b/lib/checks/aria/required-attr.js
index b9fd7a4e05..23bfe0a3df 100644
--- a/lib/checks/aria/required-attr.js
+++ b/lib/checks/aria/required-attr.js
@@ -3,7 +3,7 @@ var missing = [];
if (node.hasAttributes()) {
var attr,
role = node.getAttribute('role'),
- required = commons.aria.requiredAttr(role);
+ required = axe.commons.aria.requiredAttr(role);
if (role && required) {
for (var i = 0, l = required.length; i < l; i++) {
diff --git a/lib/checks/aria/required-children.js b/lib/checks/aria/required-children.js
index 674be0dd1d..6d61ef5db5 100644
--- a/lib/checks/aria/required-children.js
+++ b/lib/checks/aria/required-children.js
@@ -1,7 +1,7 @@
-var requiredOwned = commons.aria.requiredOwned,
-implicitNodes = commons.aria.implicitNodes,
-matchesSelector = commons.utils.matchesSelector,
-idrefs = commons.dom.idrefs;
+var requiredOwned = axe.commons.aria.requiredOwned,
+implicitNodes = axe.commons.aria.implicitNodes,
+matchesSelector = axe.commons.utils.matchesSelector,
+idrefs = axe.commons.dom.idrefs;
function owns(node, role, ariaOwned) {
if (node === null) { return false; }
diff --git a/lib/checks/aria/required-parent.js b/lib/checks/aria/required-parent.js
index ead14a9d1d..87235a548f 100644
--- a/lib/checks/aria/required-parent.js
+++ b/lib/checks/aria/required-parent.js
@@ -1,5 +1,5 @@
function getSelector(role) {
- var impliedNative = commons.aria.implicitNodes(role) || [];
+ var impliedNative = axe.commons.aria.implicitNodes(role) || [];
return impliedNative.concat('[role="' + role + '"]').join(',');
}
@@ -9,16 +9,16 @@ function getMissingContext(element, requiredContext, includeElement) {
missing = [];
if (!requiredContext) {
- requiredContext = commons.aria.requiredContext(role);
+ requiredContext = axe.commons.aria.requiredContext(role);
}
if (!requiredContext) { return null; }
for (index = 0, length = requiredContext.length; index < length; index++) {
- if (includeElement && commons.utils.matchesSelector(element, getSelector(requiredContext[index]))) {
+ if (includeElement && axe.utils.matchesSelector(element, getSelector(requiredContext[index]))) {
return null;
}
- if (commons.dom.findUp(element, getSelector(requiredContext[index]))) {
+ if (axe.commons.dom.findUp(element, getSelector(requiredContext[index]))) {
//if one matches, it passes
return null;
} else {
@@ -35,7 +35,7 @@ function getAriaOwners(element) {
while (element) {
if (element.id) {
- o = document.querySelector('[aria-owns~=' + commons.utils.escapeSelector(element.id) + ']');
+ o = document.querySelector('[aria-owns~=' + axe.commons.utils.escapeSelector(element.id) + ']');
if (o) { owners.push(o); }
}
element = element.parentNode;
diff --git a/lib/checks/aria/valid-attr-value.js b/lib/checks/aria/valid-attr-value.js
index f040c46323..02ffad9ac0 100644
--- a/lib/checks/aria/valid-attr-value.js
+++ b/lib/checks/aria/valid-attr-value.js
@@ -10,7 +10,7 @@ for (var i = 0, l = attrs.length; i < l; i++) {
attr = attrs[i];
attrName = attr.name;
if (options.indexOf(attrName) === -1 && aria.test(attrName) &&
- !commons.aria.validateAttrValue(node, attrName)) {
+ !axe.commons.aria.validateAttrValue(node, attrName)) {
invalid.push(attrName + '="' + attr.nodeValue + '"');
}
diff --git a/lib/checks/aria/valid-attr.js b/lib/checks/aria/valid-attr.js
index a6f6fbebd4..998beb6dd7 100644
--- a/lib/checks/aria/valid-attr.js
+++ b/lib/checks/aria/valid-attr.js
@@ -8,7 +8,7 @@ var attr,
for (var i = 0, l = attrs.length; i < l; i++) {
attr = attrs[i].name;
- if (options.indexOf(attr) === -1 && aria.test(attr) && !commons.aria.validateAttr(attr)) {
+ if (options.indexOf(attr) === -1 && aria.test(attr) && !axe.commons.aria.validateAttr(attr)) {
invalid.push(attr);
}
}
diff --git a/lib/checks/color/color-contrast-matches.js b/lib/checks/color/color-contrast-matches.js
index c796edc253..9748e200e4 100644
--- a/lib/checks/color/color-contrast-matches.js
+++ b/lib/checks/color/color-contrast-matches.js
@@ -44,13 +44,13 @@ if (nodeName === 'LABEL') {
// label of disabled control associated w/ aria-labelledby
if (node.id) {
- var candidate = doc.querySelector('[aria-labelledby~=' + commons.utils.escapeSelector(node.id) + ']');
+ var candidate = doc.querySelector('[aria-labelledby~=' + axe.commons.utils.escapeSelector(node.id) + ']');
if (candidate && candidate.disabled) {
return false;
}
}
-if (commons.text.visible(node, false, true) === '') {
+if (axe.commons.text.visible(node, false, true) === '') {
return false;
}
@@ -62,7 +62,7 @@ var range = document.createRange(),
for (index = 0; index < length; index++) {
child = childNodes[index];
- if (child.nodeType === 3 && commons.text.sanitize(child.nodeValue) !== '') {
+ if (child.nodeType === 3 && axe.commons.text.sanitize(child.nodeValue) !== '') {
range.selectNodeContents(child);
}
}
@@ -72,7 +72,7 @@ length = rects.length;
for (index = 0; index < length; index++) {
//check to see if the rectangle impinges
- if (commons.dom.visuallyOverlaps(rects[index], node)) {
+ if (axe.commons.dom.visuallyOverlaps(rects[index], node)) {
return true;
}
}
diff --git a/lib/checks/color/color-contrast.js b/lib/checks/color/color-contrast.js
index c311bb577e..78158a7c3e 100644
--- a/lib/checks/color/color-contrast.js
+++ b/lib/checks/color/color-contrast.js
@@ -1,7 +1,7 @@
var noScroll = !!(options || {}).noScroll;
var bgNodes = [],
- bgColor = commons.color.getBackgroundColor(node, bgNodes, noScroll),
- fgColor = commons.color.getForegroundColor(node, noScroll);
+ bgColor = axe.commons.color.getBackgroundColor(node, bgNodes, noScroll),
+ fgColor = axe.commons.color.getForegroundColor(node, noScroll);
//We don't know, so we'll pass it provisionally
if (fgColor === null || bgColor === null) {
@@ -13,7 +13,7 @@ var fontSize = parseFloat(nodeStyle.getPropertyValue('font-size'));
var fontWeight = nodeStyle.getPropertyValue('font-weight');
var bold = (['bold', 'bolder', '600', '700', '800', '900'].indexOf(fontWeight) !== -1);
-var cr = commons.color.hasValidContrastRatio(bgColor, fgColor, fontSize, bold);
+var cr = axe.commons.color.hasValidContrastRatio(bgColor, fgColor, fontSize, bold);
this.data({
fgColor: fgColor.toHexString(),
diff --git a/lib/checks/color/link-in-text-block.js b/lib/checks/color/link-in-text-block.js
index ae6750410d..90c84be792 100644
--- a/lib/checks/color/link-in-text-block.js
+++ b/lib/checks/color/link-in-text-block.js
@@ -1,5 +1,5 @@
-/* global commons*/
-var color = commons.color;
+/* global axe*/
+var color = axe.commons.color;
function getContrast(color1, color2) {
var c1lum = color1.getRelativeLuminance();
diff --git a/lib/checks/forms/fieldset.js b/lib/checks/forms/fieldset.js
index 708cd3e66c..8800412c91 100644
--- a/lib/checks/forms/fieldset.js
+++ b/lib/checks/forms/fieldset.js
@@ -3,7 +3,7 @@ var failureCode,
function getUnrelatedElements(parent, name) {
- return commons.utils.toArray(parent.querySelectorAll('select,textarea,button,input:not([name="' + name +
+ return axe.commons.utils.toArray(parent.querySelectorAll('select,textarea,button,input:not([name="' + name +
'"]):not([type="hidden"])'));
}
@@ -15,7 +15,7 @@ function checkFieldset(group, name) {
failureCode = 'no-legend';
return false;
}
- if (!commons.text.accessibleText(firstNode)) {
+ if (!axe.commons.text.accessibleText(firstNode)) {
self.relatedNodes([firstNode]);
failureCode = 'empty-legend';
return false;
@@ -31,11 +31,11 @@ function checkFieldset(group, name) {
function checkARIAGroup(group, name) {
- var hasLabelledByText = commons.dom.idrefs(group, 'aria-labelledby').some(function (element) {
- return element && commons.text.accessibleText(element);
+ var hasLabelledByText = axe.commons.dom.idrefs(group, 'aria-labelledby').some(function (element) {
+ return element && axe.commons.text.accessibleText(element);
});
var ariaLabel = group.getAttribute('aria-label');
- if (!hasLabelledByText && !(ariaLabel && commons.text.sanitize(ariaLabel))) {
+ if (!hasLabelledByText && !(ariaLabel && axe.commons.text.sanitize(ariaLabel))) {
self.relatedNodes(group);
failureCode = 'no-group-label';
return false;
@@ -51,20 +51,20 @@ function checkARIAGroup(group, name) {
}
function spliceCurrentNode(nodes, current) {
- return commons.utils.toArray(nodes).filter(function (candidate) {
+ return axe.commons.utils.toArray(nodes).filter(function (candidate) {
return candidate !== current;
});
}
function runCheck(element) {
- var name = commons.utils.escapeSelector(node.name);
+ var name = axe.commons.utils.escapeSelector(node.name);
var matchingNodes = document.querySelectorAll('input[type="' +
- commons.utils.escapeSelector(node.type) + '"][name="' + name + '"]');
+ axe.commons.utils.escapeSelector(node.type) + '"][name="' + name + '"]');
if (matchingNodes.length < 2) {
return true;
}
- var fieldset = commons.dom.findUp(element, 'fieldset');
- var group = commons.dom.findUp(element, '[role="group"]' + (node.type === 'radio' ? ',[role="radiogroup"]' : ''));
+ var fieldset = axe.commons.dom.findUp(element, 'fieldset');
+ var group = axe.commons.dom.findUp(element, '[role="group"]' + (node.type === 'radio' ? ',[role="radiogroup"]' : ''));
if (!group && !fieldset) {
failureCode = 'no-group';
self.relatedNodes(spliceCurrentNode(matchingNodes, element));
diff --git a/lib/checks/forms/labelledby.js b/lib/checks/forms/labelledby.js
index 5d2984993e..a06ddd7ac4 100644
--- a/lib/checks/forms/labelledby.js
+++ b/lib/checks/forms/labelledby.js
@@ -4,7 +4,7 @@ this.data({
});
var matchingNodes = document.querySelectorAll('input[type="' +
- commons.utils.escapeSelector(node.type) + '"][name="' + commons.utils.escapeSelector(node.name) + '"]');
+ axe.commons.utils.escapeSelector(node.type) + '"][name="' + axe.commons.utils.escapeSelector(node.name) + '"]');
if (matchingNodes.length <= 1) {
return true;
}
@@ -19,5 +19,5 @@ return [].map.call(matchingNodes, function (m) {
});
}).filter(function (n) {
var labelNode = document.getElementById(n);
- return labelNode && commons.text.accessibleText(labelNode);
+ return labelNode && axe.commons.text.accessibleText(labelNode);
}).length !== 0;
diff --git a/lib/checks/keyboard/focusable-no-name.js b/lib/checks/keyboard/focusable-no-name.js
index 232ca15ce8..9e7d5e0358 100644
--- a/lib/checks/keyboard/focusable-no-name.js
+++ b/lib/checks/keyboard/focusable-no-name.js
@@ -1,6 +1,6 @@
var tabIndex = node.getAttribute('tabindex'),
- isFocusable = commons.dom.isFocusable(node) && tabIndex > -1;
+ isFocusable = axe.commons.dom.isFocusable(node) && tabIndex > -1;
if (!isFocusable) {
return false;
}
-return !commons.text.accessibleText(node);
+return !axe.commons.text.accessibleText(node);
diff --git a/lib/checks/label/duplicate-img-label.js b/lib/checks/label/duplicate-img-label.js
index 9af5214e73..7e1062553e 100644
--- a/lib/checks/label/duplicate-img-label.js
+++ b/lib/checks/label/duplicate-img-label.js
@@ -1,5 +1,5 @@
var imgs = node.querySelectorAll('img');
-var text = commons.text.visible(node, true).toLowerCase();
+var text = axe.commons.text.visible(node, true).toLowerCase();
if (text === '') {
return false;
@@ -7,10 +7,10 @@ if (text === '') {
for (var i = 0, len = imgs.length; i < len; i++) {
var img = imgs[i];
- var imgAlt = commons.text.accessibleText(img).toLowerCase();
+ var imgAlt = axe.commons.text.accessibleText(img).toLowerCase();
if (imgAlt === text &&
img.getAttribute('role') !== 'presentation' &&
- commons.dom.isVisible(img)) {
+ axe.commons.dom.isVisible(img)) {
return true;
}
}
diff --git a/lib/checks/label/explicit.js b/lib/checks/label/explicit.js
index 13cc45eb45..05070c7629 100644
--- a/lib/checks/label/explicit.js
+++ b/lib/checks/label/explicit.js
@@ -1,6 +1,6 @@
-var label = document.querySelector('label[for="' + commons.utils.escapeSelector(node.id) + '"]');
+var label = document.querySelector('label[for="' + axe.commons.utils.escapeSelector(node.id) + '"]');
if (label) {
- return !!commons.text.accessibleText(label);
+ return !!axe.commons.text.accessibleText(label);
}
return false;
diff --git a/lib/checks/label/help-same-as-label.js b/lib/checks/label/help-same-as-label.js
index 0b12586d65..4933e977b6 100644
--- a/lib/checks/label/help-same-as-label.js
+++ b/lib/checks/label/help-same-as-label.js
@@ -1,5 +1,5 @@
-var labelText = commons.text.label(node),
+var labelText = axe.commons.text.label(node),
check = node.getAttribute('title');
if (!labelText) {
@@ -10,11 +10,11 @@ if (!check) {
check = '';
if (node.getAttribute('aria-describedby')) {
- var ref = commons.dom.idrefs(node, 'aria-describedby');
+ var ref = axe.commons.dom.idrefs(node, 'aria-describedby');
check = ref.map(function (thing) {
- return thing ? commons.text.accessibleText(thing) : '';
+ return thing ? axe.commons.text.accessibleText(thing) : '';
}).join('');
}
}
-return commons.text.sanitize(check) === commons.text.sanitize(labelText);
+return axe.commons.text.sanitize(check) === axe.commons.text.sanitize(labelText);
diff --git a/lib/checks/label/implicit.js b/lib/checks/label/implicit.js
index 9979a6ac1b..f5df7ccf2b 100644
--- a/lib/checks/label/implicit.js
+++ b/lib/checks/label/implicit.js
@@ -1,6 +1,6 @@
-var label = commons.dom.findUp(node, 'label');
+var label = axe.commons.dom.findUp(node, 'label');
if (label) {
- return !!commons.text.accessibleText(label);
+ return !!axe.commons.text.accessibleText(label);
}
return false;
diff --git a/lib/checks/label/multiple-label.js b/lib/checks/label/multiple-label.js
index 24a70f20bd..bc240acb0f 100644
--- a/lib/checks/label/multiple-label.js
+++ b/lib/checks/label/multiple-label.js
@@ -1,5 +1,5 @@
var labels = [].slice.call(document.querySelectorAll('label[for="' +
- commons.utils.escapeSelector(node.id) + '"]')),
+ axe.commons.utils.escapeSelector(node.id) + '"]')),
parent = node.parentNode;
while (parent) {
diff --git a/lib/checks/label/title-only.js b/lib/checks/label/title-only.js
index 1dfa2af42e..64251d46fd 100644
--- a/lib/checks/label/title-only.js
+++ b/lib/checks/label/title-only.js
@@ -1,2 +1,2 @@
-var labelText = commons.text.label(node);
+var labelText = axe.commons.text.label(node);
return !labelText && !!(node.getAttribute('title') || node.getAttribute('aria-describedby'));
\ No newline at end of file
diff --git a/lib/checks/navigation/region.js b/lib/checks/navigation/region.js
index a8c9d250b7..4443bf535a 100644
--- a/lib/checks/navigation/region.js
+++ b/lib/checks/navigation/region.js
@@ -1,11 +1,11 @@
//jshint latedef: false
-var landmarkRoles = commons.aria.getRolesByType('landmark'),
+var landmarkRoles = axe.commons.aria.getRolesByType('landmark'),
firstLink = node.querySelector('a[href]');
function isSkipLink(n) {
return firstLink &&
- commons.dom.isFocusable(commons.dom.getElementByReference(firstLink, 'href')) &&
+ axe.commons.dom.isFocusable(axe.commons.dom.getElementByReference(firstLink, 'href')) &&
firstLink === n;
}
@@ -17,12 +17,12 @@ function isLandmark(n) {
function checkRegion(n) {
if (isLandmark(n)) { return null; }
if (isSkipLink(n)) { return getViolatingChildren(n); }
- if (commons.dom.isVisible(n, true) &&
- (commons.text.visible(n, true, true) || commons.dom.isVisualContent(n))) { return n; }
+ if (axe.commons.dom.isVisible(n, true) &&
+ (axe.commons.text.visible(n, true, true) || axe.commons.dom.isVisualContent(n))) { return n; }
return getViolatingChildren(n);
}
function getViolatingChildren(n) {
- var children = commons.utils.toArray(n.children);
+ var children = axe.commons.utils.toArray(n.children);
if (children.length === 0) { return []; }
return children.map(checkRegion)
.filter(function (c) { return c !== null; })
diff --git a/lib/checks/navigation/skip-link.js b/lib/checks/navigation/skip-link.js
index 6de212abf5..92eb8cf509 100644
--- a/lib/checks/navigation/skip-link.js
+++ b/lib/checks/navigation/skip-link.js
@@ -1 +1 @@
-return commons.dom.isFocusable(commons.dom.getElementByReference(node, 'href'));
+return axe.commons.dom.isFocusable(axe.commons.dom.getElementByReference(node, 'href'));
diff --git a/lib/checks/shared/aria-label.js b/lib/checks/shared/aria-label.js
index 63f5f57aa4..a37f364dcd 100644
--- a/lib/checks/shared/aria-label.js
+++ b/lib/checks/shared/aria-label.js
@@ -1,2 +1,2 @@
var label = node.getAttribute('aria-label');
-return !!(label ? commons.text.sanitize(label).trim() : '');
\ No newline at end of file
+return !!(label ? axe.commons.text.sanitize(label).trim() : '');
\ No newline at end of file
diff --git a/lib/checks/shared/aria-labelledby.js b/lib/checks/shared/aria-labelledby.js
index bd3bd48016..91b10c384d 100644
--- a/lib/checks/shared/aria-labelledby.js
+++ b/lib/checks/shared/aria-labelledby.js
@@ -1,9 +1,9 @@
-var results = commons.dom.idrefs(node, 'aria-labelledby');
+var results = axe.commons.dom.idrefs(node, 'aria-labelledby');
var element, i, l = results.length;
for (i = 0; i < l; i++) {
element = results[i];
- if (element && commons.text.accessibleText(element, true)) {
+ if (element && axe.commons.text.accessibleText(element, true)) {
return true;
}
}
diff --git a/lib/checks/shared/doc-has-title.js b/lib/checks/shared/doc-has-title.js
index 9ca64bc1b7..8942f483d1 100644
--- a/lib/checks/shared/doc-has-title.js
+++ b/lib/checks/shared/doc-has-title.js
@@ -1,2 +1,2 @@
var title = document.title;
-return !!(title ? commons.text.sanitize(title).trim() : '');
\ No newline at end of file
+return !!(title ? axe.commons.text.sanitize(title).trim() : '');
\ No newline at end of file
diff --git a/lib/checks/shared/duplicate-id.js b/lib/checks/shared/duplicate-id.js
index 87ec0323ba..1d53a480a0 100644
--- a/lib/checks/shared/duplicate-id.js
+++ b/lib/checks/shared/duplicate-id.js
@@ -4,7 +4,7 @@ if (!node.id.trim()) {
return true;
}
-var matchingNodes = document.querySelectorAll('[id="' + commons.utils.escapeSelector(node.id) + '"]');
+var matchingNodes = document.querySelectorAll('[id="' + axe.commons.utils.escapeSelector(node.id) + '"]');
var related = [];
for (var i = 0; i < matchingNodes.length; i++) {
if (matchingNodes[i] !== node) {
diff --git a/lib/checks/shared/has-visible-text.js b/lib/checks/shared/has-visible-text.js
index 93ee837577..0c63a06d61 100644
--- a/lib/checks/shared/has-visible-text.js
+++ b/lib/checks/shared/has-visible-text.js
@@ -1 +1 @@
-return commons.text.accessibleText(node).length > 0;
+return axe.commons.text.accessibleText(node).length > 0;
diff --git a/lib/checks/shared/non-empty-alt.js b/lib/checks/shared/non-empty-alt.js
index 4cdadbd4ef..4426fff559 100644
--- a/lib/checks/shared/non-empty-alt.js
+++ b/lib/checks/shared/non-empty-alt.js
@@ -1,2 +1,2 @@
var label = node.getAttribute('alt');
-return !!(label ? commons.text.sanitize(label).trim() : '');
\ No newline at end of file
+return !!(label ? axe.commons.text.sanitize(label).trim() : '');
\ No newline at end of file
diff --git a/lib/checks/shared/non-empty-if-present.js b/lib/checks/shared/non-empty-if-present.js
index 420a66d777..a2a40e5aca 100644
--- a/lib/checks/shared/non-empty-if-present.js
+++ b/lib/checks/shared/non-empty-if-present.js
@@ -1,3 +1,3 @@
var label = node.getAttribute('value');
this.data(label);
-return label === null || commons.text.sanitize(label).trim() !== '';
+return label === null || axe.commons.text.sanitize(label).trim() !== '';
diff --git a/lib/checks/shared/non-empty-title.js b/lib/checks/shared/non-empty-title.js
index 26a2d16160..e870089260 100644
--- a/lib/checks/shared/non-empty-title.js
+++ b/lib/checks/shared/non-empty-title.js
@@ -1,2 +1,2 @@
var title = node.getAttribute('title');
-return !!(title ? commons.text.sanitize(title).trim() : '');
+return !!(title ? axe.commons.text.sanitize(title).trim() : '');
diff --git a/lib/checks/shared/non-empty-value.js b/lib/checks/shared/non-empty-value.js
index 4ecc73f5cd..68b325b520 100644
--- a/lib/checks/shared/non-empty-value.js
+++ b/lib/checks/shared/non-empty-value.js
@@ -1,2 +1,2 @@
var label = node.getAttribute('value');
-return !!(label ? commons.text.sanitize(label).trim() : '');
+return !!(label ? axe.commons.text.sanitize(label).trim() : '');
diff --git a/lib/checks/tables/cell-no-header.js b/lib/checks/tables/cell-no-header.js
index a0773a254a..dd1ac29100 100644
--- a/lib/checks/tables/cell-no-header.js
+++ b/lib/checks/tables/cell-no-header.js
@@ -7,7 +7,9 @@ for (var rowIndex = 0, rowLength = node.rows.length; rowIndex < rowLength; rowIn
row = node.rows[rowIndex];
for (var cellIndex = 0, cellLength = row.cells.length; cellIndex < cellLength; cellIndex++) {
cell = row.cells[cellIndex];
- if (commons.table.isDataCell(cell) && (!commons.aria.label(cell) && !commons.table.getHeaders(cell).length)) {
+ if (axe.commons.table.isDataCell(cell) &&
+ (!axe.commons.aria.label(cell) &&
+ !axe.commons.table.getHeaders(cell).length)) {
badCells.push(cell);
}
}
diff --git a/lib/checks/tables/consistent-columns.js b/lib/checks/tables/consistent-columns.js
index 8c6e61d0f5..222d122e0f 100644
--- a/lib/checks/tables/consistent-columns.js
+++ b/lib/checks/tables/consistent-columns.js
@@ -1,4 +1,4 @@
-var table = commons.table.toArray(node);
+var table = axe.commons.table.toArray(node);
var relatedNodes = [];
var expectedWidth;
for (var i = 0, length = table.length; i < length; i++) {
diff --git a/lib/checks/tables/headers-attr-reference.js b/lib/checks/tables/headers-attr-reference.js
index 619b8488df..11c4a1e5ca 100644
--- a/lib/checks/tables/headers-attr-reference.js
+++ b/lib/checks/tables/headers-attr-reference.js
@@ -2,7 +2,7 @@ var row, cell, headerCells,
badHeaders = [];
function checkHeader(header) {
- if (!header || !commons.text.accessibleText(header)) {
+ if (!header || !axe.commons.text.accessibleText(header)) {
badHeaders.push(cell);
}
}
@@ -11,7 +11,7 @@ for (var rowIndex = 0, rowLength = node.rows.length; rowIndex < rowLength; rowIn
row = node.rows[rowIndex];
for (var cellIndex = 0, cellLength = row.cells.length; cellIndex < cellLength; cellIndex++) {
cell = row.cells[cellIndex];
- headerCells = commons.dom.idrefs(cell, 'headers');
+ headerCells = axe.commons.dom.idrefs(cell, 'headers');
if (headerCells.length) {
headerCells.forEach(checkHeader);
}
diff --git a/lib/checks/tables/headers-visible-text.js b/lib/checks/tables/headers-visible-text.js
index b8dc342b85..281204579f 100644
--- a/lib/checks/tables/headers-visible-text.js
+++ b/lib/checks/tables/headers-visible-text.js
@@ -5,7 +5,7 @@ for (var rowIndex = 0, rowLength = node.rows.length; rowIndex < rowLength; rowIn
row = node.rows[rowIndex];
for (var cellIndex = 0, cellLength = row.cells.length; cellIndex < cellLength; cellIndex++) {
cell = row.cells[cellIndex];
- if (commons.table.isHeader(cell) && !commons.text.accessibleText(cell)) {
+ if (axe.commons.table.isHeader(cell) && !axe.commons.text.accessibleText(cell)) {
badHeaders.push(cell);
}
}
diff --git a/lib/checks/tables/html4-scope.js b/lib/checks/tables/html4-scope.js
index 0277cdda8b..5441263fc6 100644
--- a/lib/checks/tables/html4-scope.js
+++ b/lib/checks/tables/html4-scope.js
@@ -1,5 +1,5 @@
-if (commons.dom.isHTML5(document)) {
+if (axe.commons.dom.isHTML5(document)) {
return false;
}
var nodeName = node.nodeName.toUpperCase();
diff --git a/lib/checks/tables/html5-scope.js b/lib/checks/tables/html5-scope.js
index c621e2a2a0..c6319896cb 100644
--- a/lib/checks/tables/html5-scope.js
+++ b/lib/checks/tables/html5-scope.js
@@ -1,5 +1,5 @@
-if (!commons.dom.isHTML5(document)) {
+if (!axe.commons.dom.isHTML5(document)) {
return false;
}
diff --git a/lib/checks/tables/same-caption-summary.js b/lib/checks/tables/same-caption-summary.js
index a8809e8845..3f58cf3521 100644
--- a/lib/checks/tables/same-caption-summary.js
+++ b/lib/checks/tables/same-caption-summary.js
@@ -1 +1 @@
-return !!(node.summary && node.caption) && node.summary === commons.text.accessibleText(node.caption);
+return !!(node.summary && node.caption) && node.summary === axe.commons.text.accessibleText(node.caption);
diff --git a/lib/checks/tables/th-single-row-column.js b/lib/checks/tables/th-single-row-column.js
index 7a22f81b1a..1a9baba2e2 100644
--- a/lib/checks/tables/th-single-row-column.js
+++ b/lib/checks/tables/th-single-row-column.js
@@ -8,10 +8,10 @@ for (var rowIndex = 0, rowLength = node.rows.length; rowIndex < rowLength; rowIn
for (var cellIndex = 0, cellLength = row.cells.length; cellIndex < cellLength; cellIndex++) {
cell = row.cells[cellIndex];
if (cell.nodeType === 1) {
- if (commons.table.isColumnHeader(cell) && columnHeaders.indexOf(rowIndex) === -1) {
+ if (axe.commons.table.isColumnHeader(cell) && columnHeaders.indexOf(rowIndex) === -1) {
columnHeaders.push(rowIndex);
- } else if (commons.table.isRowHeader(cell)) {
- position = commons.table.getCellPosition(cell);
+ } else if (axe.commons.table.isRowHeader(cell)) {
+ position = axe.commons.table.getCellPosition(cell);
if (rowHeaders.indexOf(position.x) === -1) {
rowHeaders.push(position.x);
}
diff --git a/lib/commons/aria/attributes.js b/lib/commons/aria/attributes.js
index 6670163ca4..3ccd690a61 100644
--- a/lib/commons/aria/attributes.js
+++ b/lib/commons/aria/attributes.js
@@ -1,4 +1,4 @@
-/*global aria, utils, lookupTables */
+/*global aria, axe, lookupTables */
/**
* Get required attributes for a given role
@@ -59,7 +59,7 @@ aria.validateAttrValue = function (node, attr) {
return (typeof value === 'string' && attrInfo.values.indexOf(value.toLowerCase()) !== -1);
case 'nmtokens':
- list = utils.tokenList(value);
+ list = axe.utils.tokenList(value);
// Check if any value isn't in the list of values
return list.reduce(function (result, token) {
return (result && attrInfo.values.indexOf(token) !== -1);
@@ -70,7 +70,7 @@ aria.validateAttrValue = function (node, attr) {
return !!(value && doc.getElementById(value));
case 'idrefs':
- list = utils.tokenList(value);
+ list = axe.utils.tokenList(value);
// Check if any value isn't in the list of values
return list.reduce(function (result, token) {
return !!(result && doc.getElementById(token));
diff --git a/lib/commons/aria/roles.js b/lib/commons/aria/roles.js
index c3f2c9cbf4..062b7f9ac9 100644
--- a/lib/commons/aria/roles.js
+++ b/lib/commons/aria/roles.js
@@ -1,4 +1,4 @@
-/*global aria, lookupTables, utils */
+/*global aria, lookupTables, axe */
/**
* Check if a given role is valid
@@ -58,7 +58,7 @@ aria.requiredOwned = function (role) {
roles = lookupTables.role[role];
if (roles) {
- owned = utils.clone(roles.owned);
+ owned = axe.utils.clone(roles.owned);
}
return owned;
};
@@ -74,7 +74,7 @@ aria.requiredContext = function (role) {
roles = lookupTables.role[role];
if (roles) {
- context = utils.clone(roles.context);
+ context = axe.utils.clone(roles.context);
}
return context;
};
@@ -91,7 +91,7 @@ aria.implicitNodes = function (role) {
roles = lookupTables.role[role];
if (roles && roles.implicit) {
- implicit = utils.clone(roles.implicit);
+ implicit = axe.utils.clone(roles.implicit);
}
return implicit;
};
@@ -113,7 +113,7 @@ aria.implicitRole = function (node) {
if (r.implicit) {
for (var index = 0, length = r.implicit.length; index < length; index++) {
candidate = r.implicit[index];
- if (utils.matchesSelector(node, candidate)) {
+ if (axe.utils.matchesSelector(node, candidate)) {
return role;
}
}
diff --git a/lib/commons/dom/find-up.js b/lib/commons/dom/find-up.js
index e3d8b72dfd..db5c6b2ce1 100644
--- a/lib/commons/dom/find-up.js
+++ b/lib/commons/dom/find-up.js
@@ -1,4 +1,4 @@
-/*global dom, utils */
+/*global dom, axe */
/**
* recusively walk up the DOM, checking for a node which matches a selector
*
@@ -20,7 +20,7 @@ dom.findUp = function (element, target) {
return null;
}
- matches = utils.toArray(matches);
+ matches = axe.utils.toArray(matches);
parent = element.parentNode;
// recrusively walk up the DOM, checking each parent node
diff --git a/lib/commons/dom/idrefs.js b/lib/commons/dom/idrefs.js
index 46b004286b..be0ef6d6b7 100644
--- a/lib/commons/dom/idrefs.js
+++ b/lib/commons/dom/idrefs.js
@@ -1,4 +1,4 @@
-/*global dom, utils */
+/*global dom, axe */
/**
* Get elements referenced via a space-separated token attribute; it will insert `null` for any Element that is not found
@@ -15,7 +15,7 @@ dom.idrefs = function (node, attr) {
idrefs = node.getAttribute(attr);
if (idrefs) {
- idrefs = utils.tokenList(idrefs);
+ idrefs = axe.utils.tokenList(idrefs);
for (index = 0, length = idrefs.length; index < length; index++) {
result.push(doc.getElementById(idrefs[index]));
}
diff --git a/lib/commons/table/is-header.js b/lib/commons/table/is-header.js
index 95909d7d7a..906a9da254 100644
--- a/lib/commons/table/is-header.js
+++ b/lib/commons/table/is-header.js
@@ -1,4 +1,4 @@
-/*global table, utils */
+/*global table, axe */
/**
* Determine if a `HTMLTableCellElement` is a header
@@ -11,7 +11,7 @@ table.isHeader = function (cell) {
}
if (cell.id) {
- return !!document.querySelector('[headers~="' + utils.escapeSelector(cell.id) + '"]');
+ return !!document.querySelector('[headers~="' + axe.utils.escapeSelector(cell.id) + '"]');
}
return false;
diff --git a/lib/commons/text/accessible-text.js b/lib/commons/text/accessible-text.js
index e462f8c7df..44cce2d97a 100644
--- a/lib/commons/text/accessible-text.js
+++ b/lib/commons/text/accessible-text.js
@@ -1,4 +1,4 @@
-/*global text, dom, aria, utils */
+/*global text, dom, aria, axe */
/*jshint maxstatements: 25, maxcomplexity: 19 */
var defaultButtonValues = {
@@ -22,7 +22,7 @@ var phrasingElements = ['A', 'EM', 'STRONG', 'SMALL', 'MARK', 'ABBR', 'DFN', 'I'
function findLabel(element) {
var ref = null;
if (element.id) {
- ref = document.querySelector('label[for="' + utils.escapeSelector(element.id) + '"]');
+ ref = document.querySelector('label[for="' + axe.utils.escapeSelector(element.id) + '"]');
if (ref) {
return ref;
}
diff --git a/lib/commons/text/label.js b/lib/commons/text/label.js
index ad35488f3d..781d2bea1f 100644
--- a/lib/commons/text/label.js
+++ b/lib/commons/text/label.js
@@ -1,4 +1,4 @@
-/*global text, dom, utils, aria */
+/*global text, dom, axe, aria */
/**
* Gets the visible text of a label for a given input
* @see http://www.w3.org/WAI/PF/aria/roles#namecalculation
@@ -15,7 +15,7 @@ text.label = function (node) {
// explicit label
if (node.id) {
- ref = document.querySelector('label[for="' + utils.escapeSelector(node.id) + '"]');
+ ref = document.querySelector('label[for="' + axe.utils.escapeSelector(node.id) + '"]');
candidate = ref && text.visible(ref, true);
if (candidate) {
return candidate;
diff --git a/lib/commons/utils/index.js b/lib/commons/utils/index.js
index 043f3b47bc..8c2d0e801c 100644
--- a/lib/commons/utils/index.js
+++ b/lib/commons/utils/index.js
@@ -1,7 +1,4 @@
/*exported utils */
/*global axe */
-var utils = commons.utils = {};
+var utils = commons.utils = axe.utils;
-utils.escapeSelector = axe.utils.escapeSelector;
-utils.matchesSelector = axe.utils.matchesSelector;
-utils.clone = axe.utils.clone;
diff --git a/lib/commons/utils/to-array.js b/lib/commons/utils/to-array.js
index 0a710503b0..eb5c170e5e 100644
--- a/lib/commons/utils/to-array.js
+++ b/lib/commons/utils/to-array.js
@@ -1,5 +1,5 @@
-/*global utils */
-utils.toArray = function (thing) {
+/*global axe */
+axe.utils.toArray = function (thing) {
'use strict';
return Array.prototype.slice.call(thing);
};
\ No newline at end of file
diff --git a/lib/commons/utils/token-list.js b/lib/commons/utils/token-list.js
index 022758a007..8efccbd152 100644
--- a/lib/commons/utils/token-list.js
+++ b/lib/commons/utils/token-list.js
@@ -1,7 +1,6 @@
-/*global utils */
+/*global axe */
-
-utils.tokenList = function (str) {
+axe.utils.tokenList = function (str) {
'use strict';
return str.trim().replace(/\s{2,}/g, ' ').split(' ');
diff --git a/lib/core/base/audit.js b/lib/core/base/audit.js
index 81796f9207..5040d8e452 100644
--- a/lib/core/base/audit.js
+++ b/lib/core/base/audit.js
@@ -122,9 +122,9 @@ Audit.prototype.addCheck = function (spec) {
Audit.prototype.run = function (context, options, resolve, reject) {
'use strict';
- var q = utils.queue();
+ var q = axe.utils.queue();
this.rules.forEach(function (rule) {
- if (utils.ruleShouldRun(rule, context, options)) {
+ if (axe.utils.ruleShouldRun(rule, context, options)) {
q.defer(function (res, rej) {
rule.run(context, options, res, function (err) {
if (!options.debug) {
@@ -153,7 +153,7 @@ Audit.prototype.after = function (results, options) {
var rules = this.rules;
return results.map(function (ruleResult) {
- var rule = utils.findBy(rules, 'id', ruleResult.id);
+ var rule = axe.utils.findBy(rules, 'id', ruleResult.id);
return rule.after(ruleResult, options);
});
diff --git a/lib/core/base/check.js b/lib/core/base/check.js
index b0d56e7fed..e304902369 100644
--- a/lib/core/base/check.js
+++ b/lib/core/base/check.js
@@ -1,8 +1,16 @@
/*global CheckResult */
-function Check(spec) {
+function createExecutionContext(spec) {
/*jshint evil:true */
'use strict';
+ if (typeof spec === 'string') {
+ return new Function('return ' + spec + ';')();
+ }
+ return spec;
+}
+
+function Check(spec) {
+ 'use strict';
/**
* Unique ID for the check. Checks may be re-used, so there may be additional instances of checks
@@ -30,22 +38,14 @@ function Check(spec) {
* - `data()` - free-form data object, associated to the `CheckResult` which is specific to each node
* @type {Function}
*/
- if (typeof spec.evaluate === 'string') {
- this.evaluate = new Function('return ' + spec.evaluate + ';')();
- } else {
- this.evaluate = spec.evaluate;
- }
+ this.evaluate = createExecutionContext(spec.evaluate);
/**
* Optional. Filter and/or modify checks for all nodes
* @type {Function}
*/
if (spec.after) {
- if (typeof spec.after === 'string') {
- this.after = new Function('return ' + spec.after + ';')();
- } else {
- this.after = spec.after;
- }
+ this.after = createExecutionContext(spec.after);
}
if (spec.matches) {
@@ -53,11 +53,7 @@ function Check(spec) {
* Optional function to test if check should be run against a node, overrides Check#matches
* @type {Function}
*/
- if (typeof spec.matches === 'string') {
- this.matches = new Function('return ' + spec.matches + ';')();
- } else {
- this.matches = spec.matches;
- }
+ this.matches = createExecutionContext(spec.matches);
}
/**
@@ -75,7 +71,7 @@ function Check(spec) {
Check.prototype.matches = function (node) {
'use strict';
- if (!this.selector || utils.matchesSelector(node, this.selector)) {
+ if (!this.selector || axe.utils.matchesSelector(node, this.selector)) {
return true;
}
@@ -97,7 +93,7 @@ Check.prototype.run = function (node, options, resolve, reject) {
if (enabled && this.matches(node)) {
var checkResult = new CheckResult(this);
- var checkHelper = utils.checkHelper(checkResult, resolve, reject);
+ var checkHelper = axe.utils.checkHelper(checkResult, resolve, reject);
var result;
try {
diff --git a/lib/core/base/context.js b/lib/core/base/context.js
index 5390028ae7..538b8ecc2f 100644
--- a/lib/core/base/context.js
+++ b/lib/core/base/context.js
@@ -8,11 +8,11 @@
*/
function pushUniqueFrame(collection, frame) {
'use strict';
- if (utils.isHidden(frame)) {
+ if (axe.utils.isHidden(frame)) {
return;
}
- var fr = utils.findBy(collection, 'node', frame);
+ var fr = axe.utils.findBy(collection, 'node', frame);
if (!fr) {
collection.push({
@@ -126,14 +126,14 @@ function parseSelectorArray(context, type) {
item = context[type][i];
// selector
if (typeof item === 'string') {
- result = result.concat(utils.toArray(document.querySelectorAll(item)));
+ result = result.concat(axe.utils.toArray(document.querySelectorAll(item)));
break;
} else if (item && item.length) {
if (item.length > 1) {
pushUniqueFrameSelector(context, type, item);
} else {
- result = result.concat(utils.toArray(document.querySelectorAll(item[0])));
+ result = result.concat(axe.utils.toArray(document.querySelectorAll(item[0])));
}
} else {
result.push(item);
@@ -181,7 +181,7 @@ function Context(spec) {
this.include = parseSelectorArray(this, 'include');
this.exclude = parseSelectorArray(this, 'exclude');
- utils.select('frame, iframe', this).forEach(function (frame) {
+ axe.utils.select('frame, iframe', this).forEach(function (frame) {
if (isNodeInContext(frame, self)) {
pushUniqueFrame(self.frames, frame);
}
diff --git a/lib/core/base/rule.js b/lib/core/base/rule.js
index 1057e30231..30393296b5 100644
--- a/lib/core/base/rule.js
+++ b/lib/core/base/rule.js
@@ -1,4 +1,4 @@
-/*global RuleResult */
+/*global RuleResult, createExecutionContext */
function Rule(spec, parentAudit) {
/*jshint evil:true */
@@ -67,11 +67,7 @@ function Rule(spec, parentAudit) {
* Optional function to test if rule should be run against a node, overrides Rule#matches
* @type {Function}
*/
- if (typeof spec.matches === 'string') {
- this.matches = new Function('return ' + spec.matches + ';')();
- } else {
- this.matches = spec.matches;
- }
+ this.matches = createExecutionContext(spec.matches);
}
}
@@ -94,10 +90,10 @@ Rule.prototype.matches = function () {
*/
Rule.prototype.gather = function (context) {
'use strict';
- var elements = utils.select(this.selector, context);
+ var elements = axe.utils.select(this.selector, context);
if (this.excludeHidden) {
return elements.filter(function (element) {
- return !utils.isHidden(element);
+ return !axe.utils.isHidden(element);
});
}
return elements;
@@ -107,10 +103,10 @@ Rule.prototype.runChecks = function (type, node, options, resolve, reject) {
'use strict';
var self = this;
- var checkQueue = utils.queue();
+ var checkQueue = axe.utils.queue();
this[type].forEach(function (c) {
var check = self._audit.checks[c.id || c];
- var option = utils.getCheckOption(check, self.id, options);
+ var option = axe.utils.getCheckOption(check, self.id, options);
checkQueue.defer(function (res, rej) {
check.run(node, option, res, rej);
});
@@ -135,7 +131,7 @@ Rule.prototype.run = function (context, options, resolve, reject) {
'use strict';
var nodes = this.gather(context);
- var q = utils.queue();
+ var q = axe.utils.queue();
var self = this;
var ruleResult;
@@ -143,7 +139,7 @@ Rule.prototype.run = function (context, options, resolve, reject) {
nodes.forEach(function (node) {
if (self.matches(node)) {
q.defer(function (resolveNode, rejectNode) {
- var checkQueue = utils.queue();
+ var checkQueue = axe.utils.queue();
checkQueue.defer(function (res, rej) {
self.runChecks('any', node, options, res, rej);
});
@@ -158,7 +154,7 @@ Rule.prototype.run = function (context, options, resolve, reject) {
if (results.length) {
var hasResults = false,
result = {
- node: new utils.DqElement(node)
+ node: new axe.utils.DqElement(node)
};
results.forEach(function (r) {
var res = r.results.filter(function (result) {
@@ -195,7 +191,7 @@ Rule.prototype.run = function (context, options, resolve, reject) {
function findAfterChecks(rule) {
'use strict';
- return utils.getAllChecks(rule).map(function (c) {
+ return axe.utils.getAllChecks(rule).map(function (c) {
var check = rule._audit.checks[c.id || c];
return (check && typeof check.after === 'function') ? check : null;
}).filter(Boolean);
@@ -213,7 +209,7 @@ function findCheckResults(nodes, checkID) {
var checkResults = [];
nodes.forEach(function (nodeResult) {
- var checks = utils.getAllChecks(nodeResult);
+ var checks = axe.utils.getAllChecks(nodeResult);
checks.forEach(function (checkResult) {
if (checkResult.id === checkID) {
checkResults.push(checkResult);
@@ -270,7 +266,7 @@ Rule.prototype.after = function (result, options) {
var ruleID = this.id;
afterChecks.forEach(function (check) {
var beforeResults = findCheckResults(result.nodes, check.id);
- var option = utils.getCheckOption(check, ruleID, options);
+ var option = axe.utils.getCheckOption(check, ruleID, options);
var afterResults = check.after(beforeResults, option);
beforeResults.forEach(function (item) {
diff --git a/lib/core/public/cleanup-plugins.js b/lib/core/public/cleanup-plugins.js
index 3ab2e3aa94..46b3fab118 100644
--- a/lib/core/public/cleanup-plugins.js
+++ b/lib/core/public/cleanup-plugins.js
@@ -5,7 +5,7 @@ function cleanupPlugins(resolve, reject) {
throw new Error('No audit configured');
}
- var q = utils.queue();
+ var q = axe.utils.queue();
// If a plugin fails it's cleanup, we still want the others to run
var cleanupErrors = [];
@@ -23,9 +23,9 @@ function cleanupPlugins(resolve, reject) {
});
});
- utils.toArray(document.querySelectorAll('frame, iframe')).forEach(function (frame) {
+ axe.utils.toArray(document.querySelectorAll('frame, iframe')).forEach(function (frame) {
q.defer(function (res, rej) {
- return utils.sendCommandToFrame(frame, {
+ return axe.utils.sendCommandToFrame(frame, {
command: 'cleanup-plugin'
}, res, rej);
});
diff --git a/lib/core/public/load.js b/lib/core/public/load.js
index c3cb176a5d..82b5156905 100644
--- a/lib/core/public/load.js
+++ b/lib/core/public/load.js
@@ -36,13 +36,13 @@ function runCommand(data, keepalive, callback) {
axe._load = function(audit) {
'use strict';
- utils.respondable.subscribe('axe.ping', function(data, keepalive, respond) {
+ axe.utils.respondable.subscribe('axe.ping', function(data, keepalive, respond) {
respond({
axe: true
});
});
- utils.respondable.subscribe('axe.start', runCommand);
+ axe.utils.respondable.subscribe('axe.start', runCommand);
axe._audit = new Audit(audit);
};
diff --git a/lib/core/public/plugins.js b/lib/core/public/plugins.js
index 155a8de02f..65ba6253c1 100644
--- a/lib/core/public/plugins.js
+++ b/lib/core/public/plugins.js
@@ -23,7 +23,7 @@ Plugin.prototype.collect = function () {
Plugin.prototype.cleanup = function (done) {
'use strict';
- var q = utils.queue();
+ var q = axe.utils.queue();
var that = this;
Object.keys(this._registry).forEach(function (key) {
q.defer(function (done) {
diff --git a/lib/core/public/run-rules.js b/lib/core/public/run-rules.js
index 5f0c35eaaf..d4c7f2fdfa 100644
--- a/lib/core/public/run-rules.js
+++ b/lib/core/public/run-rules.js
@@ -12,12 +12,12 @@ function runRules(context, options, resolve, reject) {
'use strict';
context = new Context(context);
- var q = utils.queue();
+ var q = axe.utils.queue();
var audit = axe._audit;
if (context.frames.length) {
q.defer(function (res, rej) {
- utils.collectResultsFromFrames(context, options, 'rules', null, res, rej);
+ axe.utils.collectResultsFromFrames(context, options, 'rules', null, res, rej);
});
}
q.defer(function (res, rej) {
@@ -26,7 +26,7 @@ function runRules(context, options, resolve, reject) {
q.then(function (data) {
try {
// Add wrapper object so that we may use the same "merge" function for results from inside and outside frames
- var results = utils.mergeResults(data.map(function (d) {
+ var results = axe.utils.mergeResults(data.map(function (d) {
return {
results: d
};
@@ -35,7 +35,7 @@ function runRules(context, options, resolve, reject) {
// after should only run once, so ensure we are in the top level window
if (context.initiator) {
results = audit.after(results, options);
- results = results.map(utils.finalizeRuleResult);
+ results = results.map(axe.utils.finalizeRuleResult);
}
resolve(results);
} catch (e) {
diff --git a/lib/core/reporters/helpers/split-results.js b/lib/core/reporters/helpers/split-results.js
index 61e323fafd..efd86eba7a 100644
--- a/lib/core/reporters/helpers/split-results.js
+++ b/lib/core/reporters/helpers/split-results.js
@@ -19,7 +19,7 @@ helpers.splitResults = function (results, nodeDataMapper) {
var failResult,
passResult = helpers.formatRuleResult(rr);
- failResult = utils.clone(passResult);
+ failResult = axe.utils.clone(passResult);
failResult.impact = rr.impact || null;
failResult.nodes = rr.violations.map(mapNode);
diff --git a/lib/core/utils/check-helper.js b/lib/core/utils/check-helper.js
index ee183a2981..b9ed513db7 100644
--- a/lib/core/utils/check-helper.js
+++ b/lib/core/utils/check-helper.js
@@ -4,7 +4,7 @@
* @param {Function} callback The callback to expose when `this.async()` is called
* @return {Object} Bound to `this` for a check's fn
*/
-utils.checkHelper = function checkHelper(checkResult, resolve, reject) {
+axe.utils.checkHelper = function checkHelper(checkResult, resolve, reject) {
'use strict';
return {
@@ -24,9 +24,9 @@ utils.checkHelper = function checkHelper(checkResult, resolve, reject) {
checkResult.data = data;
},
relatedNodes: function (nodes) {
- nodes = nodes instanceof Node ? [nodes] : utils.toArray(nodes);
+ nodes = nodes instanceof Node ? [nodes] : axe.utils.toArray(nodes);
checkResult.relatedNodes = nodes.map(function (element) {
- return new utils.DqElement(element);
+ return new axe.utils.DqElement(element);
});
}
};
diff --git a/lib/core/utils/clone.js b/lib/core/utils/clone.js
index 8064ac14f2..46104bd9fe 100644
--- a/lib/core/utils/clone.js
+++ b/lib/core/utils/clone.js
@@ -3,7 +3,7 @@
* @param {Mixed} obj The object/array to clone
* @return {Mixed} A clone of the initial object or array
*/
-utils.clone = function (obj) {
+axe.utils.clone = function (obj) {
'use strict';
var index, length,
out = obj;
@@ -12,13 +12,13 @@ utils.clone = function (obj) {
if (Array.isArray(obj)) {
out = [];
for (index = 0, length = obj.length; index < length; index++) {
- out[index] = utils.clone(obj[index]);
+ out[index] = axe.utils.clone(obj[index]);
}
} else {
out = {};
// jshint forin: false
for (index in obj) {
- out[index] = utils.clone(obj[index]);
+ out[index] = axe.utils.clone(obj[index]);
}
}
}
diff --git a/lib/core/utils/collect-results-from-frames.js b/lib/core/utils/collect-results-from-frames.js
index 343812ecc4..f658c2a764 100644
--- a/lib/core/utils/collect-results-from-frames.js
+++ b/lib/core/utils/collect-results-from-frames.js
@@ -1,7 +1,7 @@
function err(message, node) {
'use strict';
- return new Error(message + ': ' + utils.getSelector(node));
+ return new Error(message + ': ' + axe.utils.getSelector(node));
}
/**
@@ -10,7 +10,7 @@ function err(message, node) {
* @param {Object} parameters Parameters to pass to the frame
* @param {Function} callback Function to call when results from all frames have returned
*/
-utils.sendCommandToFrame = function(node, parameters, resolve, reject) {
+axe.utils.sendCommandToFrame = function(node, parameters, resolve, reject) {
'use strict';
var win = node.contentWindow;
@@ -30,13 +30,13 @@ utils.sendCommandToFrame = function(node, parameters, resolve, reject) {
}
}, 500);
- utils.respondable(win, 'axe.ping', null, undefined, function() {
+ axe.utils.respondable(win, 'axe.ping', null, undefined, function() {
clearTimeout(timeout);
timeout = setTimeout(function() {
reject(err('Axe in frame timed out', node));
}, 30000);
- utils.respondable(win, 'axe.start', parameters, true, function(data) {
+ axe.utils.respondable(win, 'axe.start', parameters, true, function(data) {
clearTimeout(timeout);
if (data instanceof Error === false) {
resolve(data);
@@ -59,7 +59,7 @@ utils.sendCommandToFrame = function(node, parameters, resolve, reject) {
function collectResultsFromFrames(context, options, command, parameter, resolve, reject) {
'use strict';
- var q = utils.queue();
+ var q = axe.utils.queue();
var frames = context.frames;
function defer(frame) {
@@ -77,12 +77,12 @@ function collectResultsFromFrames(context, options, command, parameter, resolve,
q.defer(function(res, rej) {
var node = frame.node;
- utils.sendCommandToFrame(node, params, function(data) {
+ axe.utils.sendCommandToFrame(node, params, function(data) {
if (data) {
return res({
results: data,
frameElement: node,
- frame: utils.getSelector(node)
+ frame: axe.utils.getSelector(node)
});
}
res(null);
@@ -95,11 +95,11 @@ function collectResultsFromFrames(context, options, command, parameter, resolve,
}
q.then(function(data) {
- resolve(utils.mergeResults(data));
+ resolve(axe.utils.mergeResults(data));
}).catch(reject);
}
-utils.collectResultsFromFrames = collectResultsFromFrames;
+axe.utils.collectResultsFromFrames = collectResultsFromFrames;
@@ -124,12 +124,12 @@ function runFrameAudit(frame, options, resolve, reject) {
exclude: frame.exclude || []
}
};
- utils.sendCommandToFrame(node, params, function(data) {
+ axe.utils.sendCommandToFrame(node, params, function(data) {
if (data) {
return resolve({
results: data,
frameElement: node,
- frame: utils.getSelector(node)
+ frame: axe.utils.getSelector(node)
});
}
// frame did not return data
@@ -137,4 +137,4 @@ function runFrameAudit(frame, options, resolve, reject) {
}, reject);
}
-utils.runFrameAudit = runFrameAudit;
+axe.utils.runFrameAudit = runFrameAudit;
diff --git a/lib/core/utils/contains.js b/lib/core/utils/contains.js
index 016ad37f97..2ba198d5e2 100644
--- a/lib/core/utils/contains.js
+++ b/lib/core/utils/contains.js
@@ -5,7 +5,7 @@
* @param {HTMLElement} otherNode The node to test is contained by `node`
* @return {Boolean} Whether `node` contains `otherNode`
*/
-utils.contains = function (node, otherNode) {
+axe.utils.contains = function (node, otherNode) {
//jshint bitwise: false
'use strict';
diff --git a/lib/core/utils/dq-element.js b/lib/core/utils/dq-element.js
index 432b0f09e2..763cbab242 100644
--- a/lib/core/utils/dq-element.js
+++ b/lib/core/utils/dq-element.js
@@ -37,7 +37,7 @@ function DqElement(element, spec) {
* A unique CSS selector for the element
* @type {String}
*/
- this.selector = spec.selector || [utils.getSelector(element)];
+ this.selector = spec.selector || [axe.utils.getSelector(element)];
/**
* The generated HTML source code of the element
@@ -61,4 +61,4 @@ DqElement.prototype.toJSON = function () {
};
};
-utils.DqElement = DqElement;
+axe.utils.DqElement = DqElement;
diff --git a/lib/core/utils/element-matches.js b/lib/core/utils/element-matches.js
index be0a7acd95..4588f42178 100644
--- a/lib/core/utils/element-matches.js
+++ b/lib/core/utils/element-matches.js
@@ -4,7 +4,7 @@
* @param {String} selector The selector to test element against
* @return {Boolean}
*/
-utils.matchesSelector = (function () {
+axe.utils.matchesSelector = (function () {
'use strict';
var method;
diff --git a/lib/core/utils/escape-selector.js b/lib/core/utils/escape-selector.js
index 9e1a56c4fb..093aa29e16 100644
--- a/lib/core/utils/escape-selector.js
+++ b/lib/core/utils/escape-selector.js
@@ -5,7 +5,7 @@
* @param {String} value The piece of the selector to escape
* @return {String} The escaped selector
*/
-utils.escapeSelector = function (value) {
+axe.utils.escapeSelector = function (value) {
'use strict';
/*jshint bitwise: true, eqeqeq: false, maxcomplexity: 14, maxstatements: 23, onevar: false, -W041: false */
var string = String(value);
diff --git a/lib/core/utils/extend-blacklist.js b/lib/core/utils/extend-blacklist.js
index 54644c09ee..09ba384538 100644
--- a/lib/core/utils/extend-blacklist.js
+++ b/lib/core/utils/extend-blacklist.js
@@ -5,7 +5,7 @@
* @param {Object} from Metadata to extend
* @param {Array} blacklist property names to exclude from resulting object
*/
-utils.extendBlacklist = function (to, from, blacklist) {
+axe.utils.extendBlacklist = function (to, from, blacklist) {
'use strict';
blacklist = blacklist || [];
diff --git a/lib/core/utils/extend-meta-data.js b/lib/core/utils/extend-meta-data.js
index 7a9e060d50..ccb6fc7e46 100644
--- a/lib/core/utils/extend-meta-data.js
+++ b/lib/core/utils/extend-meta-data.js
@@ -4,7 +4,7 @@
* @param {Object} to The target of the extend
* @param {Object} from Metadata to extend
*/
-utils.extendMetaData = function (to, from) {
+axe.utils.extendMetaData = function (to, from) {
'use strict';
for (var i in from) {
diff --git a/lib/core/utils/finalize-result.js b/lib/core/utils/finalize-result.js
index dce3d21afb..9e7305ce33 100644
--- a/lib/core/utils/finalize-result.js
+++ b/lib/core/utils/finalize-result.js
@@ -37,22 +37,22 @@ function calculateCheckResult(failingChecks) {
function calculateRuleResult(ruleResult) {
'use strict';
function checkMap(check) {
- return utils.extendBlacklist({}, check, ['result']);
+ return axe.utils.extendBlacklist({}, check, ['result']);
}
- var newRuleResult = utils.extendBlacklist({
+ var newRuleResult = axe.utils.extendBlacklist({
violations: [],
passes: []
}, ruleResult, ['nodes']);
ruleResult.nodes.forEach(function (detail) {
- var failingChecks = utils.getFailingChecks(detail);
+ var failingChecks = axe.utils.getFailingChecks(detail);
var result = calculateCheckResult(failingChecks);
if (result === axe.constants.result.FAIL) {
- raiseMetadata(detail, utils.getAllChecks(failingChecks));
+ raiseMetadata(detail, axe.utils.getAllChecks(failingChecks));
detail.any = failingChecks.any.map(checkMap);
detail.all = failingChecks.all.map(checkMap);
detail.none = failingChecks.none.map(checkMap);
@@ -77,7 +77,7 @@ function calculateRuleResult(ruleResult) {
return newRuleResult;
}
-utils.getFailingChecks = function (detail) {
+axe.utils.getFailingChecks = function (detail) {
'use strict';
var any = detail.any.filter(function (check) {
@@ -99,9 +99,9 @@ utils.getFailingChecks = function (detail) {
* Calculates the result of a Rule based on its types and the result of its child Checks
* @param {RuleResult} ruleResult The RuleResult to calculate the result of
*/
-utils.finalizeRuleResult = function (ruleResult) {
+axe.utils.finalizeRuleResult = function (ruleResult) {
'use strict';
- utils.publishMetaData(ruleResult);
+ axe.utils.publishMetaData(ruleResult);
return calculateRuleResult(ruleResult);
};
diff --git a/lib/core/utils/find-by.js b/lib/core/utils/find-by.js
index 3ba91b9db0..94b6b5c3e9 100644
--- a/lib/core/utils/find-by.js
+++ b/lib/core/utils/find-by.js
@@ -6,7 +6,7 @@
* @param {Mixed} value The value to find
* @return {Object} The first matching object or `undefined` if no match
*/
-utils.findBy = function (array, key, value) {
+axe.utils.findBy = function (array, key, value) {
'use strict';
array = array || [];
diff --git a/lib/core/utils/get-all-checks.js b/lib/core/utils/get-all-checks.js
index fe271b56f6..69ed0c0416 100644
--- a/lib/core/utils/get-all-checks.js
+++ b/lib/core/utils/get-all-checks.js
@@ -3,7 +3,7 @@
* Gets all Checks (or CheckResults) for a given Rule or RuleResult
* @param {RuleResult|Rule} rule
*/
-utils.getAllChecks = function getAllChecks(object) {
+axe.utils.getAllChecks = function getAllChecks(object) {
'use strict';
var result = [];
return result.concat(object.any || []).concat(object.all || []).concat(object.none || []);
diff --git a/lib/core/utils/get-check-option.js b/lib/core/utils/get-check-option.js
index 34d2142f9b..1f471fa519 100644
--- a/lib/core/utils/get-check-option.js
+++ b/lib/core/utils/get-check-option.js
@@ -6,7 +6,7 @@
* @param {Object} options Options object as passed to main API
* @return {Object} The resolved object with `options` and `enabled` keys
*/
-utils.getCheckOption = function (check, ruleID, options) {
+axe.utils.getCheckOption = function (check, ruleID, options) {
'use strict';
var ruleCheckOption = ((options.rules && options.rules[ruleID] || {}).checks || {})[check.id];
var checkOption = (options.checks || {})[check.id];
diff --git a/lib/core/utils/get-selector.js b/lib/core/utils/get-selector.js
index 0785ff0611..7d339b6ff1 100644
--- a/lib/core/utils/get-selector.js
+++ b/lib/core/utils/get-selector.js
@@ -44,7 +44,7 @@ function siblingsHaveSameSelector(node, selector) {
for (index = 0; index < length; index++) {
sibling = siblings[index];
- if (sibling !== node && utils.matchesSelector(sibling, selector)) {
+ if (sibling !== node && axe.utils.matchesSelector(sibling, selector)) {
return true;
}
}
@@ -57,12 +57,12 @@ function siblingsHaveSameSelector(node, selector) {
* @param {HTMLElement} node The element to get the selector for
* @return {String} Unique CSS selector for the node
*/
-utils.getSelector = function getSelector(node) {
+axe.utils.getSelector = function getSelector(node) {
//jshint maxstatements: 21
'use strict';
function escape(p) {
- return utils.escapeSelector(p);
+ return axe.utils.escapeSelector(p);
}
var parts = [], part;
@@ -70,8 +70,8 @@ utils.getSelector = function getSelector(node) {
while (node.parentNode) {
part = '';
- if (node.id && document.querySelectorAll('#' + utils.escapeSelector(node.id)).length === 1) {
- parts.unshift('#' + utils.escapeSelector(node.id));
+ if (node.id && document.querySelectorAll('#' + axe.utils.escapeSelector(node.id)).length === 1) {
+ parts.unshift('#' + axe.utils.escapeSelector(node.id));
break;
}
@@ -83,7 +83,7 @@ utils.getSelector = function getSelector(node) {
}
if (!part) {
- part = utils.escapeSelector(node.nodeName).toLowerCase();
+ part = axe.utils.escapeSelector(node.nodeName).toLowerCase();
if (part === 'html' || part === 'body') {
parts.unshift(part);
break;
diff --git a/lib/core/utils/inject-style.js b/lib/core/utils/inject-style.js
index a607389b99..548da44630 100644
--- a/lib/core/utils/inject-style.js
+++ b/lib/core/utils/inject-style.js
@@ -1,5 +1,5 @@
/*exported injectStyle */
-/*global utils*/
+/*global axe*/
var styleSheet;
function injectStyle(style) {
@@ -33,4 +33,4 @@ function injectStyle(style) {
return styleSheet;
}
-utils.injectStyle = injectStyle;
+axe.utils.injectStyle = injectStyle;
diff --git a/lib/core/utils/is-hidden.js b/lib/core/utils/is-hidden.js
index f517a3738d..13e86f437c 100644
--- a/lib/core/utils/is-hidden.js
+++ b/lib/core/utils/is-hidden.js
@@ -6,7 +6,7 @@
* @param {HTMLElement} el The HTMLElement
* @return {Boolean} The element's visibilty status
*/
-utils.isHidden = function isHidden(el, recursed) {
+axe.utils.isHidden = function isHidden(el, recursed) {
'use strict';
// 9 === Node.DOCUMENT
@@ -27,6 +27,6 @@ utils.isHidden = function isHidden(el, recursed) {
return true;
}
- return utils.isHidden(el.parentNode, true);
+ return axe.utils.isHidden(el.parentNode, true);
};
diff --git a/lib/core/utils/merge-results.js b/lib/core/utils/merge-results.js
index ca310b7c44..8f736038d2 100644
--- a/lib/core/utils/merge-results.js
+++ b/lib/core/utils/merge-results.js
@@ -10,13 +10,13 @@ function pushFrame(resultSet, frameElement, frameSelector) {
'use strict';
resultSet.forEach(function (res) {
res.node.selector.unshift(frameSelector);
- res.node = new utils.DqElement(frameElement, res.node);
- var checks = utils.getAllChecks(res);
+ res.node = new axe.utils.DqElement(frameElement, res.node);
+ var checks = axe.utils.getAllChecks(res);
if (checks.length) {
checks.forEach(function (check) {
check.relatedNodes.forEach(function (node) {
node.selector.unshift(frameSelector);
- node = new utils.DqElement(frameElement, node);
+ node = new axe.utils.DqElement(frameElement, node);
});
});
}
@@ -37,7 +37,7 @@ function spliceNodes(target, to) {
sorterResult, t;
for (var i = 0, l = target.length; i < l; i++) {
t = target[i].node;
- sorterResult = utils.nodeSorter(t.element, firstFromFrame.element);
+ sorterResult = axe.utils.nodeSorter(t.element, firstFromFrame.element);
if (sorterResult > 0 || (sorterResult === 0 && firstFromFrame.selector.length < t.selector.length)) {
target.splice.apply(target, [i, 0].concat(to));
return;
@@ -72,7 +72,7 @@ function normalizeResult(result) {
* @param {Array} frameResults Array of objects including the RuleResults as `results` and frame as `frame`
* @return {Array} The merged RuleResults; should only have one result per rule
*/
-utils.mergeResults = function mergeResults(frameResults) {
+axe.utils.mergeResults = function mergeResults(frameResults) {
'use strict';
var result = [];
frameResults.forEach(function (frameResult) {
@@ -86,7 +86,7 @@ utils.mergeResults = function mergeResults(frameResults) {
pushFrame(ruleResult.nodes, frameResult.frameElement, frameResult.frame);
}
- var res = utils.findBy(result, 'id', ruleResult.id);
+ var res = axe.utils.findBy(result, 'id', ruleResult.id);
if (!res) {
result.push(ruleResult);
} else {
diff --git a/lib/core/utils/node-sorter.js b/lib/core/utils/node-sorter.js
index 5daabb8e28..b92829aa81 100644
--- a/lib/core/utils/node-sorter.js
+++ b/lib/core/utils/node-sorter.js
@@ -5,7 +5,7 @@
* @param {Node} b
* @return {Integer} @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Sort
*/
-utils.nodeSorter = function nodeSorter(a, b) {
+axe.utils.nodeSorter = function nodeSorter(a, b) {
/*jshint bitwise: false */
'use strict';
diff --git a/lib/core/utils/publish-metadata.js b/lib/core/utils/publish-metadata.js
index f162809675..585f4f7f17 100644
--- a/lib/core/utils/publish-metadata.js
+++ b/lib/core/utils/publish-metadata.js
@@ -5,24 +5,24 @@
* @param {RuleResult} result Result to publish to
* @private
*/
-utils.publishMetaData = function (ruleResult) {
+axe.utils.publishMetaData = function (ruleResult) {
'use strict';
function extender(shouldBeTrue) {
return function (check) {
var sourceData = checksData[check.id] || {};
var messages = sourceData.messages || {};
- var data = utils.extendBlacklist({}, sourceData, ['messages']);
+ var data = axe.utils.extendBlacklist({}, sourceData, ['messages']);
data.message = check.result === shouldBeTrue ? messages.pass : messages.fail;
- utils.extendMetaData(check, data);
+ axe.utils.extendMetaData(check, data);
};
}
var checksData = axe._audit.data.checks || {};
var rulesData = axe._audit.data.rules || {};
- var rule = utils.findBy(axe._audit.rules, 'id', ruleResult.id) || {};
+ var rule = axe.utils.findBy(axe._audit.rules, 'id', ruleResult.id) || {};
- ruleResult.tags = utils.clone(rule.tags || []);
+ ruleResult.tags = axe.utils.clone(rule.tags || []);
var shouldBeTrue = extender(true);
var shouldBeFalse = extender(false);
@@ -31,5 +31,5 @@ utils.publishMetaData = function (ruleResult) {
detail.all.forEach(shouldBeTrue);
detail.none.forEach(shouldBeFalse);
});
- utils.extendMetaData(ruleResult, utils.clone(rulesData[ruleResult.id] || {}));
+ axe.utils.extendMetaData(ruleResult, axe.utils.clone(rulesData[ruleResult.id] || {}));
};
diff --git a/lib/core/utils/queue.js b/lib/core/utils/queue.js
index da4986784e..084aa26740 100644
--- a/lib/core/utils/queue.js
+++ b/lib/core/utils/queue.js
@@ -134,5 +134,5 @@
return q;
}
- utils.queue = queue;
+ axe.utils.queue = queue;
})();
diff --git a/lib/core/utils/respondable.js b/lib/core/utils/respondable.js
index 4548888cd1..024dce2a50 100644
--- a/lib/core/utils/respondable.js
+++ b/lib/core/utils/respondable.js
@@ -1,4 +1,4 @@
-/*global uuid */
+/*global uuid, utils */
(function (exports) {
'use strict';
var messages = {},
diff --git a/lib/core/utils/rule-should-run.js b/lib/core/utils/rule-should-run.js
index cff596e600..9a1eb412a3 100644
--- a/lib/core/utils/rule-should-run.js
+++ b/lib/core/utils/rule-should-run.js
@@ -46,7 +46,7 @@ function matchTags(rule, runOnly) {
* @param {Object} options Options object
* @return {Boolean}
*/
-utils.ruleShouldRun = function (rule, context, options) {
+axe.utils.ruleShouldRun = function (rule, context, options) {
'use strict';
var runOnly = options.runOnly || {};
var ruleOptions = (options.rules || {})[rule.id];
diff --git a/lib/core/utils/select.js b/lib/core/utils/select.js
index 036889b545..54156d4a63 100644
--- a/lib/core/utils/select.js
+++ b/lib/core/utils/select.js
@@ -8,7 +8,7 @@ function getDeepest(collection) {
'use strict';
return collection.sort(function (a, b) {
- if (utils.contains(a, b)) {
+ if (axe.utils.contains(a, b)) {
return 1;
}
return -1;
@@ -27,12 +27,12 @@ function isNodeInContext(node, context) {
'use strict';
var include = context.include && getDeepest(context.include.filter(function (candidate) {
- return utils.contains(candidate, node);
+ return axe.utils.contains(candidate, node);
}));
var exclude = context.exclude && getDeepest(context.exclude.filter(function (candidate) {
- return utils.contains(candidate, node);
+ return axe.utils.contains(candidate, node);
}));
- if ((!exclude && include) || (exclude && utils.contains(exclude, include))) {
+ if ((!exclude && include) || (exclude && axe.utils.contains(exclude, include))) {
return true;
}
return false;
@@ -61,17 +61,17 @@ function pushNode(result, nodes, context) {
* @param {Context} context The "resolved" context object, @see Context
* @return {Array} Matching nodes sorted by DOM order
*/
-utils.select = function select(selector, context) {
+axe.utils.select = function select(selector, context) {
'use strict';
var result = [], candidate;
for (var i = 0, l = context.include.length; i < l; i++) {
candidate = context.include[i];
- if (candidate.nodeType === candidate.ELEMENT_NODE && utils.matchesSelector(candidate, selector)) {
+ if (candidate.nodeType === candidate.ELEMENT_NODE && axe.utils.matchesSelector(candidate, selector)) {
pushNode(result, [candidate], context);
}
pushNode(result, candidate.querySelectorAll(selector), context);
}
- return result.sort(utils.nodeSorter);
+ return result.sort(axe.utils.nodeSorter);
};
diff --git a/lib/core/utils/to-array.js b/lib/core/utils/to-array.js
index 2801189290..5d04fc2adc 100644
--- a/lib/core/utils/to-array.js
+++ b/lib/core/utils/to-array.js
@@ -4,7 +4,7 @@
* @param {Mixed} thing Array-like thing to convert
* @return {Array}
*/
-utils.toArray = function (thing) {
+axe.utils.toArray = function (thing) {
'use strict';
return Array.prototype.slice.call(thing);
};
\ No newline at end of file
diff --git a/lib/outro.stub b/lib/outro.stub
index 2b9082facd..2a1f396b37 100644
--- a/lib/outro.stub
+++ b/lib/outro.stub
@@ -1,2 +1,2 @@
-})(this, this.document);
\ No newline at end of file
+})(window, window ? window.document : undefined);
\ No newline at end of file
diff --git a/lib/rules/.jshintrc b/lib/rules/.jshintrc
index 2d167f21e2..4fb6970fa1 100644
--- a/lib/rules/.jshintrc
+++ b/lib/rules/.jshintrc
@@ -3,7 +3,7 @@
"results": true,
"node": true,
"options": true,
- "commons": true
+ "axe": true
},
"browser" : false,
diff --git a/lib/rules/data-table-matches.js b/lib/rules/data-table-matches.js
index 45385ebd8a..df4e1bf80e 100644
--- a/lib/rules/data-table-matches.js
+++ b/lib/rules/data-table-matches.js
@@ -1 +1 @@
-return commons.table.isDataTable(node);
\ No newline at end of file
+return axe.commons.table.isDataTable(node);
\ No newline at end of file
diff --git a/lib/rules/layout-table-matches.js b/lib/rules/layout-table-matches.js
index 913b6a5790..bc1598ffde 100644
--- a/lib/rules/layout-table-matches.js
+++ b/lib/rules/layout-table-matches.js
@@ -1 +1 @@
-return !commons.table.isDataTable(node);
\ No newline at end of file
+return !axe.commons.table.isDataTable(node);
\ No newline at end of file
diff --git a/lib/rules/link-in-text-block-matches.js b/lib/rules/link-in-text-block-matches.js
index 2bc0a95869..dceb82be0c 100644
--- a/lib/rules/link-in-text-block-matches.js
+++ b/lib/rules/link-in-text-block-matches.js
@@ -1,5 +1,5 @@
/* global window */
-var text = commons.text.sanitize(node.textContent);
+var text = axe.commons.text.sanitize(node.textContent);
if (!text) {
return false;
@@ -19,7 +19,7 @@ while (parentBlock.nodeType === 1 && !isBlock(parentBlock)) {
if (parentBlock.textContent) {
- var parentText = commons.text.sanitize(parentBlock.textContent);
+ var parentText = axe.commons.text.sanitize(parentBlock.textContent);
return (text !== parentText);
} else {
return false;
diff --git a/test/.jshintrc b/test/.jshintrc
index 2307280b07..b9b8e7667d 100644
--- a/test/.jshintrc
+++ b/test/.jshintrc
@@ -10,8 +10,7 @@
"chai": true,
"assert": true,
"axe": true,
- "helpers": true,
- "utils": true
+ "helpers": true
},
"browser" : true,
diff --git a/test/checks/.jshintrc b/test/checks/.jshintrc
index 2b083ab221..62df2a4928 100644
--- a/test/checks/.jshintrc
+++ b/test/checks/.jshintrc
@@ -11,7 +11,7 @@
"assert": true,
"checks": true,
"dqreRules": true,
- "commons": true
+ "axe": true
},
"browser" : true,
diff --git a/test/checks/aria/allowed-attr.js b/test/checks/aria/allowed-attr.js
index 9fd238f31f..17f418c4c1 100644
--- a/test/checks/aria/allowed-attr.js
+++ b/test/checks/aria/allowed-attr.js
@@ -70,7 +70,7 @@ describe('aria-allowed-attr', function () {
});
- it('should determine attribute validity by calling commons.aria.allowedAttr', function () {
+ it('should determine attribute validity by calling axe.commons.aria.allowedAttr', function () {
var node = document.createElement('div');
node.id = 'test';
node.tabIndex = 1;
@@ -79,9 +79,9 @@ describe('aria-allowed-attr', function () {
node.setAttribute('aria-bats', 'dead');
fixture.appendChild(node);
- var orig = commons.aria.allowedAttr;
+ var orig = axe.commons.aria.allowedAttr;
var called = 0;
- commons.aria.allowedAttr = function (role) {
+ axe.commons.aria.allowedAttr = function (role) {
assert.equal(role, 'cats');
called++;
return ['aria-cats', 'aria-bats'];
@@ -90,7 +90,7 @@ describe('aria-allowed-attr', function () {
assert.isNull(checkContext._data);
assert.equal(called, 1);
- commons.aria.allowedAttr = orig;
+ axe.commons.aria.allowedAttr = orig;
});
it('should not report on invalid attributes', function () {
@@ -109,8 +109,8 @@ describe('aria-allowed-attr', function () {
describe('matches', function () {
it('should return false on elements with no role or no implicit role', function () {
- var orig = commons.aria.implicitRole;
- commons.aria.implicitRole = function (nd) {
+ var orig = axe.commons.aria.implicitRole;
+ axe.commons.aria.implicitRole = function (nd) {
assert.equal(nd, div);
return null;
};
@@ -118,12 +118,12 @@ describe('aria-allowed-attr', function () {
fixture.appendChild(div);
assert.isFalse(checks['aria-allowed-attr'].matches(div));
- commons.aria.implicitRole = orig;
+ axe.commons.aria.implicitRole = orig;
});
it('should return false on elements that have no allowed attributes', function () {
- var orig = commons.aria.allowedAttr;
- commons.aria.allowedAttr = function (role) {
+ var orig = axe.commons.aria.allowedAttr;
+ axe.commons.aria.allowedAttr = function (role) {
assert.equal(role, 'button');
return null;
};
@@ -132,7 +132,7 @@ describe('aria-allowed-attr', function () {
fixture.appendChild(div);
assert.isFalse(checks['aria-allowed-attr'].matches(div));
- commons.aria.allowedAttr = orig;
+ axe.commons.aria.allowedAttr = orig;
});
it('should return false on elements that have a role but no aria attributes', function () {
diff --git a/test/checks/aria/required-attr.js b/test/checks/aria/required-attr.js
index fdd34056ec..7a0cc8bfe6 100644
--- a/test/checks/aria/required-attr.js
+++ b/test/checks/aria/required-attr.js
@@ -37,7 +37,7 @@ describe('aria-required-attr', function () {
});
- it('should determine attribute validity by calling commons.aria.requiredAttr', function () {
+ it('should determine attribute validity by calling axe.commons.aria.requiredAttr', function () {
var node = document.createElement('div');
node.id = 'test';
node.tabIndex = 1;
@@ -45,9 +45,9 @@ describe('aria-required-attr', function () {
node.setAttribute('aria-cats', 'maybe');
fixture.appendChild(node);
- var orig = commons.aria.requiredAttr;
+ var orig = axe.commons.aria.requiredAttr;
var called = 0;
- commons.aria.requiredAttr = function (role) {
+ axe.commons.aria.requiredAttr = function (role) {
assert.equal(role, 'cats');
called++;
return ['aria-cats', 'aria-bats'];
@@ -56,7 +56,7 @@ describe('aria-required-attr', function () {
assert.deepEqual(checkContext._data, ['aria-bats']);
assert.equal(called, 1);
- commons.aria.requiredAttr = orig;
+ axe.commons.aria.requiredAttr = orig;
});
});
\ No newline at end of file
diff --git a/test/checks/aria/valid-attr-value.js b/test/checks/aria/valid-attr-value.js
index 5e17447f2f..27ae8bd403 100644
--- a/test/checks/aria/valid-attr-value.js
+++ b/test/checks/aria/valid-attr-value.js
@@ -72,7 +72,7 @@ describe('aria-valid-attr-value', function () {
assert.deepEqual(checkContext._data, ['aria-selected="0"']);
});
- it('should determine attribute validity by calling commons.aria.validateAttrValue', function () {
+ it('should determine attribute validity by calling axe.commons.aria.validateAttrValue', function () {
var node = document.createElement('div');
node.id = 'test';
node.tabIndex = 1;
@@ -80,9 +80,9 @@ describe('aria-valid-attr-value', function () {
node.setAttribute('aria-live', 'dead');
fixture.appendChild(node);
- var orig = commons.aria.validateAttrValue;
+ var orig = axe.commons.aria.validateAttrValue;
var called = 0;
- commons.aria.validateAttrValue = function (nd, attrName) {
+ axe.commons.aria.validateAttrValue = function (nd, attrName) {
assert.equal(nd, node);
assert.match(attrName, /^aria-/);
called++;
@@ -92,7 +92,7 @@ describe('aria-valid-attr-value', function () {
assert.isNull(checkContext._data);
assert.equal(called, 2);
- commons.aria.validateAttrValue = orig;
+ axe.commons.aria.validateAttrValue = orig;
});
describe('options', function () {
diff --git a/test/checks/aria/valid-attr.js b/test/checks/aria/valid-attr.js
index aa34468978..285f41519c 100644
--- a/test/checks/aria/valid-attr.js
+++ b/test/checks/aria/valid-attr.js
@@ -41,7 +41,7 @@ describe('aria-valid-attr', function () {
});
- it('should determine attribute validity by calling commons.aria.validateAttr', function () {
+ it('should determine attribute validity by calling axe.commons.aria.validateAttr', function () {
var node = document.createElement('div');
node.id = 'test';
node.tabIndex = 1;
@@ -49,9 +49,9 @@ describe('aria-valid-attr', function () {
node.setAttribute('aria-dogs', 'true');
fixture.appendChild(node);
- var orig = commons.aria.validateAttr;
+ var orig = axe.commons.aria.validateAttr;
var called = 0;
- commons.aria.validateAttr = function (attrName) {
+ axe.commons.aria.validateAttr = function (attrName) {
assert.match(attrName, /^aria-/);
called++;
return true;
@@ -60,7 +60,7 @@ describe('aria-valid-attr', function () {
assert.isNull(checkContext._data);
assert.equal(called, 2);
- commons.aria.validateAttr = orig;
+ axe.commons.aria.validateAttr = orig;
});
describe('options', function () {
diff --git a/test/checks/color/color-contrast.js b/test/checks/color/color-contrast.js
index a76379ea02..853e3fcf1f 100644
--- a/test/checks/color/color-contrast.js
+++ b/test/checks/color/color-contrast.js
@@ -26,8 +26,8 @@ describe('color-contrast', function () {
var target = fixture.querySelector('#target');
assert.isTrue(checks['color-contrast'].evaluate.call(checkContext, target));
- var white = new commons.color.Color(255, 255, 255, 1);
- var black = new commons.color.Color(0, 0, 0, 1);
+ var white = new axe.commons.color.Color(255, 255, 255, 1);
+ var black = new axe.commons.color.Color(0, 0, 0, 1);
assert.equal(checkContext._data.bgColor, white.toHexString());
assert.equal(checkContext._data.fgColor, black.toHexString());
assert.equal(checkContext._data.contrastRatio, '21.00');
diff --git a/test/checks/color/link-in-text-block.js b/test/checks/color/link-in-text-block.js
index f2a4cfd55b..149a2ca964 100644
--- a/test/checks/color/link-in-text-block.js
+++ b/test/checks/color/link-in-text-block.js
@@ -95,17 +95,17 @@ describe('link-in-text-block', function () {
it('uses color.elementIsDistinct to test the initial state', function () {
var isCalled;
- var orig = commons.color.elementIsDistinct;
+ var orig = axe.commons.color.elementIsDistinct;
var linkElm = getLinkElm();
- commons.color.elementIsDistinct = function (arg1, arg2) {
+ axe.commons.color.elementIsDistinct = function (arg1, arg2) {
isCalled = true;
return orig(arg1, arg2);
};
checks['link-in-text-block'].evaluate(linkElm);
assert.ok(isCalled);
- commons.color.elementIsDistinct = orig;
+ axe.commons.color.elementIsDistinct = orig;
});
it('passes the selected node and closest ancestral block element', function () {
@@ -116,18 +116,18 @@ describe('link-in-text-block', function () {
' inside block
inside block' +
' outside block ';
- var orig = commons.color.elementIsDistinct;
+ var orig = axe.commons.color.elementIsDistinct;
var linkElm = document.getElementById('link');
var parentElm = document.getElementById('parent');
- commons.color.elementIsDistinct = function (arg1, arg2) {
+ axe.commons.color.elementIsDistinct = function (arg1, arg2) {
assert.deepEqual(arg1, linkElm);
assert.deepEqual(arg2, parentElm);
return orig(arg1, arg2);
};
checks['link-in-text-block'].evaluate(linkElm);
- commons.color.elementIsDistinct = orig;
+ axe.commons.color.elementIsDistinct = orig;
});
});
diff --git a/test/checks/tables/html4-scope.js b/test/checks/tables/html4-scope.js
index db04d8f608..b7de418574 100644
--- a/test/checks/tables/html4-scope.js
+++ b/test/checks/tables/html4-scope.js
@@ -7,12 +7,12 @@ describe('html4-scope', function () {
afterEach(function () {
fixture.innerHTML = '';
- commons.dom.isHTML5 = orig;
+ axe.commons.dom.isHTML5 = orig;
});
beforeEach(function () {
- orig = commons.dom.isHTML5;
- commons.dom.isHTML5 = function () {
+ orig = axe.commons.dom.isHTML5;
+ axe.commons.dom.isHTML5 = function () {
return isHTML5;
};
diff --git a/test/checks/tables/html5-scope.js b/test/checks/tables/html5-scope.js
index e2e0409e58..68054a4be0 100644
--- a/test/checks/tables/html5-scope.js
+++ b/test/checks/tables/html5-scope.js
@@ -24,8 +24,8 @@ describe('html5-scope', function () {
});
it('should return false on non-HTML5 documents', function () {
- var orig = commons.dom.isHTML5;
- commons.dom.isHTML5 = function () {
+ var orig = axe.commons.dom.isHTML5;
+ axe.commons.dom.isHTML5 = function () {
return false;
};
@@ -34,7 +34,7 @@ describe('html5-scope', function () {
assert.isFalse(checks['html5-scope'].evaluate(node));
- commons.dom.isHTML5 = orig;
+ axe.commons.dom.isHTML5 = orig;
});
});
\ No newline at end of file
diff --git a/test/commons/.jshintrc b/test/commons/.jshintrc
index 10457f12bc..2e67e46d92 100644
--- a/test/commons/.jshintrc
+++ b/test/commons/.jshintrc
@@ -8,7 +8,7 @@
"after": true,
"afterEach": true,
"chai": true,
- "commons": true,
+ "axe": true,
"assert": true
},
diff --git a/test/commons/aria/attributes.js b/test/commons/aria/attributes.js
index b8a87b774e..88f947b4b8 100644
--- a/test/commons/aria/attributes.js
+++ b/test/commons/aria/attributes.js
@@ -4,28 +4,28 @@ describe('aria.requiredAttr', function () {
var orig;
beforeEach(function () {
- orig = commons.aria._lut.role;
+ orig = axe.commons.aria._lut.role;
});
afterEach(function () {
- commons.aria._lut.role = orig;
+ axe.commons.aria._lut.role = orig;
});
it('should returned the attributes property for the proper role', function () {
- commons.aria._lut.role = {
+ axe.commons.aria._lut.role = {
'cats': {
attributes: {
required: 'yes'
}
}
};
- assert.equal(commons.aria.requiredAttr('cats'), 'yes');
+ assert.equal(axe.commons.aria.requiredAttr('cats'), 'yes');
});
it('should return an empty array if there are no required attributes', function () {
- commons.aria._lut.role = {};
- var result = commons.aria.requiredAttr('cats');
+ axe.commons.aria._lut.role = {};
+ var result = axe.commons.aria.requiredAttr('cats');
assert.deepEqual(result, []);
@@ -37,16 +37,16 @@ describe('aria.allowedAttr', function () {
var orig;
beforeEach(function () {
- orig = commons.aria._lut.role;
+ orig = axe.commons.aria._lut.role;
});
afterEach(function () {
- commons.aria._lut.role = orig;
+ axe.commons.aria._lut.role = orig;
});
it('should returned the attributes property for the proper role', function () {
- var orig = commons.aria._lut.globalAttributes = ['world'];
- commons.aria._lut.role = {
+ var orig = axe.commons.aria._lut.globalAttributes = ['world'];
+ axe.commons.aria._lut.role = {
'cats': {
attributes: {
allowed: ['hello']
@@ -54,13 +54,13 @@ describe('aria.allowedAttr', function () {
}
};
- assert.deepEqual(commons.aria.allowedAttr('cats'), ['hello', 'world']);
- commons.aria._lut.globalAttributes = orig;
+ assert.deepEqual(axe.commons.aria.allowedAttr('cats'), ['hello', 'world']);
+ axe.commons.aria._lut.globalAttributes = orig;
});
it('should also check required attributes', function () {
- var orig = commons.aria._lut.globalAttributes = ['world'];
- commons.aria._lut.role = {
+ var orig = axe.commons.aria._lut.globalAttributes = ['world'];
+ axe.commons.aria._lut.role = {
'cats': {
attributes: {
required: ['hello'],
@@ -69,19 +69,19 @@ describe('aria.allowedAttr', function () {
}
};
- assert.deepEqual(commons.aria.allowedAttr('cats'), ['ok', 'world', 'hello']);
- commons.aria._lut.globalAttributes = orig;
+ assert.deepEqual(axe.commons.aria.allowedAttr('cats'), ['ok', 'world', 'hello']);
+ axe.commons.aria._lut.globalAttributes = orig;
});
it('should return an array with globally allowed attributes', function () {
var result,
- orig = commons.aria._lut.globalAttributes = ['world'];
+ orig = axe.commons.aria._lut.globalAttributes = ['world'];
- commons.aria._lut.role = {};
- result = commons.aria.allowedAttr('cats');
+ axe.commons.aria._lut.role = {};
+ result = axe.commons.aria.allowedAttr('cats');
assert.deepEqual(result, ['world']);
- commons.aria._lut.globalAttributes = orig;
+ axe.commons.aria._lut.globalAttributes = orig;
});
});
@@ -91,36 +91,36 @@ describe('aria.validateAttr', function () {
var orig;
beforeEach(function () {
- orig = commons.aria._lut.attributes;
+ orig = axe.commons.aria._lut.attributes;
});
afterEach(function () {
- commons.aria._lut.attributes = orig;
+ axe.commons.aria._lut.attributes = orig;
});
it('should return true if attribute is found in lut', function () {
- commons.aria._lut.attributes = {
+ axe.commons.aria._lut.attributes = {
'cats': {}
};
- assert.isTrue(commons.aria.validateAttr('cats'));
+ assert.isTrue(axe.commons.aria.validateAttr('cats'));
});
it('should return false if attribute is found in lut', function () {
- commons.aria._lut.attributes = {};
+ axe.commons.aria._lut.attributes = {};
- assert.isFalse(commons.aria.validateAttr('cats'));
+ assert.isFalse(axe.commons.aria.validateAttr('cats'));
});
});
describe('aria.validateAttrValue', function () {
'use strict';
- var orig = commons.aria._lut.attributes,
+ var orig = axe.commons.aria._lut.attributes,
fixture = document.getElementById('fixture');
afterEach(function () {
- commons.aria._lut.attributes = orig;
+ axe.commons.aria._lut.attributes = orig;
fixture.innerHTML = '';
});
@@ -128,14 +128,14 @@ describe('aria.validateAttrValue', function () {
var node = document.createElement('div');
node.setAttribute('cats', 'hello');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
});
describe('schema defintions', function () {
describe('enumerated values', function () {
it('should validate against enumerated .values if present', function () {
- commons.aria._lut.attributes = {
+ axe.commons.aria._lut.attributes = {
cats: {
type: 'nmtoken',
values: ['valid']
@@ -144,15 +144,15 @@ describe('aria.validateAttrValue', function () {
var node = document.createElement('div');
node.setAttribute('cats', 'valid');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', 'invalid');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
});
it('should be case-insensitive for enumerated values', function () {
- commons.aria._lut.attributes = {
+ axe.commons.aria._lut.attributes = {
cats: {
type: 'nmtoken',
values: ['valid']
@@ -161,11 +161,11 @@ describe('aria.validateAttrValue', function () {
var node = document.createElement('div');
node.setAttribute('cats', 'vaLiD');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
});
it('should reject empty strings', function () {
- commons.aria._lut.attributes = {
+ axe.commons.aria._lut.attributes = {
cats: {
type: 'nmtoken',
values: ['valid']
@@ -174,12 +174,12 @@ describe('aria.validateAttrValue', function () {
var node = document.createElement('div');
node.setAttribute('cats', '');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
});
});
describe('idref', function () {
it('should validate the referenced node exists', function () {
- commons.aria._lut.attributes = {
+ axe.commons.aria._lut.attributes = {
cats: {
type: 'idref'
}
@@ -188,17 +188,17 @@ describe('aria.validateAttrValue', function () {
var node = document.createElement('div');
fixture.innerHTML = '';
node.setAttribute('cats', 'target');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', 'invalid');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
});
});
describe('idrefs', function () {
var node = document.createElement('div');
beforeEach(function () {
- commons.aria._lut.attributes = {
+ axe.commons.aria._lut.attributes = {
cats: {
type: 'idrefs'
}
@@ -209,7 +209,7 @@ describe('aria.validateAttrValue', function () {
node.setAttribute('cats', 'invalid');
// target2 not found
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
});
it('should return false when a referenced element is not found', function () {
@@ -217,40 +217,40 @@ describe('aria.validateAttrValue', function () {
fixture.innerHTML = '';
node.setAttribute('cats', 'target target2');
// target2 not found
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
});
it('should return true when all targets are found', function () {
fixture.innerHTML = '';
node.setAttribute('cats', 'target target2');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
});
it('should not fail on weird whitespace', function () {
fixture.innerHTML = '';
node.setAttribute('cats', ' \t \ttarget \t target2 ');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
});
});
describe('string', function () {
it('should always return true', function () {
- commons.aria._lut.attributes = {
+ axe.commons.aria._lut.attributes = {
cats: {
type: 'string'
}
};
var node = document.createElement('div');
node.setAttribute('cats', 'hi');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
});
});
describe('decimal', function () {
var node = document.createElement('div');
beforeEach(function () {
- commons.aria._lut.attributes = {
+ axe.commons.aria._lut.attributes = {
cats: {
type: 'decimal'
}
@@ -259,91 +259,91 @@ describe('aria.validateAttrValue', function () {
it('should allow, but not require, a preceeding sign', function () {
node.setAttribute('cats', '+1.12');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '-1.12');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '1.12');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
});
it('should make the decimal separator optional', function () {
node.setAttribute('cats', '+1');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '-1');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '1');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
});
it('should make the whole number optional', function () {
node.setAttribute('cats', '+.1');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '-.1');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '.1');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
});
it('should make the right-side optional', function () {
node.setAttribute('cats', '+1.');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '-1.');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '1.');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
});
it('should validate the entire string', function () {
node.setAttribute('cats', ' +1.12 ');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', 'invalid +1.12');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '+1.12 invalid');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
});
it('should only allow for numbers', function () {
node.setAttribute('cats', '+a.12');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '+1.b');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', 'b1.1');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
});
it('should require at least one number', function () {
node.setAttribute('cats', '+.');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '-.');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '+');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '-');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '.');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '');
- assert.isFalse(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isFalse(axe.commons.aria.validateAttrValue(node, 'cats'));
});
});
@@ -351,7 +351,7 @@ describe('aria.validateAttrValue', function () {
describe('int', function () {
var node = document.createElement('div');
beforeEach(function () {
- commons.aria._lut.attributes = {
+ axe.commons.aria._lut.attributes = {
cats: {
type: 'int'
}
@@ -361,13 +361,13 @@ describe('aria.validateAttrValue', function () {
it('should only allow for numbers by an optional preceeding sign', function () {
node.setAttribute('cats', '+1234234');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '-137456745');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
node.setAttribute('cats', '1234523452');
- assert.isTrue(commons.aria.validateAttrValue(node, 'cats'));
+ assert.isTrue(axe.commons.aria.validateAttrValue(node, 'cats'));
});
});
});
diff --git a/test/commons/aria/label.js b/test/commons/aria/label.js
index 5609a575c7..cad00f3b71 100644
--- a/test/commons/aria/label.js
+++ b/test/commons/aria/label.js
@@ -12,7 +12,7 @@ describe('aria.label', function() {
'';
var target = document.getElementById('target');
- assert.equal(commons.text.label(target), 'monkeys bananas');
+ assert.equal(axe.commons.text.label(target), 'monkeys bananas');
});
it('should filter invisible elements', function() {
@@ -20,7 +20,7 @@ describe('aria.label', function() {
'';
var target = document.getElementById('target');
- assert.equal(commons.text.label(target), 'monkeys');
+ assert.equal(axe.commons.text.label(target), 'monkeys');
});
it('should take precedence over aria-label', function() {
@@ -28,7 +28,7 @@ describe('aria.label', function() {
'';
var target = document.getElementById('target');
- assert.equal(commons.text.label(target), 'monkeys bananas');
+ assert.equal(axe.commons.text.label(target), 'monkeys bananas');
});
it('should ignore whitespace only labels', function() {
@@ -36,7 +36,7 @@ describe('aria.label', function() {
'';
var target = document.getElementById('target');
- assert.isNull(commons.text.label(target));
+ assert.isNull(axe.commons.text.label(target));
});
});
@@ -45,14 +45,14 @@ describe('aria.label', function() {
fixture.innerHTML = '';
var target = document.getElementById('target');
- assert.equal(commons.text.label(target), 'monkeys');
+ assert.equal(axe.commons.text.label(target), 'monkeys');
});
it('should ignore whitespace only labels', function() {
fixture.innerHTML = '';
var target = document.getElementById('target');
- assert.isNull(commons.text.label(target));
+ assert.isNull(axe.commons.text.label(target));
});
});
});
diff --git a/test/commons/aria/roles.js b/test/commons/aria/roles.js
index e9d28c08e9..fd1f01b3f3 100644
--- a/test/commons/aria/roles.js
+++ b/test/commons/aria/roles.js
@@ -3,17 +3,17 @@ describe('aria.isValidRole', function () {
'use strict';
it('should return true if role is found in the lookup table', function () {
- var orig = commons.aria._lut.role;
- commons.aria._lut.role = {
+ var orig = axe.commons.aria._lut.role;
+ axe.commons.aria._lut.role = {
'cats': true
};
- assert.isTrue(commons.aria.isValidRole('cats'));
- commons.aria._lut.role = orig;
+ assert.isTrue(axe.commons.aria.isValidRole('cats'));
+ axe.commons.aria._lut.role = orig;
});
it('should return false if role is not found in the lut', function () {
- assert.isFalse(commons.aria.isValidRole('cats'));
+ assert.isFalse(axe.commons.aria.isValidRole('cats'));
});
});
@@ -22,8 +22,8 @@ describe('aria.getRolesWithNameFromContents', function () {
'use strict';
it('should return array if nameFrom contents is found in the lookup table', function () {
- var orig = commons.aria._lut.role;
- commons.aria._lut.role = {
+ var orig = axe.commons.aria._lut.role;
+ axe.commons.aria._lut.role = {
'dogs': {
type: 'things',
nameFrom: ['author', 'contents']
@@ -33,8 +33,8 @@ describe('aria.getRolesWithNameFromContents', function () {
nameFrom: ['author']
}
};
- assert.deepEqual(commons.aria.getRolesWithNameFromContents(), ['dogs']);
- commons.aria._lut.role = orig;
+ assert.deepEqual(axe.commons.aria.getRolesWithNameFromContents(), ['dogs']);
+ axe.commons.aria._lut.role = orig;
});
});
@@ -43,8 +43,8 @@ describe('aria.getRolesByType', function () {
'use strict';
it('should return array if roletype is found in the lookup table', function () {
- var orig = commons.aria._lut.role;
- commons.aria._lut.role = {
+ var orig = axe.commons.aria._lut.role;
+ axe.commons.aria._lut.role = {
'dogs': {
type: 'things'
},
@@ -52,13 +52,13 @@ describe('aria.getRolesByType', function () {
type: 'stuff'
}
};
- assert.deepEqual(commons.aria.getRolesByType('stuff'), ['cats']);
- commons.aria._lut.role = orig;
+ assert.deepEqual(axe.commons.aria.getRolesByType('stuff'), ['cats']);
+ axe.commons.aria._lut.role = orig;
});
it('should return empty array if role is not found in the lut', function () {
- assert.deepEqual(commons.aria.getRolesByType('blahblahblah'), []);
+ assert.deepEqual(axe.commons.aria.getRolesByType('blahblahblah'), []);
});
});
@@ -66,19 +66,19 @@ describe('aria.getRoleType', function () {
'use strict';
it('should return true if role is found in the lookup table', function () {
- var orig = commons.aria._lut.role;
- commons.aria._lut.role = {
+ var orig = axe.commons.aria._lut.role;
+ axe.commons.aria._lut.role = {
'cats': {
type: 'stuff'
}
};
- assert.equal(commons.aria.getRoleType('cats'), 'stuff');
- commons.aria._lut.role = orig;
+ assert.equal(axe.commons.aria.getRoleType('cats'), 'stuff');
+ axe.commons.aria._lut.role = orig;
});
it('should return null if role is not found in the lut', function () {
- assert.isNull(commons.aria.getRoleType('cats'));
+ assert.isNull(axe.commons.aria.getRoleType('cats'));
});
});
@@ -87,26 +87,26 @@ describe('aria.requiredOwned', function () {
var orig;
beforeEach(function () {
- orig = commons.aria._lut.role;
+ orig = axe.commons.aria._lut.role;
});
afterEach(function () {
- commons.aria._lut.role = orig;
+ axe.commons.aria._lut.role = orig;
});
it('should returned the owned property for the proper role', function () {
- commons.aria._lut.role = {
+ axe.commons.aria._lut.role = {
'cats': {
owned: 'yes'
}
};
- assert.equal(commons.aria.requiredOwned('cats'), 'yes');
+ assert.equal(axe.commons.aria.requiredOwned('cats'), 'yes');
});
it('should return null if there are no required owned nodes', function () {
- commons.aria._lut.role = {};
- var result = commons.aria.requiredOwned('cats');
+ axe.commons.aria._lut.role = {};
+ var result = axe.commons.aria.requiredOwned('cats');
assert.isNull(result);
@@ -118,26 +118,26 @@ describe('aria.requiredContext', function () {
var orig;
beforeEach(function () {
- orig = commons.aria._lut.role;
+ orig = axe.commons.aria._lut.role;
});
afterEach(function () {
- commons.aria._lut.role = orig;
+ axe.commons.aria._lut.role = orig;
});
it('should returned the context property for the proper role', function () {
- commons.aria._lut.role = {
+ axe.commons.aria._lut.role = {
'cats': {
context: 'yes'
}
};
- assert.equal(commons.aria.requiredContext('cats'), 'yes');
+ assert.equal(axe.commons.aria.requiredContext('cats'), 'yes');
});
it('should return null if there are no required context nodes', function () {
- commons.aria._lut.role = {};
- var result = commons.aria.requiredContext('cats');
+ axe.commons.aria._lut.role = {};
+ var result = axe.commons.aria.requiredContext('cats');
assert.isNull(result);
@@ -149,26 +149,26 @@ describe('aria.implicitNodes', function () {
var orig;
beforeEach(function () {
- orig = commons.aria._lut.role;
+ orig = axe.commons.aria._lut.role;
});
afterEach(function () {
- commons.aria._lut.role = orig;
+ axe.commons.aria._lut.role = orig;
});
it('should return the implicit property for the proper role', function () {
- commons.aria._lut.role = {
+ axe.commons.aria._lut.role = {
'cats': {
implicit: 'yes'
}
};
- assert.equal(commons.aria.implicitNodes('cats'), 'yes');
+ assert.equal(axe.commons.aria.implicitNodes('cats'), 'yes');
});
it('should return null if there are no implicit roles', function () {
- commons.aria._lut.role = {};
- var result = commons.aria.implicitNodes('cats');
+ axe.commons.aria._lut.role = {};
+ var result = axe.commons.aria.implicitNodes('cats');
assert.isNull(result);
@@ -181,12 +181,12 @@ describe('aria.implicitRole', function () {
var fixture = document.getElementById('fixture');
var orig;
beforeEach(function () {
- orig = commons.aria._lut.role;
+ orig = axe.commons.aria._lut.role;
});
afterEach(function () {
fixture.innerHTML = '';
- commons.aria._lut.role = orig;
+ axe.commons.aria._lut.role = orig;
});
it('should find the first matching role', function () {
@@ -194,12 +194,12 @@ describe('aria.implicitRole', function () {
node.id = 'cats';
fixture.appendChild(node);
- commons.aria._lut.role = {
+ axe.commons.aria._lut.role = {
'cats': {
implicit: ['div[id="cats"]']
}
};
- assert.equal(commons.aria.implicitRole(node), 'cats');
+ assert.equal(axe.commons.aria.implicitRole(node), 'cats');
});
@@ -208,8 +208,8 @@ describe('aria.implicitRole', function () {
node.id = 'cats';
fixture.appendChild(node);
- commons.aria._lut.role = {};
- var result = commons.aria.implicitRole(node);
+ axe.commons.aria._lut.role = {};
+ var result = axe.commons.aria.implicitRole(node);
assert.isNull(result);
diff --git a/test/commons/color/contrast.js b/test/commons/color/contrast.js
index abee91f04a..5980145538 100644
--- a/test/commons/color/contrast.js
+++ b/test/commons/color/contrast.js
@@ -2,7 +2,7 @@ describe('color.Color', function () {
'use strict';
it('should set values properly via RGB', function () {
- var c = new commons.color.Color();
+ var c = new axe.commons.color.Color();
c.parseRgbString('rgb(17, 34, 51)');
assert.equal(c.red, 17);
assert.equal(c.green, 34);
@@ -11,7 +11,7 @@ describe('color.Color', function () {
});
it('should set values properly via RGBA', function () {
- var c = new commons.color.Color();
+ var c = new axe.commons.color.Color();
c.parseRgbString('rgba(17, 34, 51, 0)');
assert.equal(c.red, 17);
assert.equal(c.green, 34);
@@ -20,11 +20,11 @@ describe('color.Color', function () {
});
it('should return hex values properly', function () {
- var black = new commons.color.Color(0, 0, 0, 1);
- var white = new commons.color.Color(255, 255, 255, 1);
- var yellow = new commons.color.Color(255, 255, 0, 1);
- var darkyellow = new commons.color.Color(128, 128, 0, 1);
- var blue = new commons.color.Color(0, 0, 255, 1);
+ var black = new axe.commons.color.Color(0, 0, 0, 1);
+ var white = new axe.commons.color.Color(255, 255, 255, 1);
+ var yellow = new axe.commons.color.Color(255, 255, 0, 1);
+ var darkyellow = new axe.commons.color.Color(128, 128, 0, 1);
+ var blue = new axe.commons.color.Color(0, 0, 255, 1);
assert.equal(black.toHexString(), '#000000');
assert.equal(white.toHexString(), '#ffffff');
assert.equal(yellow.toHexString(), '#ffff00');
@@ -34,19 +34,19 @@ describe('color.Color', function () {
});
it('should return hex values properly when they are non-integery', function () {
- var black = new commons.color.Color(0, 0, 0, 1);
- var white = new commons.color.Color(255, 255, 255, 0.1);
- var grayish = commons.color.flattenColors(white, black);
+ var black = new axe.commons.color.Color(0, 0, 0, 1);
+ var white = new axe.commons.color.Color(255, 255, 255, 0.1);
+ var grayish = axe.commons.color.flattenColors(white, black);
assert.equal(grayish.toHexString(), '#1a1a1a');
});
it('should calculate luminance sensibly', function () {
- var black = new commons.color.Color(0, 0, 0, 1);
- var white = new commons.color.Color(255, 255, 255, 1);
- var yellow = new commons.color.Color(255, 255, 0, 1);
- var darkyellow = new commons.color.Color(128, 128, 0, 1);
- var blue = new commons.color.Color(0, 0, 255, 1);
+ var black = new axe.commons.color.Color(0, 0, 0, 1);
+ var white = new axe.commons.color.Color(255, 255, 255, 1);
+ var yellow = new axe.commons.color.Color(255, 255, 0, 1);
+ var darkyellow = new axe.commons.color.Color(128, 128, 0, 1);
+ var blue = new axe.commons.color.Color(0, 0, 255, 1);
var lBlack = black.getRelativeLuminance();
var lWhite = white.getRelativeLuminance();
var lYellow = yellow.getRelativeLuminance();
@@ -65,63 +65,63 @@ describe('color.Color', function () {
});
it('should calculate contrast sensibly', function () {
- var black = new commons.color.Color(0, 0, 0, 1);
- var transparent = new commons.color.Color(0, 0, 0, 0);
- var white = new commons.color.Color(255, 255, 255, 1);
- var yellow = new commons.color.Color(255, 255, 0, 1);
+ var black = new axe.commons.color.Color(0, 0, 0, 1);
+ var transparent = new axe.commons.color.Color(0, 0, 0, 0);
+ var white = new axe.commons.color.Color(255, 255, 255, 1);
+ var yellow = new axe.commons.color.Color(255, 255, 0, 1);
//Same foreground/background gives 1
- assert.equal(commons.color.getContrast(black, black), 1);
- assert.equal(commons.color.getContrast(transparent, black), 1);
- assert.equal(commons.color.getContrast(white, white), 1);
- assert.equal(commons.color.getContrast(yellow, yellow), 1);
+ assert.equal(axe.commons.color.getContrast(black, black), 1);
+ assert.equal(axe.commons.color.getContrast(transparent, black), 1);
+ assert.equal(axe.commons.color.getContrast(white, white), 1);
+ assert.equal(axe.commons.color.getContrast(yellow, yellow), 1);
//contrast ratio is reversible
- assert.equal(commons.color.getContrast(yellow, black), commons.color.getContrast(black, yellow));
- assert.equal(commons.color.getContrast(yellow, white), commons.color.getContrast(white, yellow));
+ assert.equal(axe.commons.color.getContrast(yellow, black), axe.commons.color.getContrast(black, yellow));
+ assert.equal(axe.commons.color.getContrast(yellow, white), axe.commons.color.getContrast(white, yellow));
//things that are more contrasty return higher values than things that are less contrasty
- assert.isTrue(commons.color.getContrast(yellow, white) < commons.color.getContrast(yellow, black));
- assert.isTrue(commons.color.getContrast(yellow, black) < commons.color.getContrast(white, black));
+ assert.isTrue(axe.commons.color.getContrast(yellow, white) < axe.commons.color.getContrast(yellow, black));
+ assert.isTrue(axe.commons.color.getContrast(yellow, black) < axe.commons.color.getContrast(white, black));
});
it('should flatten colors properly', function () {
- var halfblack = new commons.color.Color(0, 0, 0, 0.5);
- var fullblack = new commons.color.Color(0, 0, 0, 1);
- var transparent = new commons.color.Color(0, 0, 0, 0);
- var white = new commons.color.Color(255, 255, 255, 1);
- var gray = new commons.color.Color(127.5, 127.5, 127.5, 1);
- var flat = commons.color.flattenColors(halfblack, white);
+ var halfblack = new axe.commons.color.Color(0, 0, 0, 0.5);
+ var fullblack = new axe.commons.color.Color(0, 0, 0, 1);
+ var transparent = new axe.commons.color.Color(0, 0, 0, 0);
+ var white = new axe.commons.color.Color(255, 255, 255, 1);
+ var gray = new axe.commons.color.Color(127.5, 127.5, 127.5, 1);
+ var flat = axe.commons.color.flattenColors(halfblack, white);
assert.equal(flat.red, gray.red);
assert.equal(flat.green, gray.green);
assert.equal(flat.blue, gray.blue);
- var flat2 = commons.color.flattenColors(fullblack, white);
+ var flat2 = axe.commons.color.flattenColors(fullblack, white);
assert.equal(flat2.red, fullblack.red);
assert.equal(flat2.green, fullblack.green);
assert.equal(flat2.blue, fullblack.blue);
- var flat3 = commons.color.flattenColors(transparent, white);
+ var flat3 = axe.commons.color.flattenColors(transparent, white);
assert.equal(flat3.red, white.red);
assert.equal(flat3.green, white.green);
assert.equal(flat3.blue, white.blue);
});
it('should give sensible results for WCAG compliance', function () {
- var black = new commons.color.Color(0, 0, 0, 1);
- var white = new commons.color.Color(255, 255, 255, 1);
- var gray = new commons.color.Color(128, 128, 128, 1);
-
- assert.isTrue(commons.color.hasValidContrastRatio(black, white, 8, false).isValid);
- assert.isTrue(commons.color.hasValidContrastRatio(black, white, 8, false).contrastRatio > 4.5);
- assert.isFalse(commons.color.hasValidContrastRatio(black, black, 16, true).isValid);
- assert.isTrue(commons.color.hasValidContrastRatio(black, black, 16, true).contrastRatio < 3);
- assert.isTrue(commons.color.hasValidContrastRatio(white, gray, 24, false).isValid);
- assert.isTrue(commons.color.hasValidContrastRatio(white, gray, 24, false).contrastRatio > 3);
- assert.isTrue(commons.color.hasValidContrastRatio(white, gray, 20, true).isValid);
- assert.isTrue(commons.color.hasValidContrastRatio(white, gray, 20, true).contrastRatio > 3);
- assert.isFalse(commons.color.hasValidContrastRatio(white, gray, 8, false).isValid);
- assert.isTrue(commons.color.hasValidContrastRatio(white, gray, 8, false).contrastRatio < 4.5);
+ var black = new axe.commons.color.Color(0, 0, 0, 1);
+ var white = new axe.commons.color.Color(255, 255, 255, 1);
+ var gray = new axe.commons.color.Color(128, 128, 128, 1);
+
+ assert.isTrue(axe.commons.color.hasValidContrastRatio(black, white, 8, false).isValid);
+ assert.isTrue(axe.commons.color.hasValidContrastRatio(black, white, 8, false).contrastRatio > 4.5);
+ assert.isFalse(axe.commons.color.hasValidContrastRatio(black, black, 16, true).isValid);
+ assert.isTrue(axe.commons.color.hasValidContrastRatio(black, black, 16, true).contrastRatio < 3);
+ assert.isTrue(axe.commons.color.hasValidContrastRatio(white, gray, 24, false).isValid);
+ assert.isTrue(axe.commons.color.hasValidContrastRatio(white, gray, 24, false).contrastRatio > 3);
+ assert.isTrue(axe.commons.color.hasValidContrastRatio(white, gray, 20, true).isValid);
+ assert.isTrue(axe.commons.color.hasValidContrastRatio(white, gray, 20, true).contrastRatio > 3);
+ assert.isFalse(axe.commons.color.hasValidContrastRatio(white, gray, 8, false).isValid);
+ assert.isTrue(axe.commons.color.hasValidContrastRatio(white, gray, 8, false).contrastRatio < 4.5);
});
});
diff --git a/test/commons/color/element-is-distinct.js b/test/commons/color/element-is-distinct.js
index 9a835a5e29..777f379f9b 100644
--- a/test/commons/color/element-is-distinct.js
+++ b/test/commons/color/element-is-distinct.js
@@ -16,7 +16,7 @@ describe('color.elementIsDistinct', function () {
beforeEach(function () {
createStyleString('p', defaultStyle);
- elementIsDistinct = commons.color.elementIsDistinct;
+ elementIsDistinct = axe.commons.color.elementIsDistinct;
});
afterEach(function () {
diff --git a/test/commons/color/get-background-color.js b/test/commons/color/get-background-color.js
index e3c162885e..f6457b74bc 100644
--- a/test/commons/color/get-background-color.js
+++ b/test/commons/color/get-background-color.js
@@ -14,8 +14,8 @@ describe('color.getBackgroundColor', function () {
var target = fixture.querySelector('#target');
var parent = fixture.querySelector('#parent');
var bgNodes = [];
- var actual = commons.color.getBackgroundColor(target, bgNodes);
- var expected = new commons.color.Color(128, 0, 0, 1);
+ 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);
assert.closeTo(actual.green, expected.green, 0.5);
assert.closeTo(actual.blue, expected.blue, 0.5);
@@ -36,9 +36,9 @@ describe('color.getBackgroundColor', function () {
var target = fixture.querySelector('#target');
var pos = fixture.querySelector('#pos');
var bgNodes = [];
- var actual = commons.color.getBackgroundColor(target, bgNodes);
- var expected = new commons.color.Color(64, 64, 0, 1);
- if (commons.dom.supportsElementsFromPoint(document)) {
+ var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
+ var expected = new axe.commons.color.Color(64, 64, 0, 1);
+ if (axe.commons.dom.supportsElementsFromPoint(document)) {
assert.closeTo(actual.red, expected.red, 0.5);
assert.closeTo(actual.green, expected.green, 0.5);
assert.closeTo(actual.blue, expected.blue, 0.5);
@@ -57,8 +57,8 @@ describe('color.getBackgroundColor', function () {
var target = fixture.querySelector('#target');
var under = fixture.querySelector('#under');
var bgNodes = [];
- var actual = commons.color.getBackgroundColor(target, bgNodes);
- var expected = new commons.color.Color(64, 64, 0, 1);
+ 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);
assert.closeTo(actual.green, expected.green, 0.5);
assert.closeTo(actual.blue, expected.blue, 0.5);
@@ -81,9 +81,9 @@ describe('color.getBackgroundColor', function () {
var target = fixture.querySelector('#target');
var under = fixture.querySelector('#under');
var bgNodes = [];
- var actual = commons.color.getBackgroundColor(target, bgNodes);
- var expected = new commons.color.Color(64, 64, 0, 1);
- if (commons.dom.supportsElementsFromPoint(document)) {
+ var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
+ var expected = new axe.commons.color.Color(64, 64, 0, 1);
+ if (axe.commons.dom.supportsElementsFromPoint(document)) {
assert.closeTo(actual.red, expected.red, 0.5);
assert.closeTo(actual.green, expected.green, 0.5);
assert.closeTo(actual.blue, expected.blue, 0.5);
@@ -101,8 +101,8 @@ describe('color.getBackgroundColor', function () {
var target = fixture.querySelector('#target');
var parent = fixture.querySelector('#parent');
var bgNodes = [];
- var actual = commons.color.getBackgroundColor(target, bgNodes);
- var expected = new commons.color.Color(64, 64, 0, 1);
+ 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);
assert.closeTo(actual.green, expected.green, 0.5);
assert.closeTo(actual.blue, expected.blue, 0.5);
@@ -117,8 +117,8 @@ describe('color.getBackgroundColor', function () {
var target = fixture.querySelector('#target');
var parent = fixture.querySelector('#parent');
var bgNodes = [];
- var actual = commons.color.getBackgroundColor(target, bgNodes);
- var expected = new commons.color.Color(64, 64, 0, 1);
+ 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);
assert.equal(actual.green, expected.green);
assert.equal(actual.blue, expected.blue);
@@ -134,7 +134,7 @@ describe('color.getBackgroundColor', function () {
var target = fixture.querySelector('#target');
var parent = fixture.querySelector('#parent');
var bgNodes = [];
- var actual = commons.color.getBackgroundColor(target, bgNodes);
+ var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
assert.isNull(actual);
assert.deepEqual(bgNodes, [target, parent]);
});
@@ -146,7 +146,7 @@ describe('color.getBackgroundColor', function () {
'';
var target = fixture.querySelector('#target');
var bgNodes = [];
- var actual = commons.color.getBackgroundColor(target, bgNodes);
+ var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
assert.isNull(actual);
assert.deepEqual(bgNodes, [target]);
});
@@ -155,8 +155,8 @@ 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');
- var actual = commons.color.getBackgroundColor(target);
- var expected = new commons.color.Color(255, 255, 255, 1);
+ var actual = axe.commons.color.getBackgroundColor(target);
+ var expected = new axe.commons.color.Color(255, 255, 255, 1);
assert.equal(actual.red, expected.red);
assert.equal(actual.green, expected.green);
assert.equal(actual.blue, expected.blue);
@@ -169,7 +169,7 @@ describe('color.getBackgroundColor', function () {
'
';
var target = fixture.querySelector('#target');
var bgNodes = [];
- var actual = commons.color.getBackgroundColor(target, bgNodes);
+ var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
assert.isNull(actual);
assert.deepEqual(bgNodes, [target]);
});
@@ -177,7 +177,7 @@ describe('color.getBackgroundColor', function () {
it('should return null if something is obscuring it', function () {
fixture.innerHTML = '' +
'
Hello
';
- var actual = commons.color.getBackgroundColor(document.getElementById('target'), []);
+ var actual = axe.commons.color.getBackgroundColor(document.getElementById('target'), []);
assert.isNull(actual);
});
@@ -188,8 +188,8 @@ describe('color.getBackgroundColor', function () {
'';
var target = fixture.querySelector('#target');
var bgNodes = [];
- var actual = commons.color.getBackgroundColor(target, bgNodes);
- var expected = new commons.color.Color(0, 128, 0, 1);
+ 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);
assert.equal(actual.green, expected.green);
assert.equal(actual.blue, expected.blue);
@@ -207,8 +207,8 @@ describe('color.getBackgroundColor', function () {
var target = fixture.querySelector('#target');
var parent = fixture.querySelector('#parent');
var bgNodes = [];
- var actual = commons.color.getBackgroundColor(target, bgNodes);
- var expected = new commons.color.Color(255, 255, 255, 1);
+ var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
+ var expected = new axe.commons.color.Color(255, 255, 255, 1);
assert.closeTo(actual.red, expected.red, 0.5);
assert.closeTo(actual.green, expected.green, 0.5);
assert.closeTo(actual.blue, expected.blue, 0.5);
@@ -226,9 +226,9 @@ describe('color.getBackgroundColor', function () {
var target = fixture.querySelector('#target');
var parent = fixture.querySelector('#parent');
var bgNodes = [];
- var actual = commons.color.getBackgroundColor(target, bgNodes);
+ var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
- var expected = new commons.color.Color(255, 255, 255, 1);
+ var expected = new axe.commons.color.Color(255, 255, 255, 1);
assert.closeTo(actual.red, expected.red, 0.5);
assert.closeTo(actual.green, expected.green, 0.5);
assert.closeTo(actual.blue, expected.blue, 0.5);
@@ -247,12 +247,12 @@ describe('color.getBackgroundColor', function () {
var shifted = fixture.querySelector('#shifted');
var parent = fixture.querySelector('#parent');
var bgNodes = [];
- var actual = commons.color.getBackgroundColor(target, bgNodes, false);
- var expected = new commons.color.Color(0, 0, 0, 1);
- if (commons.dom.supportsElementsFromPoint(document)) {
+ var actual = axe.commons.color.getBackgroundColor(target, bgNodes, false);
+ var expected = new axe.commons.color.Color(0, 0, 0, 1);
+ if (axe.commons.dom.supportsElementsFromPoint(document)) {
assert.deepEqual(bgNodes, [shifted]);
} else {
- expected = new commons.color.Color(255, 255, 255, 1);
+ expected = new axe.commons.color.Color(255, 255, 255, 1);
assert.deepEqual(bgNodes, [parent]);
}
assert.closeTo(actual.red, expected.red, 0.5);
@@ -275,7 +275,7 @@ describe('color.getBackgroundColor', function () {
var target = fixture.querySelector('#target');
var bgNodes = [];
- var outcome = commons.color.getBackgroundColor(target, bgNodes, false);
+ var outcome = axe.commons.color.getBackgroundColor(target, bgNodes, false);
assert.isNull(outcome);
});
@@ -293,7 +293,7 @@ describe('color.getBackgroundColor', function () {
var target = fixture.querySelector('#target');
var bgNodes = [];
- var outcome = commons.color.getBackgroundColor(target, bgNodes, false);
+ var outcome = axe.commons.color.getBackgroundColor(target, bgNodes, false);
assert.isNull(outcome);
});
@@ -306,7 +306,7 @@ describe('color.getBackgroundColor', function () {
var bgNodes = [];
window.scroll(0, 0);
- commons.color.getBackgroundColor(targetEl, bgNodes, true);
+ axe.commons.color.getBackgroundColor(targetEl, bgNodes, true);
assert.equal(window.pageYOffset, 0);
});
@@ -320,7 +320,7 @@ describe('color.getBackgroundColor', function () {
var bgNodes = [];
window.scroll(0, 0);
- commons.color.getBackgroundColor(targetEl, bgNodes, false);
+ axe.commons.color.getBackgroundColor(targetEl, bgNodes, false);
assert.notEqual(window.pageYOffset, 0);
});
diff --git a/test/commons/color/get-foreground-color.js b/test/commons/color/get-foreground-color.js
index 642e2251b3..fc1b168f47 100644
--- a/test/commons/color/get-foreground-color.js
+++ b/test/commons/color/get-foreground-color.js
@@ -14,8 +14,8 @@ describe('color.getForegroundColor', function () {
'This is my text' +
'';
var target = fixture.querySelector('#target');
- var actual = commons.color.getForegroundColor(target, true);
- var expected = new commons.color.Color(32, 32, 64, 1);
+ var actual = axe.commons.color.getForegroundColor(target, true);
+ var expected = new axe.commons.color.Color(32, 32, 64, 1);
assert.closeTo(actual.red, expected.red, 0.8);
assert.closeTo(actual.green, expected.green, 0.8);
assert.closeTo(actual.blue, expected.blue, 0.8);
@@ -29,8 +29,8 @@ describe('color.getForegroundColor', function () {
'This is my text' +
'';
var target = fixture.querySelector('#target');
- var actual = commons.color.getForegroundColor(target, true);
- var expected = new commons.color.Color(32, 32, 64, 1);
+ var actual = axe.commons.color.getForegroundColor(target, true);
+ var expected = new axe.commons.color.Color(32, 32, 64, 1);
assert.equal(actual.red, expected.red);
assert.equal(actual.green, expected.green);
assert.equal(actual.blue, expected.blue);
@@ -43,7 +43,7 @@ describe('color.getForegroundColor', function () {
'
' +
'
';
var target = fixture.querySelector('#target');
- var actual = commons.color.getForegroundColor(target, true);
+ var actual = axe.commons.color.getForegroundColor(target, true);
assert.isNull(actual);
});
@@ -52,8 +52,8 @@ describe('color.getForegroundColor', function () {
'
' +
'
';
var target = fixture.querySelector('#target');
- var actual = commons.color.getForegroundColor(target, true);
- var expected = new commons.color.Color(0, 0, 128, 1);
+ var actual = axe.commons.color.getForegroundColor(target, true);
+ var expected = new axe.commons.color.Color(0, 0, 128, 1);
assert.equal(actual.red, expected.red);
assert.equal(actual.green, expected.green);
assert.equal(actual.blue, expected.blue);
diff --git a/test/commons/dom/elements-from-point.js b/test/commons/dom/elements-from-point.js
index 767e929c73..02dcab2454 100644
--- a/test/commons/dom/elements-from-point.js
+++ b/test/commons/dom/elements-from-point.js
@@ -24,8 +24,8 @@ describe('dom.elementsFromPoint', function () {
target.scrollIntoView();
var rect = target.getBoundingClientRect();
- if (commons.dom.supportsElementsFromPoint(document)) {
- var visualParents = commons.dom.elementsFromPoint(document,
+ if (axe.commons.dom.supportsElementsFromPoint(document)) {
+ var visualParents = axe.commons.dom.elementsFromPoint(document,
Math.ceil(rect.left + 1),
Math.ceil(rect.top + 1));
assert.deepEqual(visualParents.slice(0, 3), [target, pos, container]);
@@ -49,8 +49,8 @@ describe('dom.elementsFromPoint', function () {
target.scrollIntoView();
var rect = target.getBoundingClientRect();
- if (commons.dom.supportsElementsFromPoint(document)) {
- var visualParents = commons.dom.elementsFromPoint(document,
+ if (axe.commons.dom.supportsElementsFromPoint(document)) {
+ var visualParents = axe.commons.dom.elementsFromPoint(document,
Math.ceil(rect.left + 1),
Math.ceil(rect.top + 1));
assert.deepEqual(visualParents.slice(0, 3), [target, pos, container]);
@@ -67,8 +67,8 @@ describe('dom.elementsFromPoint', function () {
target.scrollIntoView();
var rect = target.getBoundingClientRect();
- if (commons.dom.supportsElementsFromPoint(document)) {
- var visualParents = commons.dom.elementsFromPoint(document, Math.ceil(rect.left), Math.ceil(rect.top));
+ if (axe.commons.dom.supportsElementsFromPoint(document)) {
+ var visualParents = axe.commons.dom.elementsFromPoint(document, Math.ceil(rect.left), Math.ceil(rect.top));
assert.deepEqual(visualParents.slice(0, 3), [target, parent, fixture]);
}
});
@@ -83,12 +83,12 @@ describe('dom.elementsFromPoint', function () {
var rect = target.getBoundingClientRect();
var visualParents = null;
- if (commons.dom.supportsElementsFromPoint(document)) {
+ if (axe.commons.dom.supportsElementsFromPoint(document)) {
if (!document.msElementsFromPoint) {
document.msElementsFromPoint = function () {
return ['a', 'b', 'c'];
};
- visualParents = commons.dom.elementsFromPoint(document, Math.ceil(rect.left), Math.ceil(rect.top));
+ visualParents = axe.commons.dom.elementsFromPoint(document, Math.ceil(rect.left), Math.ceil(rect.top));
delete document.msElementsFromPoint;
assert.deepEqual(visualParents.slice(0, 3), ['a', 'b', 'c']);
}
diff --git a/test/commons/dom/find-up.js b/test/commons/dom/find-up.js
index fdb9d3a0d7..dc8ca459de 100644
--- a/test/commons/dom/find-up.js
+++ b/test/commons/dom/find-up.js
@@ -14,7 +14,7 @@ describe('dom.findUp', function () {
var start = document.getElementById('start'),
target = document.getElementById('target');
- assert.equal(commons.dom.findUp(start, '.target'), target, 'Should find it!');
+ assert.equal(axe.commons.dom.findUp(start, '.target'), target, 'Should find it!');
});
@@ -23,7 +23,7 @@ describe('dom.findUp', function () {
fixture.innerHTML = '';
var start = document.getElementById('start');
- assert.isNull(commons.dom.findUp(start, '.nomatchyplzkthx'));
+ assert.isNull(axe.commons.dom.findUp(start, '.nomatchyplzkthx'));
});
@@ -31,7 +31,7 @@ describe('dom.findUp', function () {
fixture.innerHTML = '';
var start = document.getElementById('start');
- assert.isNull(commons.dom.findUp(start, '.target'));
+ assert.isNull(axe.commons.dom.findUp(start, '.target'));
});
});
\ No newline at end of file
diff --git a/test/commons/dom/get-element-by-reference.js b/test/commons/dom/get-element-by-reference.js
index 62ffd59621..b351636f4e 100644
--- a/test/commons/dom/get-element-by-reference.js
+++ b/test/commons/dom/get-element-by-reference.js
@@ -11,7 +11,7 @@ describe('dom.getElementByReference', function () {
it('should return null if the attribute is not found', function () {
fixture.innerHTML = 'Hi';
var node = document.getElementById('link'),
- result = commons.dom.getElementByReference(node, 'usemap');
+ result = axe.commons.dom.getElementByReference(node, 'usemap');
assert.isNull(result);
@@ -20,7 +20,7 @@ describe('dom.getElementByReference', function () {
it('should return null if the attribute does not start with "#"', function () {
fixture.innerHTML = 'Hi';
var node = document.getElementById('link'),
- result = commons.dom.getElementByReference(node, 'href');
+ result = axe.commons.dom.getElementByReference(node, 'href');
assert.isNull(result);
@@ -29,7 +29,7 @@ describe('dom.getElementByReference', function () {
it('should return null if no targets are found', function () {
fixture.innerHTML = 'Hi';
var node = document.getElementById('link'),
- result = commons.dom.getElementByReference(node, 'href');
+ result = axe.commons.dom.getElementByReference(node, 'href');
assert.isNull(result);
@@ -42,7 +42,7 @@ describe('dom.getElementByReference', function () {
var node = document.getElementById('link'),
expected = document.getElementById('target'),
- result = commons.dom.getElementByReference(node, 'href');
+ result = axe.commons.dom.getElementByReference(node, 'href');
assert.equal(result, expected);
@@ -54,7 +54,7 @@ describe('dom.getElementByReference', function () {
var node = document.getElementById('link'),
expected = document.getElementById('target0'),
- result = commons.dom.getElementByReference(node, 'href');
+ result = axe.commons.dom.getElementByReference(node, 'href');
assert.equal(result, expected);
@@ -67,7 +67,7 @@ describe('dom.getElementByReference', function () {
var node = document.getElementById('link'),
expected = document.getElementById('target0'),
- result = commons.dom.getElementByReference(node, 'href');
+ result = axe.commons.dom.getElementByReference(node, 'href');
assert.equal(result, expected);
diff --git a/test/commons/dom/get-element-coordinates.js b/test/commons/dom/get-element-coordinates.js
index 8f2970f167..d4f3be0a54 100644
--- a/test/commons/dom/get-element-coordinates.js
+++ b/test/commons/dom/get-element-coordinates.js
@@ -16,7 +16,7 @@ describe('dom.getElementCoordinates', function () {
'';
el = document.getElementById('coords0');
- coords = commons.dom.getElementCoordinates(el);
+ coords = axe.commons.dom.getElementCoordinates(el);
assert.closeTo(coords.left, -1000, 0.5);
assert.closeTo(coords.top, -1000, 0.5);
assert.closeTo(coords.width, 1000, 0.5);
@@ -25,14 +25,14 @@ describe('dom.getElementCoordinates', function () {
assert.closeTo(coords.bottom, 0, 0.5);
el = document.getElementById('div');
- coords = commons.dom.getElementCoordinates(el);
+ coords = axe.commons.dom.getElementCoordinates(el);
assert.equal(Math.round(coords.left), -1);
assert.equal(Math.round(coords.top), -1);
});
it('should take into account scroll offsets', function () {
var el, coords,
- offset = commons.dom.getScrollOffset(window.document);
+ offset = axe.commons.dom.getScrollOffset(window.document);
fixture.innerHTML = '
';
el = document.getElementById('coords0');
- coords = commons.dom.getElementCoordinates(el);
+ coords = axe.commons.dom.getElementCoordinates(el);
assert.closeTo(coords.left, -1000, 0.5);
assert.closeTo(coords.top, -1000, 0.5);
assert.closeTo(coords.width, 1000, 0.5);
@@ -49,7 +49,7 @@ describe('dom.getElementCoordinates', function () {
assert.closeTo(coords.bottom, 0, 0.5);
window.scrollTo(0, 150);
- coords = commons.dom.getElementCoordinates(el);
+ coords = axe.commons.dom.getElementCoordinates(el);
assert.closeTo(coords.left, -1000, 0.5);
assert.closeTo(coords.top, -1000, 0.5);
assert.closeTo(coords.width, 1000, 0.5);
diff --git a/test/commons/dom/get-scroll-offset.js b/test/commons/dom/get-scroll-offset.js
index dcf021ffd9..15bed1f9e9 100644
--- a/test/commons/dom/get-scroll-offset.js
+++ b/test/commons/dom/get-scroll-offset.js
@@ -4,7 +4,7 @@ describe('dom.getScrollOffset', function () {
'use strict';
it('should return scrollTop and scrollLeft for normal nodes', function () {
- var offset = commons.dom.getScrollOffset({
+ var offset = axe.commons.dom.getScrollOffset({
nodeType: 3,
scrollTop: 42,
scrollLeft: 98
@@ -15,7 +15,7 @@ describe('dom.getScrollOffset', function () {
});
it('should get the scroll from the documentElement if a document is passed in', function () {
- var offset = commons.dom.getScrollOffset({
+ var offset = axe.commons.dom.getScrollOffset({
nodeType: 9,
documentElement: {
scrollTop: 42,
@@ -30,7 +30,7 @@ describe('dom.getScrollOffset', function () {
it('should get the scroll from the document.body if a document is passed in and it has no documentElement',
function () {
- var offset = commons.dom.getScrollOffset({
+ var offset = axe.commons.dom.getScrollOffset({
nodeType: 9,
body: {
scrollTop: 42,
@@ -43,7 +43,7 @@ describe('dom.getScrollOffset', function () {
});
it('should work on a window object', function () {
- var offset = commons.dom.getScrollOffset({
+ var offset = axe.commons.dom.getScrollOffset({
document: {
nodeType: 9,
documentElement: {
diff --git a/test/commons/dom/get-viewport-size.js b/test/commons/dom/get-viewport-size.js
index e132a152f5..a836be6d01 100644
--- a/test/commons/dom/get-viewport-size.js
+++ b/test/commons/dom/get-viewport-size.js
@@ -3,7 +3,7 @@ describe('dom.getViewportSize', function () {
it('should return an object with width and height', function () {
- var result = commons.dom.getViewportSize(window);
+ var result = axe.commons.dom.getViewportSize(window);
assert.property(result, 'width');
assert.property(result, 'height');
@@ -14,7 +14,7 @@ describe('dom.getViewportSize', function () {
it('should have some fallbacks for old browsers', function () {
- var result = commons.dom.getViewportSize({
+ var result = axe.commons.dom.getViewportSize({
document: {},
innerWidth: 12,
innerHeight: 47
@@ -23,7 +23,7 @@ describe('dom.getViewportSize', function () {
assert.equal(result.width, 12);
assert.equal(result.height, 47);
- result = commons.dom.getViewportSize({
+ result = axe.commons.dom.getViewportSize({
document: {
documentElement: {
clientWidth: 13,
@@ -35,7 +35,7 @@ describe('dom.getViewportSize', function () {
assert.equal(result.width, 13);
assert.equal(result.height, 48);
- result = commons.dom.getViewportSize({
+ result = axe.commons.dom.getViewportSize({
document: {
body: {
clientWidth: 22,
diff --git a/test/commons/dom/idrefs.js b/test/commons/dom/idrefs.js
index 69e4f5a308..12397ba966 100644
--- a/test/commons/dom/idrefs.js
+++ b/test/commons/dom/idrefs.js
@@ -14,7 +14,7 @@ describe('dom.idrefs', function () {
var start = document.getElementById('start'),
expected = [document.getElementById('target1'), document.getElementById('target2')];
- assert.deepEqual(commons.dom.idrefs(start, 'aria-cats'), expected, 'Should find it!');
+ assert.deepEqual(axe.commons.dom.idrefs(start, 'aria-cats'), expected, 'Should find it!');
});
@@ -26,7 +26,7 @@ describe('dom.idrefs', function () {
var start = document.getElementById('start'),
expected = [document.getElementById('target1'), document.getElementById('target2'), null];
- assert.deepEqual(commons.dom.idrefs(start, 'aria-cats'), expected, 'Should find it!');
+ assert.deepEqual(axe.commons.dom.idrefs(start, 'aria-cats'), expected, 'Should find it!');
});
@@ -38,7 +38,7 @@ describe('dom.idrefs', function () {
var start = document.getElementById('start'),
expected = [document.getElementById('target1'), document.getElementById('target2'), null];
- assert.deepEqual(commons.dom.idrefs(start, 'aria-cats'), expected, 'Should find it!');
+ assert.deepEqual(axe.commons.dom.idrefs(start, 'aria-cats'), expected, 'Should find it!');
});
diff --git a/test/commons/dom/is-focusable.js b/test/commons/dom/is-focusable.js
index c05cf08a3e..5759f25010 100644
--- a/test/commons/dom/is-focusable.js
+++ b/test/commons/dom/is-focusable.js
@@ -12,7 +12,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isFocusable(el));
+ assert.isTrue(axe.commons.dom.isFocusable(el));
});
@@ -20,7 +20,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isFocusable(el));
+ assert.isTrue(axe.commons.dom.isFocusable(el));
});
@@ -28,7 +28,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isFocusable(el));
+ assert.isTrue(axe.commons.dom.isFocusable(el));
});
@@ -36,7 +36,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isFocusable(el));
+ assert.isTrue(axe.commons.dom.isFocusable(el));
});
@@ -44,7 +44,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isFocusable(el));
+ assert.isFalse(axe.commons.dom.isFocusable(el));
});
@@ -52,7 +52,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isFocusable(el));
+ assert.isFalse(axe.commons.dom.isFocusable(el));
});
@@ -60,7 +60,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isFocusable(el));
+ assert.isFalse(axe.commons.dom.isFocusable(el));
});
@@ -68,7 +68,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isFocusable(el));
+ assert.isTrue(axe.commons.dom.isFocusable(el));
});
@@ -76,7 +76,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isFocusable(el));
+ assert.isFalse(axe.commons.dom.isFocusable(el));
});
@@ -84,7 +84,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isFocusable(el));
+ assert.isTrue(axe.commons.dom.isFocusable(el));
});
@@ -92,7 +92,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isFocusable(el));
+ assert.isTrue(axe.commons.dom.isFocusable(el));
});
@@ -100,7 +100,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isFocusable(el));
+ assert.isFalse(axe.commons.dom.isFocusable(el));
});
@@ -108,7 +108,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '
Detail
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isFocusable(el));
+ assert.isTrue(axe.commons.dom.isFocusable(el));
});
@@ -116,7 +116,7 @@ describe('dom.isFocusable', function () {
fixture.innerHTML = '';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isFocusable(el));
+ assert.isFalse(axe.commons.dom.isFocusable(el));
});
});
diff --git a/test/commons/dom/is-html5.js b/test/commons/dom/is-html5.js
index a66348917d..bd5e23cec6 100644
--- a/test/commons/dom/is-html5.js
+++ b/test/commons/dom/is-html5.js
@@ -3,15 +3,15 @@ describe('dom.isHTML5', function () {
it('should return false on any document that is not HTML5', function () {
var doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null);
- assert.isFalse(commons.dom.isHTML5(doc));
+ assert.isFalse(axe.commons.dom.isHTML5(doc));
});
it('should return true on any document that is HTML5', function () {
var doc = document.implementation.createHTMLDocument('Monkeys');
- assert.isTrue(commons.dom.isHTML5(doc));
+ assert.isTrue(axe.commons.dom.isHTML5(doc));
});
it('should return true on any document that is HTML5 - fixture', function () {
- assert.isTrue(commons.dom.isHTML5(document));
+ assert.isTrue(axe.commons.dom.isHTML5(document));
});
});
\ No newline at end of file
diff --git a/test/commons/dom/is-node.js b/test/commons/dom/is-node.js
index 2d23d4c27a..97a369f3c0 100644
--- a/test/commons/dom/is-node.js
+++ b/test/commons/dom/is-node.js
@@ -4,49 +4,49 @@ describe('dom.isNode', function () {
it('nodes', function () {
var node;
node = document;
- assert.isTrue(commons.dom.isNode(node), 'Document');
+ assert.isTrue(axe.commons.dom.isNode(node), 'Document');
node = document.body;
- assert.isTrue(commons.dom.isNode(node), 'Body');
+ assert.isTrue(axe.commons.dom.isNode(node), 'Body');
node = document.documentElement;
- assert.isTrue(commons.dom.isNode(node), 'Document Element');
+ assert.isTrue(axe.commons.dom.isNode(node), 'Document Element');
node = document.createTextNode('cats');
- assert.isTrue(commons.dom.isNode(node), 'Text Nodes');
+ assert.isTrue(axe.commons.dom.isNode(node), 'Text Nodes');
node = document.createElement('div');
- assert.isTrue(commons.dom.isNode(node), 'Elements');
+ assert.isTrue(axe.commons.dom.isNode(node), 'Elements');
node = document.createComment('div');
- assert.isTrue(commons.dom.isNode(node), 'Comment nodes');
+ assert.isTrue(axe.commons.dom.isNode(node), 'Comment nodes');
node = document.createDocumentFragment();
- assert.isTrue(commons.dom.isNode(node), 'Document fragments');
+ assert.isTrue(axe.commons.dom.isNode(node), 'Document fragments');
});
it('non-nodes', function () {
var node;
node = {};
- assert.isFalse(commons.dom.isNode(node));
+ assert.isFalse(axe.commons.dom.isNode(node));
node = null;
- assert.isFalse(commons.dom.isNode(node));
+ assert.isFalse(axe.commons.dom.isNode(node));
node = window;
- assert.isFalse(commons.dom.isNode(node));
+ assert.isFalse(axe.commons.dom.isNode(node));
node = [];
- assert.isFalse(commons.dom.isNode(node));
+ assert.isFalse(axe.commons.dom.isNode(node));
node = 'cats';
- assert.isFalse(commons.dom.isNode(node));
+ assert.isFalse(axe.commons.dom.isNode(node));
node = undefined;
- assert.isFalse(commons.dom.isNode(node));
+ assert.isFalse(axe.commons.dom.isNode(node));
node = false;
- assert.isFalse(commons.dom.isNode(node));
+ assert.isFalse(axe.commons.dom.isNode(node));
});
});
\ No newline at end of file
diff --git a/test/commons/dom/is-offscreen.js b/test/commons/dom/is-offscreen.js
index d7442566f8..c4444a7ee0 100644
--- a/test/commons/dom/is-offscreen.js
+++ b/test/commons/dom/is-offscreen.js
@@ -11,49 +11,49 @@ describe('dom.isOffscreen', function () {
fixture.innerHTML = '
Offscreen?
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isOffscreen(el));
+ assert.isTrue(axe.commons.dom.isOffscreen(el));
});
it('should detect elements positioned outside the top edge', function () {
fixture.innerHTML = '
Offscreen?
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isOffscreen(el));
+ assert.isTrue(axe.commons.dom.isOffscreen(el));
});
it('should never detect elements positioned outside the bottom edge', function () {
fixture.innerHTML = '
Offscreen?
';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isOffscreen(el));
+ assert.isFalse(axe.commons.dom.isOffscreen(el));
});
it('should detect elements positioned that bleed inside the left edge', function () {
fixture.innerHTML = '
Offscreen?
';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isOffscreen(el));
+ assert.isFalse(axe.commons.dom.isOffscreen(el));
});
it('should detect elements positioned outside the right edge', function () {
fixture.innerHTML = '
Offscreen?
';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isOffscreen(el));
+ assert.isFalse(axe.commons.dom.isOffscreen(el));
});
it('should detect elements positioned outside the top edge', function () {
fixture.innerHTML = '
Offscreen?
';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isOffscreen(el));
+ assert.isFalse(axe.commons.dom.isOffscreen(el));
});
it('should detect elements positioned outside the bottom edge', function () {
fixture.innerHTML = '
Offscreen?
';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isOffscreen(el));
+ assert.isFalse(axe.commons.dom.isOffscreen(el));
});
it('should detect elements that are made off-screen by a parent', function () {
@@ -63,14 +63,14 @@ describe('dom.isOffscreen', function () {
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isOffscreen(el));
+ assert.isTrue(axe.commons.dom.isOffscreen(el));
});
it('should NOT detect elements positioned outside the right edge on LTR documents', function () {
fixture.innerHTML = '
Offscreen?
';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isOffscreen(el));
+ assert.isFalse(axe.commons.dom.isOffscreen(el));
});
@@ -80,14 +80,14 @@ describe('dom.isOffscreen', function () {
fixture.innerHTML = '
Offscreen?
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isOffscreen(el));
+ assert.isTrue(axe.commons.dom.isOffscreen(el));
});
it('should NOT detect elements positioned outside the left edge on RTL documents', function () {
document.body.style.direction = 'rtl';
fixture.innerHTML = '
Offscreen?
';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isOffscreen(el));
+ assert.isFalse(axe.commons.dom.isOffscreen(el));
});
});
diff --git a/test/commons/dom/is-visible.js b/test/commons/dom/is-visible.js
index 52e154684c..0cd1037e9c 100644
--- a/test/commons/dom/is-visible.js
+++ b/test/commons/dom/is-visible.js
@@ -17,7 +17,7 @@ describe('dom.isVisible', function () {
window.getComputedStyle = function () {
return null;
};
- assert.isFalse(commons.dom.isVisible(fakeNode));
+ assert.isFalse(axe.commons.dom.isVisible(fakeNode));
window.getComputedStyle = orig;
});
@@ -25,7 +25,7 @@ describe('dom.isVisible', function () {
fixture.innerHTML = '
Hello!
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el));
+ assert.isTrue(axe.commons.dom.isVisible(el));
});
@@ -33,7 +33,7 @@ describe('dom.isVisible', function () {
fixture.innerHTML = '
hi
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el));
+ assert.isTrue(axe.commons.dom.isVisible(el));
});
@@ -41,7 +41,7 @@ describe('dom.isVisible', function () {
fixture.innerHTML = '
StickySticky
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el));
+ assert.isTrue(axe.commons.dom.isVisible(el));
});
it('should properly calculate offsets according the the offsetParent', function () {
@@ -49,37 +49,37 @@ describe('dom.isVisible', function () {
'
Hi
' +
'';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el));
+ assert.isTrue(axe.commons.dom.isVisible(el));
});
it('should return false if moved offscreen with left', function () {
fixture.innerHTML = '
Hi
';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isVisible(el));
+ assert.isFalse(axe.commons.dom.isVisible(el));
});
it('should return false if moved offscreen with top', function () {
fixture.innerHTML = '
Hi
';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isVisible(el));
+ assert.isFalse(axe.commons.dom.isVisible(el));
});
it('should return false on detached elements', function () {
var el = document.createElement('div');
el.innerHTML = 'I am not visible because I am detached!';
- assert.isFalse(commons.dom.isVisible(el));
+ assert.isFalse(axe.commons.dom.isVisible(el));
});
it('should return true on a document', function () {
- assert.isTrue(commons.dom.isVisible(document));
+ assert.isTrue(axe.commons.dom.isVisible(document));
});
it('should return true if positioned staticly but top/left is set', function () {
fixture.innerHTML = '
Hi
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el));
+ assert.isTrue(axe.commons.dom.isVisible(el));
});
@@ -87,7 +87,7 @@ describe('dom.isVisible', function () {
fixture.innerHTML = '
Hidden from screen readers
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el));
+ assert.isTrue(axe.commons.dom.isVisible(el));
});
it('should not calculate position on parents', function () {
@@ -97,7 +97,7 @@ describe('dom.isVisible', function () {
'';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el));
+ assert.isTrue(axe.commons.dom.isVisible(el));
});
it('should know how `visibility` works', function () {
@@ -106,7 +106,7 @@ describe('dom.isVisible', function () {
'';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el));
+ assert.isTrue(axe.commons.dom.isVisible(el));
});
it('should detect clip rect hidden text technique', function () {
@@ -120,7 +120,7 @@ describe('dom.isVisible', function () {
fixture.innerHTML = '
Hi
';
el = document.getElementById('target');
- assert.isFalse(commons.dom.isVisible(el));
+ assert.isFalse(axe.commons.dom.isVisible(el));
});
@@ -137,7 +137,7 @@ describe('dom.isVisible', function () {
'';
el = document.getElementById('target');
- assert.isFalse(commons.dom.isVisible(el));
+ assert.isFalse(axe.commons.dom.isVisible(el));
});
@@ -152,7 +152,7 @@ describe('dom.isVisible', function () {
fixture.innerHTML = '
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el, true));
+ assert.isTrue(axe.commons.dom.isVisible(el, true));
});
@@ -182,7 +182,7 @@ describe('dom.isVisible', function () {
fixture.innerHTML = '
hi
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el, true));
+ assert.isTrue(axe.commons.dom.isVisible(el, true));
});
@@ -190,7 +190,7 @@ describe('dom.isVisible', function () {
fixture.innerHTML = '
StickySticky
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el, true));
+ assert.isTrue(axe.commons.dom.isVisible(el, true));
});
it('should properly calculate offsets according the the offsetParent', function () {
@@ -198,55 +198,55 @@ describe('dom.isVisible', function () {
'
Hi
' +
'';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el, true));
+ assert.isTrue(axe.commons.dom.isVisible(el, true));
});
it('should return true if moved offscreen with left', function () {
fixture.innerHTML = '
Hi
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el, true));
+ assert.isTrue(axe.commons.dom.isVisible(el, true));
});
it('should return true if moved offscreen with top', function () {
fixture.innerHTML = '
Hi
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el, true));
+ assert.isTrue(axe.commons.dom.isVisible(el, true));
});
it('should return true if moved offscreen with right', function () {
fixture.innerHTML = '
Hi
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el, true));
+ assert.isTrue(axe.commons.dom.isVisible(el, true));
});
it('should return true if moved offscreen with bottom', function () {
fixture.innerHTML = '
Hi
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el, true));
+ assert.isTrue(axe.commons.dom.isVisible(el, true));
});
it('should return true if text is moved offscreen with text-indent', function () {
fixture.innerHTML = '
Hi
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el, true));
+ assert.isTrue(axe.commons.dom.isVisible(el, true));
});
it('should return false on detached elements', function () {
var el = document.createElement('div');
el.innerHTML = 'I am not visible because I am detached!';
- assert.isFalse(commons.dom.isVisible(el, true));
+ assert.isFalse(axe.commons.dom.isVisible(el, true));
});
it('should return true on a document', function () {
- assert.isTrue(commons.dom.isVisible(document, true));
+ assert.isTrue(axe.commons.dom.isVisible(document, true));
});
it('should return true if positioned staticly but top/left is set', function () {
fixture.innerHTML = '
Hi
';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el, true));
+ assert.isTrue(axe.commons.dom.isVisible(el, true));
});
@@ -254,14 +254,14 @@ describe('dom.isVisible', function () {
fixture.innerHTML = '
Hidden from screen readers
';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isVisible(el, true));
+ assert.isFalse(axe.commons.dom.isVisible(el, true));
});
it('should return false if `aria-hidden` is set on parent', function () {
fixture.innerHTML = '
Hidden from screen readers
';
var el = document.getElementById('target');
- assert.isFalse(commons.dom.isVisible(el, true));
+ assert.isFalse(axe.commons.dom.isVisible(el, true));
});
it('should not calculate position on parents', function () {
@@ -271,7 +271,7 @@ describe('dom.isVisible', function () {
'';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el, true));
+ assert.isTrue(axe.commons.dom.isVisible(el, true));
});
it('should know how `visibility` works', function () {
@@ -280,7 +280,7 @@ describe('dom.isVisible', function () {
'';
var el = document.getElementById('target');
- assert.isTrue(commons.dom.isVisible(el, true));
+ assert.isTrue(axe.commons.dom.isVisible(el, true));
});
it('should detect clip rect hidden text technique', function () {
@@ -294,7 +294,7 @@ describe('dom.isVisible', function () {
fixture.innerHTML = '
';
var target = fixture.querySelector('#target');
- assert.isTrue(commons.dom.visuallyContains(target, target.parentNode));
+ assert.isTrue(axe.commons.dom.visuallyContains(target, target.parentNode));
});
it('should return false when overflow is hidden', function () {
@@ -20,7 +20,7 @@ describe('dom.visuallyContains', function () {
'
' +
'
';
var target = fixture.querySelector('#target');
- assert.isTrue(commons.dom.visuallyContains(target, target.parentNode));
+ assert.isTrue(axe.commons.dom.visuallyContains(target, target.parentNode));
});
it('should return false when element is outside of margin', function () {
@@ -28,7 +28,7 @@ describe('dom.visuallyContains', function () {
'
' +
'
';
var target = fixture.querySelector('#target');
- assert.isFalse(commons.dom.visuallyContains(target, target.parentNode));
+ assert.isFalse(axe.commons.dom.visuallyContains(target, target.parentNode));
});
it('should return false when overflow is visible', function () {
@@ -36,7 +36,7 @@ describe('dom.visuallyContains', function () {
'
' +
'
';
var target = fixture.querySelector('#target');
- assert.isFalse(commons.dom.visuallyContains(target, target.parentNode));
+ assert.isFalse(axe.commons.dom.visuallyContains(target, target.parentNode));
});
it('should return true when element is scrollable', function () {
@@ -44,7 +44,7 @@ describe('dom.visuallyContains', function () {
'
' +
'
';
var target = fixture.querySelector('#target');
- assert.isTrue(commons.dom.visuallyContains(target, target.parentNode));
+ assert.isTrue(axe.commons.dom.visuallyContains(target, target.parentNode));
});
});
diff --git a/test/commons/dom/visually-overlaps.js b/test/commons/dom/visually-overlaps.js
index f1056a5cf0..cc1c6e6ab5 100644
--- a/test/commons/dom/visually-overlaps.js
+++ b/test/commons/dom/visually-overlaps.js
@@ -13,7 +13,7 @@ describe('dom.visuallyOverlaps', function () {
'';
var target = fixture.querySelector('#target');
var targetRect = target.getBoundingClientRect();
- assert.isTrue(commons.dom.visuallyOverlaps(targetRect, target.parentNode));
+ assert.isTrue(axe.commons.dom.visuallyOverlaps(targetRect, target.parentNode));
});
it('should return false when rect has no overlap', function () {
@@ -24,7 +24,7 @@ describe('dom.visuallyOverlaps', function () {
'';
var target = fixture.querySelector('#target');
var targetRect = target.getBoundingClientRect();
- assert.isFalse(commons.dom.visuallyOverlaps(targetRect, target.parentNode));
+ assert.isFalse(axe.commons.dom.visuallyOverlaps(targetRect, target.parentNode));
});
it('should return true when rect has overlap', function () {
@@ -35,7 +35,7 @@ describe('dom.visuallyOverlaps', function () {
'';
var target = fixture.querySelector('#target');
var targetRect = target.getBoundingClientRect();
- assert.isTrue(commons.dom.visuallyOverlaps(targetRect, target.parentNode));
+ assert.isTrue(axe.commons.dom.visuallyOverlaps(targetRect, target.parentNode));
});
it('should return true when container is scrollable and rect is in the scroll area', function () {
@@ -44,7 +44,7 @@ describe('dom.visuallyOverlaps', function () {
'';
var target = fixture.querySelector('#target');
var targetRect = target.getBoundingClientRect();
- assert.isTrue(commons.dom.visuallyOverlaps(targetRect, target.parentNode));
+ assert.isTrue(axe.commons.dom.visuallyOverlaps(targetRect, target.parentNode));
});
it('should return false when container has overflow hidden and rect is in the scroll area', function () {
@@ -53,7 +53,7 @@ describe('dom.visuallyOverlaps', function () {
'';
var target = fixture.querySelector('#target');
var targetRect = target.getBoundingClientRect();
- assert.isFalse(commons.dom.visuallyOverlaps(targetRect, target.parentNode));
+ assert.isFalse(axe.commons.dom.visuallyOverlaps(targetRect, target.parentNode));
});
});
diff --git a/test/commons/index.js b/test/commons/index.js
index e1f47d53f4..907f4250e2 100644
--- a/test/commons/index.js
+++ b/test/commons/index.js
@@ -1,7 +1,7 @@
-describe('commons', function () {
+describe('axe.commons', function () {
'use strict';
it('should be an object', function () {
- assert.isObject(commons);
+ assert.isObject(axe.commons);
});
});
diff --git a/test/commons/table/get-cell-position.js b/test/commons/table/get-cell-position.js
index 307826a21e..647411142c 100644
--- a/test/commons/table/get-cell-position.js
+++ b/test/commons/table/get-cell-position.js
@@ -15,7 +15,7 @@ describe('table.getCellPosition', function () {
var target = document.getElementById('target');
- assert.deepEqual(commons.table.getCellPosition(target), {
+ assert.deepEqual(axe.commons.table.getCellPosition(target), {
x: 1,
y: 1
});
@@ -30,7 +30,7 @@ describe('table.getCellPosition', function () {
var target = document.getElementById('target');
- assert.deepEqual(commons.table.getCellPosition(target), {
+ assert.deepEqual(axe.commons.table.getCellPosition(target), {
x: 2,
y: 1
});
@@ -45,7 +45,7 @@ describe('table.getCellPosition', function () {
var target = document.getElementById('target');
- assert.deepEqual(commons.table.getCellPosition(target), {
+ assert.deepEqual(axe.commons.table.getCellPosition(target), {
x: 2,
y: 1
});
@@ -61,7 +61,7 @@ describe('table.getCellPosition', function () {
var target = document.getElementById('target');
- assert.deepEqual(commons.table.getCellPosition(target), {
+ assert.deepEqual(axe.commons.table.getCellPosition(target), {
x: 2,
y: 1
});
@@ -78,7 +78,7 @@ describe('table.getCellPosition', function () {
var target = document.getElementById('target');
- assert.deepEqual(commons.table.getCellPosition(target), {
+ 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 ac15898bc3..e7e2d0961c 100644
--- a/test/commons/table/get-headers.js
+++ b/test/commons/table/get-headers.js
@@ -18,7 +18,7 @@ describe('table.getHeaders', function () {
var target = $id('target');
- assert.deepEqual(commons.table.getHeaders(target), [$id('t1'), $id('t2')]);
+ assert.deepEqual(axe.commons.table.getHeaders(target), [$id('t1'), $id('t2')]);
});
@@ -30,7 +30,7 @@ describe('table.getHeaders', function () {
var target = $id('target');
- assert.deepEqual(commons.table.getHeaders(target), [$id('t1'), $id('t2')]);
+ assert.deepEqual(axe.commons.table.getHeaders(target), [$id('t1'), $id('t2')]);
});
@@ -43,7 +43,7 @@ describe('table.getHeaders', function () {
var target = $id('target');
- assert.deepEqual(commons.table.getHeaders(target), [$id('t1'), $id('t2'), $id('t3')]);
+ assert.deepEqual(axe.commons.table.getHeaders(target), [$id('t1'), $id('t2'), $id('t3')]);
});
@@ -55,7 +55,7 @@ describe('table.getHeaders', function () {
var target = $id('target');
- assert.deepEqual(commons.table.getHeaders(target), [$id('t1'), $id('t2'), $id('t3')]);
+ assert.deepEqual(axe.commons.table.getHeaders(target), [$id('t1'), $id('t2'), $id('t3')]);
});
it('should handle colspans', function () {
@@ -66,7 +66,7 @@ describe('table.getHeaders', function () {
var target = $id('target');
- assert.deepEqual(commons.table.getHeaders(target), [$id('t1')]);
+ assert.deepEqual(axe.commons.table.getHeaders(target), [$id('t1')]);
});
it('should handle rowspans', function () {
@@ -77,7 +77,7 @@ describe('table.getHeaders', function () {
var target = $id('target');
- assert.deepEqual(commons.table.getHeaders(target), [$id('t1'), $id('t2')]);
+ assert.deepEqual(axe.commons.table.getHeaders(target), [$id('t1'), $id('t2')]);
});
it('should handle headers attribute', function () {
@@ -88,7 +88,7 @@ describe('table.getHeaders', function () {
var target = $id('target');
- assert.deepEqual(commons.table.getHeaders(target), [$id('t1'), $id('t2'), $id('t3')]);
+ assert.deepEqual(axe.commons.table.getHeaders(target), [$id('t1'), $id('t2'), $id('t3')]);
});
@@ -100,7 +100,7 @@ describe('table.getHeaders', function () {
var target = $id('target');
- assert.deepEqual(commons.table.getHeaders(target), []);
+ assert.deepEqual(axe.commons.table.getHeaders(target), []);
});
diff --git a/test/commons/table/is-column-header.js b/test/commons/table/is-column-header.js
index 1c278ab5c4..d3544ee800 100644
--- a/test/commons/table/is-column-header.js
+++ b/test/commons/table/is-column-header.js
@@ -18,7 +18,7 @@ describe('table.isColumnHeader', function () {
var target = $id('target');
- assert.isTrue(commons.table.isColumnHeader(target));
+ assert.isTrue(axe.commons.table.isColumnHeader(target));
});
it('should work with scope=col', function () {
@@ -29,7 +29,7 @@ describe('table.isColumnHeader', function () {
var target = $id('target');
- assert.isTrue(commons.table.isColumnHeader(target));
+ assert.isTrue(axe.commons.table.isColumnHeader(target));
});
it('should work with scope=row', function () {
@@ -40,7 +40,7 @@ describe('table.isColumnHeader', function () {
var target = $id('target');
- assert.isFalse(commons.table.isColumnHeader(target));
+ assert.isFalse(axe.commons.table.isColumnHeader(target));
});
it('should work with scope=auto on TD', function () {
@@ -51,7 +51,7 @@ describe('table.isColumnHeader', function () {
var target = $id('target');
- assert.isFalse(commons.table.isColumnHeader(target));
+ assert.isFalse(axe.commons.table.isColumnHeader(target));
});
it('should work with scope=col on TD', function () {
@@ -62,7 +62,7 @@ describe('table.isColumnHeader', function () {
var target = $id('target');
- assert.isTrue(commons.table.isColumnHeader(target));
+ assert.isTrue(axe.commons.table.isColumnHeader(target));
});
it('should work with scope=auto with data cells in the same row', function () {
@@ -73,6 +73,6 @@ describe('table.isColumnHeader', function () {
var target = $id('target');
- assert.isFalse(commons.table.isColumnHeader(target));
+ assert.isFalse(axe.commons.table.isColumnHeader(target));
});
});
diff --git a/test/commons/table/is-data-cell.js b/test/commons/table/is-data-cell.js
index 07b5f4e3f7..d800ccc26b 100644
--- a/test/commons/table/is-data-cell.js
+++ b/test/commons/table/is-data-cell.js
@@ -17,7 +17,7 @@ describe('table.isDataCell', function () {
var target = $id('target');
- assert.isFalse(commons.table.isDataCell(target));
+ assert.isFalse(axe.commons.table.isDataCell(target));
});
it('should work with TD', function () {
@@ -27,7 +27,7 @@ describe('table.isDataCell', function () {
var target = $id('target');
- assert.isTrue(commons.table.isDataCell(target));
+ assert.isTrue(axe.commons.table.isDataCell(target));
});
it('should work with empty TD', function () {
@@ -37,7 +37,7 @@ describe('table.isDataCell', function () {
var target = $id('target');
- assert.isFalse(commons.table.isDataCell(target));
+ assert.isFalse(axe.commons.table.isDataCell(target));
});
});
diff --git a/test/commons/table/is-data-table.js b/test/commons/table/is-data-table.js
index cc3f585ce9..f0898ffd44 100644
--- a/test/commons/table/is-data-table.js
+++ b/test/commons/table/is-data-table.js
@@ -14,7 +14,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isFalse(commons.table.isDataTable(node));
+ assert.isFalse(axe.commons.table.isDataTable(node));
});
it('should be false if the table has role=none', function () {
@@ -24,7 +24,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isFalse(commons.table.isDataTable(node));
+ assert.isFalse(axe.commons.table.isDataTable(node));
});
it('should be true if the table is inside an editable area', function () {
@@ -37,28 +37,28 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be true if the table has a role of grid', function () {
fixture.innerHTML = '
';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be true if the table has a role of treegrid', function () {
fixture.innerHTML = '
';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be true if the element has a role of table', function () {
fixture.innerHTML = '';
var node = fixture.querySelector('[role="table"]');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
describe('should be true if the table has a landmark role', function () {
@@ -66,49 +66,49 @@ describe('table.isDataTable', function () {
fixture.innerHTML = '
';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('banner', function () {
fixture.innerHTML = '
';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('complementary', function () {
fixture.innerHTML = '
';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('contentinfo', function () {
fixture.innerHTML = '
';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('form', function () {
fixture.innerHTML = '
';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('main', function () {
fixture.innerHTML = '
';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('navigation', function () {
fixture.innerHTML = '
';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('search', function () {
fixture.innerHTML = '
';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
});
@@ -120,7 +120,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isFalse(commons.table.isDataTable(node));
+ assert.isFalse(axe.commons.table.isDataTable(node));
});
it('should be true if the table has a summary attribute', function () {
@@ -128,7 +128,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be true if the table has a caption element', function () {
@@ -137,7 +137,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be true if the table has a col element', function () {
@@ -146,7 +146,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be true if the table has a colgroup element', function () {
@@ -155,7 +155,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be true if the table has a thead element', function () {
@@ -164,7 +164,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
@@ -174,7 +174,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be true if the table has a th element', function () {
@@ -183,7 +183,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be true if the table has a cell with headers attribute', function () {
@@ -192,7 +192,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be true if the table has a cell with scope attribute', function () {
@@ -201,7 +201,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be true if the table has a cell with abbr attribute', function () {
@@ -210,7 +210,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be true if the table has a cell with an abbr element as a single child', function () {
@@ -219,21 +219,21 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isFalse(commons.table.isDataTable(node));
+ assert.isFalse(axe.commons.table.isDataTable(node));
fixture.innerHTML = '
';
node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be false if it has a nested table', function () {
@@ -243,7 +243,7 @@ describe('table.isDataTable', function () {
var node = fixture.querySelector('#out');
- assert.isFalse(commons.table.isDataTable(node));
+ assert.isFalse(axe.commons.table.isDataTable(node));
});
@@ -255,7 +255,7 @@ describe('table.isDataTable', function () {
var node = fixture.querySelector('table');
- assert.isFalse(commons.table.isDataTable(node));
+ assert.isFalse(axe.commons.table.isDataTable(node));
});
@@ -266,7 +266,7 @@ describe('table.isDataTable', function () {
var node = fixture.querySelector('table');
- assert.isFalse(commons.table.isDataTable(node));
+ assert.isFalse(axe.commons.table.isDataTable(node));
});
@@ -277,7 +277,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
@@ -288,7 +288,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
@@ -304,7 +304,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
@@ -323,7 +323,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be true if it has 20 or more rows', function () {
@@ -332,7 +332,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
it('should be false if its width is 95% of the document width', function () {
@@ -341,7 +341,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isFalse(commons.table.isDataTable(node));
+ assert.isFalse(axe.commons.table.isDataTable(node));
});
@@ -352,7 +352,7 @@ describe('table.isDataTable', function () {
var node = fixture.querySelector('table');
- assert.isFalse(commons.table.isDataTable(node));
+ assert.isFalse(axe.commons.table.isDataTable(node));
});
@@ -364,7 +364,7 @@ describe('table.isDataTable', function () {
var node = fixture.querySelector('table');
- assert.isFalse(commons.table.isDataTable(node));
+ assert.isFalse(axe.commons.table.isDataTable(node));
});
@@ -376,7 +376,7 @@ describe('table.isDataTable', function () {
var node = fixture.querySelector('table');
- assert.isFalse(commons.table.isDataTable(node));
+ assert.isFalse(axe.commons.table.isDataTable(node));
});
@@ -388,7 +388,7 @@ describe('table.isDataTable', function () {
var node = fixture.querySelector('table');
- assert.isFalse(commons.table.isDataTable(node));
+ assert.isFalse(axe.commons.table.isDataTable(node));
});
@@ -400,7 +400,7 @@ describe('table.isDataTable', function () {
'';
var node = fixture.querySelector('table');
- assert.isFalse(commons.table.isDataTable(node));
+ assert.isFalse(axe.commons.table.isDataTable(node));
});
it('should otherwise be true', function () {
@@ -410,7 +410,7 @@ describe('table.isDataTable', function () {
var node = fixture.querySelector('table');
- assert.isTrue(commons.table.isDataTable(node));
+ assert.isTrue(axe.commons.table.isDataTable(node));
});
diff --git a/test/commons/table/is-header.js b/test/commons/table/is-header.js
index d75c3b6df4..ca6d7d10c4 100644
--- a/test/commons/table/is-header.js
+++ b/test/commons/table/is-header.js
@@ -11,48 +11,48 @@ describe('table.isHeader', function () {
});
it('should return true if table.isColumnHeader return true', function () {
- var orig = commons.table.isColumnHeader;
- commons.table.isColumnHeader = function () {
+ var orig = axe.commons.table.isColumnHeader;
+ axe.commons.table.isColumnHeader = function () {
return true;
};
- var orig2 = commons.table.isRowHeader;
- commons.table.isRowHeader = function () {
+ var orig2 = axe.commons.table.isRowHeader;
+ axe.commons.table.isRowHeader = function () {
return false;
};
- assert.isTrue(commons.table.isHeader({}));
+ assert.isTrue(axe.commons.table.isHeader({}));
- commons.table.isColumnHeader = orig;
- commons.table.isRowHeader = orig2;
+ axe.commons.table.isColumnHeader = orig;
+ axe.commons.table.isRowHeader = orig2;
});
it('should return true if table.isRowHeader return true', function () {
- var orig = commons.table.isRowHeader;
- commons.table.isRowHeader = function () {
+ var orig = axe.commons.table.isRowHeader;
+ axe.commons.table.isRowHeader = function () {
return true;
};
- var orig2 = commons.table.isColumnHeader;
- commons.table.isColumnHeader = function () {
+ var orig2 = axe.commons.table.isColumnHeader;
+ axe.commons.table.isColumnHeader = function () {
return false;
};
- assert.isTrue(commons.table.isHeader({}));
+ assert.isTrue(axe.commons.table.isHeader({}));
- commons.table.isRowHeader = orig;
- commons.table.isColumnHeader = orig2;
+ axe.commons.table.isRowHeader = orig;
+ axe.commons.table.isColumnHeader = orig2;
});
it('should return false if table.isRowHeader and table.isColumnHeader return false', function () {
- var orig = commons.table.isRowHeader;
- commons.table.isRowHeader = function () {
+ var orig = axe.commons.table.isRowHeader;
+ axe.commons.table.isRowHeader = function () {
return false;
};
- var orig2 = commons.table.isColumnHeader;
- commons.table.isColumnHeader = function () {
+ var orig2 = axe.commons.table.isColumnHeader;
+ axe.commons.table.isColumnHeader = function () {
return false;
};
- assert.isFalse(commons.table.isHeader({}));
+ assert.isFalse(axe.commons.table.isHeader({}));
- commons.table.isRowHeader = orig;
- commons.table.isColumnHeader = orig2;
+ axe.commons.table.isRowHeader = orig;
+ axe.commons.table.isColumnHeader = orig2;
});
it('should return true if referenced by another cells headers attr', function () {
@@ -62,7 +62,7 @@ describe('table.isHeader', function () {
var target = $id('target');
- assert.isTrue(commons.table.isHeader(target));
+ assert.isTrue(axe.commons.table.isHeader(target));
});
it('should return false otherwise', function () {
@@ -72,7 +72,7 @@ describe('table.isHeader', function () {
var target = document.querySelector('.target');
- assert.isFalse(commons.table.isHeader(target));
+ assert.isFalse(axe.commons.table.isHeader(target));
});
});
diff --git a/test/commons/table/is-row-header.js b/test/commons/table/is-row-header.js
index dbebab0467..5c890ed5bd 100644
--- a/test/commons/table/is-row-header.js
+++ b/test/commons/table/is-row-header.js
@@ -17,7 +17,7 @@ describe('table.isRowHeader', function () {
var target = $id('target');
- assert.isTrue(commons.table.isRowHeader(target));
+ assert.isTrue(axe.commons.table.isRowHeader(target));
});
it('should work with scope=row', function () {
@@ -27,7 +27,7 @@ describe('table.isRowHeader', function () {
var target = $id('target');
- assert.isTrue(commons.table.isRowHeader(target));
+ assert.isTrue(axe.commons.table.isRowHeader(target));
});
it('should work with scope=col', function () {
@@ -38,7 +38,7 @@ describe('table.isRowHeader', function () {
var target = $id('target');
- assert.isFalse(commons.table.isRowHeader(target));
+ assert.isFalse(axe.commons.table.isRowHeader(target));
});
it('should work with scope=auto on TD', function () {
@@ -48,7 +48,7 @@ describe('table.isRowHeader', function () {
var target = $id('target');
- assert.isFalse(commons.table.isRowHeader(target));
+ assert.isFalse(axe.commons.table.isRowHeader(target));
});
it('should work with scope=row on TD', function () {
@@ -58,7 +58,7 @@ describe('table.isRowHeader', function () {
var target = $id('target');
- assert.isTrue(commons.table.isRowHeader(target));
+ assert.isTrue(axe.commons.table.isRowHeader(target));
});
it('should work with scope=auto with data cells in the same column', function () {
@@ -69,7 +69,7 @@ describe('table.isRowHeader', function () {
var target = $id('target');
- assert.isFalse(commons.table.isRowHeader(target));
+ assert.isFalse(axe.commons.table.isRowHeader(target));
});
});
diff --git a/test/commons/table/to-array.js b/test/commons/table/to-array.js
index 221f9d8488..8904895546 100644
--- a/test/commons/table/to-array.js
+++ b/test/commons/table/to-array.js
@@ -18,7 +18,7 @@ describe('table.toArray', function () {
var target = fixture.querySelector('table');
- assert.deepEqual(commons.table.toArray(target), [
+ assert.deepEqual(axe.commons.table.toArray(target), [
[$id('t1'), $id('t2')],
[$id('t3'), $id('t4')]
]);
@@ -32,7 +32,7 @@ describe('table.toArray', function () {
var target = fixture.querySelector('table');
- assert.deepEqual(commons.table.toArray(target), [
+ assert.deepEqual(axe.commons.table.toArray(target), [
[$id('t1'), $id('t1'), $id('t2')],
[$id('t3'), $id('t3'), $id('t3')]
]);
@@ -47,7 +47,7 @@ describe('table.toArray', function () {
var target = fixture.querySelector('table');
- assert.deepEqual(commons.table.toArray(target), [
+ assert.deepEqual(axe.commons.table.toArray(target), [
[$id('t1'), $id('t2')],
[$id('t1'), $id('t3')]
]);
@@ -62,7 +62,7 @@ describe('table.toArray', function () {
var target = fixture.querySelector('table');
- assert.deepEqual(commons.table.toArray(target), [
+ assert.deepEqual(axe.commons.table.toArray(target), [
[$id('t1'), $id('t1'), $id('t2')],
[$id('t1'), $id('t1'), $id('t3')]
]);
@@ -77,7 +77,7 @@ describe('table.toArray', function () {
var target = fixture.querySelector('table');
- assert.deepEqual(commons.table.toArray(target), [
+ assert.deepEqual(axe.commons.table.toArray(target), [
[],
[$id('t1')]
]);
diff --git a/test/commons/text/accessible-text.js b/test/commons/text/accessible-text.js
index 9eba3051c7..381bce1ee2 100644
--- a/test/commons/text/accessible-text.js
+++ b/test/commons/text/accessible-text.js
@@ -22,8 +22,8 @@ describe('text.accessibleText', function() {
'';
var rule2a = fixture.querySelector('#rule2a');
var rule2c = fixture.querySelector('#rule2c');
- assert.equal(commons.text.accessibleText(rule2a), 'File');
- assert.equal(commons.text.accessibleText(rule2c), 'New');
+ assert.equal(axe.commons.text.accessibleText(rule2a), 'File');
+ assert.equal(axe.commons.text.accessibleText(rule2c), 'New');
});
@@ -45,8 +45,8 @@ describe('text.accessibleText', function() {
var rule2a = fixture.querySelector('#beep');
var rule2b = fixture.querySelector('#flash');
- assert.equal(commons.text.accessibleText(rule2a), 'Beep');
- assert.equal(commons.text.accessibleText(rule2b), 'Flash the screen 3 times');
+ assert.equal(axe.commons.text.accessibleText(rule2a), 'Beep');
+ assert.equal(axe.commons.text.accessibleText(rule2b), 'Flash the screen 3 times');
});
@@ -58,7 +58,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t1');
- assert.equal(commons.text.accessibleText(target), 'This is a label');
+ assert.equal(axe.commons.text.accessibleText(target), 'This is a label');
});
it('should use recusive aria-labelledby properly', function() {
@@ -69,7 +69,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t1');
- assert.equal(commons.text.accessibleText(target), 'ARIA Label This is a label');
+ assert.equal(axe.commons.text.accessibleText(target), 'ARIA Label This is a label');
});
it('should include hidden text referred to with aria-labelledby', function () {
@@ -80,15 +80,15 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t1');
- assert.equal(commons.text.accessibleText(target), 'This is a hidden secret');
+ assert.equal(axe.commons.text.accessibleText(target), 'This is a hidden secret');
});
it('should allow setting the initial inLabelledbyContext value', function () {
fixture.innerHTML = '';
var target = fixture.querySelector('#lbl1');
- assert.equal(commons.text.accessibleText(target, false), '');
- assert.equal(commons.text.accessibleText(target, true), 'hidden label');
+ assert.equal(axe.commons.text.accessibleText(target, false), '');
+ assert.equal(axe.commons.text.accessibleText(target, true), 'hidden label');
});
it('should use aria-label if present with no labelledby', function() {
@@ -99,7 +99,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t1');
- assert.equal(commons.text.accessibleText(target), 'ARIA Label');
+ assert.equal(axe.commons.text.accessibleText(target), 'ARIA Label');
});
it('should use alt on imgs with no ARIA', function() {
@@ -111,7 +111,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#target');
- assert.equal(commons.text.accessibleText(target), 'Alt text goes here');
+ assert.equal(axe.commons.text.accessibleText(target), 'Alt text goes here');
});
it('should use alt on image inputs with no ARIA', function() {
@@ -123,7 +123,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#target');
- assert.equal(commons.text.accessibleText(target), 'Alt text goes here');
+ assert.equal(axe.commons.text.accessibleText(target), 'Alt text goes here');
});
it('should use not use alt on text inputs with no ARIA', function() {
@@ -135,7 +135,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#target');
- assert.equal(commons.text.accessibleText(target), '');
+ assert.equal(axe.commons.text.accessibleText(target), '');
});
it('should use HTML label if no ARIA information', function() {
@@ -146,7 +146,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t1');
- assert.equal(commons.text.accessibleText(target), 'HTML Label');
+ assert.equal(axe.commons.text.accessibleText(target), 'HTML Label');
});
it('should handle last ditch title attribute', function() {
@@ -157,7 +157,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t2label');
- assert.equal(commons.text.accessibleText(target), 'This is This is a label of italics');
+ assert.equal(axe.commons.text.accessibleText(target), 'This is This is a label of italics');
});
it('should handle totally empty elements', function() {
@@ -168,7 +168,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t2label');
- assert.equal(commons.text.accessibleText(target), 'This is This is a label of');
+ assert.equal(axe.commons.text.accessibleText(target), 'This is This is a label of');
});
@@ -180,14 +180,14 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t2label');
- assert.equal(commons.text.accessibleText(target), 'This is This is a label of');
+ assert.equal(axe.commons.text.accessibleText(target), 'This is This is a label of');
});
it('should only show each node once when label is before input', function() {
fixture.innerHTML = '
' +
'
';
var target = fixture.querySelector('#target');
- assert.equal(commons.text.accessibleText(target), 'My form input');
+ assert.equal(axe.commons.text.accessibleText(target), 'My form input');
});
it('should only show each node once when label follows input', function() {
@@ -195,7 +195,7 @@ describe('text.accessibleText', function() {
'' +
'';
var target = fixture.querySelector('#target');
- assert.equal(commons.text.accessibleText(target), 'My form input');
+ assert.equal(axe.commons.text.accessibleText(target), 'My form input');
});
it('should handle nested inputs in normal context', function() {
@@ -206,7 +206,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t2label');
- assert.equal(commons.text.accessibleText(target), 'This is This is a label of everything');
+ assert.equal(axe.commons.text.accessibleText(target), 'This is This is a label of everything');
});
it('should use handle nested inputs properly in labelledby context', function() {
@@ -217,7 +217,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t2');
- assert.equal(commons.text.accessibleText(target), 'This is the value of everything');
+ assert.equal(axe.commons.text.accessibleText(target), 'This is the value of everything');
});
it('should use ignore hidden inputs', function() {
@@ -228,7 +228,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t2');
- assert.equal(commons.text.accessibleText(target), 'This is of everything');
+ assert.equal(axe.commons.text.accessibleText(target), 'This is of everything');
});
it('should use handle inputs with no type as if they were text inputs', function() {
@@ -239,7 +239,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t2');
- assert.equal(commons.text.accessibleText(target), 'This is the value of everything');
+ assert.equal(axe.commons.text.accessibleText(target), 'This is the value of everything');
});
it('should use handle nested selects properly in labelledby context', function() {
@@ -252,7 +252,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t2');
- assert.equal(commons.text.accessibleText(target), 'This is first third of everything');
+ assert.equal(axe.commons.text.accessibleText(target), 'This is first third of everything');
});
it('should use handle nested textareas properly in labelledby context', function() {
@@ -263,7 +263,7 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t2');
- assert.equal(commons.text.accessibleText(target), 'This is the value of everything');
+ assert.equal(axe.commons.text.accessibleText(target), 'This is the value of everything');
});
it('should use handle ARIA labels properly in labelledby context', function() {
@@ -275,79 +275,79 @@ describe('text.accessibleText', function() {
'';
var target = fixture.querySelector('#t2');
- assert.equal(commons.text.accessibleText(target), 'This not a span is the value of everything');
+ assert.equal(axe.commons.text.accessibleText(target), 'This not a span is the value of everything');
});
it('shoud properly fall back to title', function() {
fixture.innerHTML = '';
var target = fixture.querySelector('a');
- assert.equal(commons.text.accessibleText(target), 'Hello');
+ assert.equal(axe.commons.text.accessibleText(target), 'Hello');
});
it('should give text even for role=presentation on anchors', function() {
fixture.innerHTML = 'Hello';
var target = fixture.querySelector('a');
- assert.equal(commons.text.accessibleText(target), 'Hello');
+ assert.equal(axe.commons.text.accessibleText(target), 'Hello');
});
it('should give text even for role=presentation on buttons', function() {
fixture.innerHTML = '';
var target = fixture.querySelector('button');
- assert.equal(commons.text.accessibleText(target), 'Hello');
+ assert.equal(axe.commons.text.accessibleText(target), 'Hello');
});
it('should give text even for role=presentation on summary', function() {
fixture.innerHTML = 'Hello';
var target = fixture.querySelector('summary');
- assert.equal(commons.text.accessibleText(target), 'Hello');
+ assert.equal(axe.commons.text.accessibleText(target), 'Hello');
});
it('shoud properly fall back to title', function() {
fixture.innerHTML = '';
var target = fixture.querySelector('a');
- assert.equal(commons.text.accessibleText(target), 'Hello');
+ assert.equal(axe.commons.text.accessibleText(target), 'Hello');
});
it('should give text even for role=none on anchors', function() {
fixture.innerHTML = 'Hello';
var target = fixture.querySelector('a');
- assert.equal(commons.text.accessibleText(target), 'Hello');
+ assert.equal(axe.commons.text.accessibleText(target), 'Hello');
});
it('should give text even for role=none on buttons', function() {
fixture.innerHTML = '';
var target = fixture.querySelector('button');
- assert.equal(commons.text.accessibleText(target), 'Hello');
+ assert.equal(axe.commons.text.accessibleText(target), 'Hello');
});
it('should give text even for role=none on summary', function() {
fixture.innerHTML = 'Hello';
var target = fixture.querySelector('summary');
- assert.equal(commons.text.accessibleText(target), 'Hello');
+ assert.equal(axe.commons.text.accessibleText(target), 'Hello');
});
it('should not add extra spaces around phrasing elements', function() {
fixture.innerHTML = 'HelloWorld';
var target = fixture.querySelector('a');
- assert.equal(commons.text.accessibleText(target), 'HelloWorld');
+ assert.equal(axe.commons.text.accessibleText(target), 'HelloWorld');
});
it('should add spaces around non-phrasing elements', function() {
fixture.innerHTML = 'Hello
';
- assert.equal(commons.text.visible(fixture, true), 'Hello');
+ assert.equal(axe.commons.text.visible(fixture, true), 'Hello');
});
});
diff --git a/test/commons/utils/index.js b/test/commons/utils/index.js
index 63ec118087..3b80b3b338 100644
--- a/test/commons/utils/index.js
+++ b/test/commons/utils/index.js
@@ -3,7 +3,7 @@ describe('utils.escapeSelector', function () {
'use strict';
it('should be a function', function () {
- assert.isFunction(commons.utils.escapeSelector);
+ assert.isFunction(axe.commons.utils.escapeSelector);
});
});
@@ -11,7 +11,7 @@ describe('utils.matchesSelector', function () {
'use strict';
it('should be a function', function () {
- assert.isFunction(commons.utils.matchesSelector);
+ assert.isFunction(axe.commons.utils.matchesSelector);
});
});
@@ -19,7 +19,7 @@ describe('utils.clone', function () {
'use strict';
it('should be a function', function () {
- assert.isFunction(commons.utils.clone);
+ assert.isFunction(axe.commons.utils.clone);
});
});
\ No newline at end of file
diff --git a/test/commons/utils/to-array.js b/test/commons/utils/to-array.js
index 92cdcf64a1..aa8dac324a 100644
--- a/test/commons/utils/to-array.js
+++ b/test/commons/utils/to-array.js
@@ -11,7 +11,7 @@ describe('utils.toArray', function () {
assert.equal(this, arrayLike);
};
- commons.utils.toArray(arrayLike);
+ axe.commons.utils.toArray(arrayLike);
Array.prototype.slice = orig;
@@ -20,7 +20,7 @@ describe('utils.toArray', function () {
it('should return an array', function () {
var arrayLike = {'0': 'cats', length: 1};
- var result = commons.utils.toArray(arrayLike);
+ var result = axe.commons.utils.toArray(arrayLike);
assert.isArray(result);
});
});
\ No newline at end of file
diff --git a/test/commons/utils/token-list.js b/test/commons/utils/token-list.js
index 84e6cf9812..32336aea4e 100644
--- a/test/commons/utils/token-list.js
+++ b/test/commons/utils/token-list.js
@@ -2,14 +2,14 @@ describe('utils.tokenList', function () {
'use strict';
it('should split by space', function () {
- assert.deepEqual(commons.utils.tokenList('bananas monkeys 42'), ['bananas', 'monkeys', '42']);
+ assert.deepEqual(axe.commons.utils.tokenList('bananas monkeys 42'), ['bananas', 'monkeys', '42']);
});
it('should trim first', function () {
- assert.deepEqual(commons.utils.tokenList(' \r bananas monkeys 42 \n '), ['bananas', 'monkeys', '42']);
+ assert.deepEqual(axe.commons.utils.tokenList(' \r bananas monkeys 42 \n '), ['bananas', 'monkeys', '42']);
});
it('should collapse whitespace', function () {
- assert.deepEqual(commons.utils.tokenList(' \r bananas \r \n monkeys 42 \n '), ['bananas', 'monkeys', '42']);
+ assert.deepEqual(axe.commons.utils.tokenList(' \r bananas \r \n monkeys 42 \n '), ['bananas', 'monkeys', '42']);
});
});
\ No newline at end of file
diff --git a/test/core/base/audit.js b/test/core/base/audit.js
index 5cc3984a15..51b59430f1 100644
--- a/test/core/base/audit.js
+++ b/test/core/base/audit.js
@@ -421,7 +421,7 @@ describe('Audit', function () {
});
it('should call the rule\'s run function', function (done) {
var targetRule = mockRules[mockRules.length - 1],
- rule = utils.findBy(a.rules, 'id', targetRule.id),
+ rule = axe.utils.findBy(a.rules, 'id', targetRule.id),
called = false,
orig;
@@ -439,7 +439,7 @@ describe('Audit', function () {
});
it('should pass the option to the run function', function (done) {
var targetRule = mockRules[mockRules.length - 1],
- rule = utils.findBy(a.rules, 'id', targetRule.id),
+ rule = axe.utils.findBy(a.rules, 'id', targetRule.id),
passed = false,
orig, options;
diff --git a/test/core/base/check.js b/test/core/base/check.js
index 8433a60077..b19396005c 100644
--- a/test/core/base/check.js
+++ b/test/core/base/check.js
@@ -1,4 +1,4 @@
-/*global Check, CheckResult */
+/*global Check, CheckResult, axe */
describe('Check', function () {
'use strict';
var noop = function () {};
@@ -28,7 +28,6 @@ describe('Check', function () {
it('should be a function', function () {
assert.isFunction(Check.prototype.matches);
});
-
it('should test its selector against a given node', function () {
var node = document.createElement('div');
node.id = 'monkeys';
@@ -237,11 +236,11 @@ describe('Check', function () {
});
it('should bind context to `bindCheckResult`', function (done) {
- var orig = utils.checkHelper,
+ var orig = axe.utils.checkHelper,
cb = function () { return true; },
result = { monkeys: 'bananas' };
- utils.checkHelper = function (checkResult, callback) {
+ axe.utils.checkHelper = function (checkResult, callback) {
assert.instanceOf(checkResult, window.CheckResult);
assert.equal(callback, cb);
@@ -251,7 +250,7 @@ describe('Check', function () {
new Check({
evaluate: function () {
assert.deepEqual(result, this);
- utils.checkHelper = orig;
+ axe.utils.checkHelper = orig;
done();
}
}).run(fixture, {}, cb);
diff --git a/test/core/base/context.js b/test/core/base/context.js
index e323961119..68c8282ad6 100644
--- a/test/core/base/context.js
+++ b/test/core/base/context.js
@@ -1,4 +1,4 @@
-/*global Context */
+/*global Context, axe */
describe('Context', function() {
'use strict';
@@ -206,10 +206,10 @@ describe('Context', function() {
fixture.innerHTML = '';
iframeReady('../mock/frames/context.html', $id('outer'), 'target', function() {
var frame = $id('target');
- var orig = utils.isHidden;
+ var orig = axe.utils.isHidden;
var success = false;
- utils.isHidden = function(actual) {
+ axe.utils.isHidden = function(actual) {
assert.equal(actual, frame);
success = true;
@@ -219,8 +219,8 @@ describe('Context', function() {
var result = new Context([$id('target')]);
assert.deepEqual(result.frames, []);
- utils.isHidden = orig;
- assert.isTrue(success, 'utils.isHidden was called');
+ axe.utils.isHidden = orig;
+ assert.isTrue(success, 'axe.utils.isHidden was called');
done();
});
@@ -231,10 +231,10 @@ describe('Context', function() {
fixture.innerHTML = '';
iframeReady('../mock/frames/context.html', $id('outer'), 'target', function() {
var frame = $id('target');
- var orig = utils.isHidden;
+ var orig = axe.utils.isHidden;
var success = false;
- utils.isHidden = function(actual) {
+ axe.utils.isHidden = function(actual) {
assert.equal(actual, frame);
success = true;
@@ -249,8 +249,8 @@ describe('Context', function() {
node: $id('target')
}]);
- utils.isHidden = orig;
- assert.isTrue(success, 'utils.isHidden was called');
+ axe.utils.isHidden = orig;
+ assert.isTrue(success, 'axe.utils.isHidden was called');
done();
});
diff --git a/test/core/public/cleanup-plugins.js b/test/core/public/cleanup-plugins.js
index c87e927daf..a4a4a1e16d 100644
--- a/test/core/public/cleanup-plugins.js
+++ b/test/core/public/cleanup-plugins.js
@@ -62,14 +62,14 @@ describe('cleanupPlugins', function () {
it('should send command to frames to cleanup', function (done) {
createFrames(function () {
axe._load({});
- var orig = utils.sendCommandToFrame;
+ var orig = axe.utils.sendCommandToFrame;
var frame = document.querySelector('iframe');
- utils.sendCommandToFrame = function (node, opts) {
+ axe.utils.sendCommandToFrame = function (node, opts) {
assert.equal(node, frame);
assert.deepEqual(opts, {
command: 'cleanup-plugin'
});
- utils.sendCommandToFrame = orig;
+ axe.utils.sendCommandToFrame = orig;
done();
};
cleanupPlugins(function () {}, assertNotCalled);
diff --git a/test/core/public/load.js b/test/core/public/load.js
index fdbe629f32..6f959804d3 100644
--- a/test/core/public/load.js
+++ b/test/core/public/load.js
@@ -57,7 +57,7 @@ describe('axe._load', function () {
};
var orig = window.utils.respondable.subscribe;
- utils.respondable.subscribe = function (topic, callback) {
+ axe.utils.respondable.subscribe = function (topic, callback) {
assert.ok(topic.indexOf('axe.') === 0);
assert.isFunction(callback);
};
@@ -80,7 +80,7 @@ describe('axe._load', function () {
done();
};
- utils.respondable.subscribe = function (topic, callback) {
+ axe.utils.respondable.subscribe = function (topic, callback) {
callback({data: 'iscool', command: 'rules'}, undefined, function (response) {
// ping callback will call this response function
assert.ok(response);
@@ -102,7 +102,7 @@ describe('axe._load', function () {
done();
};
- utils.respondable.subscribe = function (topic, callback) {
+ axe.utils.respondable.subscribe = function (topic, callback) {
callback({ command: 'rules', context: { include: ['monkeys'] }}, undefined, function (response) {
assert.ok(response);
});
@@ -116,7 +116,7 @@ describe('axe._load', function () {
window.runRules = orig;
});
it('should default include to current document if none are found', function (done) {
- var origSub = utils.respondable.subscribe;
+ var origSub = axe.utils.respondable.subscribe;
var orig = window.runRules;
var expected = {include: [document]};
window.runRules = function (context) {
@@ -124,14 +124,14 @@ describe('axe._load', function () {
done();
};
- utils.respondable.subscribe = function (topic, callback) {
+ axe.utils.respondable.subscribe = function (topic, callback) {
callback({ command: 'rules', context: { include: [] }}, undefined, function () {});
};
axe._load({
rules: []
});
window.runRules = orig;
- utils.respondable.subscribe = origSub;
+ axe.utils.respondable.subscribe = origSub;
});
});
@@ -147,7 +147,7 @@ describe('axe._load', function () {
done();
};
- utils.respondable.subscribe = function (topic, callback) {
+ axe.utils.respondable.subscribe = function (topic, callback) {
callback({
command: 'cleanup-plugin'
}, undefined, function (response) {
@@ -168,7 +168,7 @@ describe('axe._load', function () {
var origSub = window.utils.respondable.subscribe;
var expected = {data: {include: ['monkeys']}};
- utils.respondable.subscribe = function (topic, callback) {
+ axe.utils.respondable.subscribe = function (topic, callback) {
callback({}, undefined, function responder(data) {
if (topic === 'axe.start') {
assert.equal(data, expected);
diff --git a/test/core/utils/check-helper.js b/test/core/utils/check-helper.js
index 58e3a2c97c..43f250da64 100644
--- a/test/core/utils/check-helper.js
+++ b/test/core/utils/check-helper.js
@@ -1,34 +1,34 @@
/*global DqElement */
-describe('utils.checkHelper', function () {
+describe('axe.utils.checkHelper', function () {
'use strict';
function noop() {}
it('should be a function', function () {
- assert.isFunction(utils.checkHelper);
+ assert.isFunction(axe.utils.checkHelper);
});
it('should accept 3 named parameters', function () {
- assert.lengthOf(utils.checkHelper, 3);
+ assert.lengthOf(axe.utils.checkHelper, 3);
});
it('should return an object', function () {
- assert.isObject(utils.checkHelper());
+ assert.isObject(axe.utils.checkHelper());
});
describe('return value', function () {
describe('async', function () {
it('should set isAsync property on returned object to `true` when called', function () {
var target = {},
- helper = utils.checkHelper(target, noop);
+ helper = axe.utils.checkHelper(target, noop);
helper.async();
assert.isTrue(helper.isAsync);
});
- it('should call the second parameter of `utils.checkHelper` when invoked', function () {
+ it('should call the second parameter of `axe.utils.checkHelper` when invoked', function () {
function fn() { success = true; }
var success = false,
- helper = utils.checkHelper({}, fn);
+ helper = axe.utils.checkHelper({}, fn);
var done = helper.async();
done();
@@ -36,14 +36,14 @@ describe('utils.checkHelper', function () {
assert.isTrue(success);
});
- it('should call the third parameter of `utils.checkHelper` when returning an error', function () {
+ it('should call the third parameter of `axe.utils.checkHelper` when returning an error', function () {
var success = false;
function reject(e) {
success = true;
assert.equal(e.message, 'Concrete donkey!');
}
- var helper = utils.checkHelper({}, noop, reject);
+ var helper = axe.utils.checkHelper({}, noop, reject);
var done = helper.async();
done( new Error('Concrete donkey!'));
@@ -55,7 +55,7 @@ describe('utils.checkHelper', function () {
it('should set data property on target when called', function () {
var target = {},
expected = { monkeys: 'bananas' },
- helper = utils.checkHelper(target, noop);
+ helper = axe.utils.checkHelper(target, noop);
assert.notProperty(target, 'data');
helper.data(expected);
@@ -71,7 +71,7 @@ describe('utils.checkHelper', function () {
it('should accept NodeList', function () {
fixture.innerHTML = '';
var target = {},
- helper = utils.checkHelper(target, noop);
+ helper = axe.utils.checkHelper(target, noop);
helper.relatedNodes(fixture.children);
assert.lengthOf(target.relatedNodes, 2);
assert.instanceOf(target.relatedNodes[0], DqElement);
@@ -82,7 +82,7 @@ describe('utils.checkHelper', function () {
it('should accept a single Node', function () {
fixture.innerHTML = '';
var target = {},
- helper = utils.checkHelper(target, noop);
+ helper = axe.utils.checkHelper(target, noop);
helper.relatedNodes(fixture.firstChild);
assert.lengthOf(target.relatedNodes, 1);
assert.instanceOf(target.relatedNodes[0], DqElement);
@@ -91,7 +91,7 @@ describe('utils.checkHelper', function () {
it('should accept an Array', function () {
fixture.innerHTML = '';
var target = {},
- helper = utils.checkHelper(target, noop);
+ helper = axe.utils.checkHelper(target, noop);
helper.relatedNodes(Array.prototype.slice.call(fixture.children));
assert.lengthOf(target.relatedNodes, 2);
assert.instanceOf(target.relatedNodes[0], DqElement);
@@ -102,7 +102,7 @@ describe('utils.checkHelper', function () {
it('should accept an array-like Object', function () {
fixture.innerHTML = '';
var target = {},
- helper = utils.checkHelper(target, noop);
+ helper = axe.utils.checkHelper(target, noop);
var nodes = {
0: fixture.children[0],
1: fixture.children[1],
diff --git a/test/core/utils/collect-results-from-frames.js b/test/core/utils/collect-results-from-frames.js
index ae44dad76d..376d37597e 100644
--- a/test/core/utils/collect-results-from-frames.js
+++ b/test/core/utils/collect-results-from-frames.js
@@ -1,5 +1,5 @@
/*global Context */
-describe('utils.collectResultsFromFrames', function () {
+describe('axe.utils.collectResultsFromFrames', function () {
'use strict';
var fixture = document.getElementById('fixture');
@@ -24,7 +24,7 @@ describe('utils.collectResultsFromFrames', function () {
var frame = document.createElement('iframe');
frame.addEventListener('load', function () {
var context = new Context(document);
- utils.collectResultsFromFrames(context, {}, 'stuff', 'morestuff', noop,
+ axe.utils.collectResultsFromFrames(context, {}, 'stuff', 'morestuff', noop,
function (err) {
assert.instanceOf(err, Error);
assert.equal(err.message.split(/: /)[0], 'Axe in frame timed out');
@@ -57,7 +57,7 @@ describe('utils.collectResultsFromFrames', function () {
var frame = document.createElement('iframe');
frame.addEventListener('load', function () {
var context = new Context(document);
- utils.collectResultsFromFrames(context, {}, 'rules', 'morestuff', function () {
+ axe.utils.collectResultsFromFrames(context, {}, 'rules', 'morestuff', function () {
done();
}, function (e) {
assert.ok(false, e);
@@ -75,7 +75,7 @@ describe('utils.collectResultsFromFrames', function () {
var frame = document.createElement('iframe');
frame.addEventListener('load', function () {
var context = new Context(document);
- utils.collectResultsFromFrames(context, {}, 'command', 'params', noop,
+ axe.utils.collectResultsFromFrames(context, {}, 'command', 'params', noop,
function (err) {
assert.instanceOf(err, Error);
diff --git a/test/core/utils/contains.js b/test/core/utils/contains.js
index 5361f11d52..cb97255f85 100644
--- a/test/core/utils/contains.js
+++ b/test/core/utils/contains.js
@@ -1,4 +1,4 @@
-describe('utils.contains', function () {
+describe('axe.utils.contains', function () {
'use strict';
var fixture = document.getElementById('fixture');
@@ -22,7 +22,7 @@ describe('utils.contains', function () {
}
};
- utils.contains(node1, node2);
+ axe.utils.contains(node1, node2);
assert.isTrue(success);
});
@@ -36,7 +36,7 @@ describe('utils.contains', function () {
}
};
- utils.contains(node1, node2);
+ axe.utils.contains(node1, node2);
assert.isTrue(success);
});
@@ -48,7 +48,7 @@ describe('utils.contains', function () {
}
};
- assert.isTrue(utils.contains(node1, node2));
+ assert.isTrue(axe.utils.contains(node1, node2));
});
it('should work', function () {
@@ -56,7 +56,7 @@ describe('utils.contains', function () {
var inner = document.getElementById('inner');
var outer = document.getElementById('outer');
- assert.isTrue(utils.contains(outer, inner));
- assert.isFalse(utils.contains(inner, outer));
+ assert.isTrue(axe.utils.contains(outer, inner));
+ assert.isFalse(axe.utils.contains(inner, outer));
});
});
\ No newline at end of file
diff --git a/test/core/utils/dq-element.js b/test/core/utils/dq-element.js
index 6eca8fad45..dc04f5e6db 100644
--- a/test/core/utils/dq-element.js
+++ b/test/core/utils/dq-element.js
@@ -13,7 +13,7 @@ describe('DqElement', function () {
});
it('should be exposed to utils', function () {
- assert.equal(utils.DqElement, DqElement);
+ assert.equal(axe.utils.DqElement, DqElement);
});
it('should take a node as a parameter and return an object', function () {
@@ -81,12 +81,12 @@ describe('DqElement', function () {
describe('selector', function () {
- it('should call utils.getSelector', function () {
- var orig = utils.getSelector;
+ it('should call axe.utils.getSelector', function () {
+ var orig = axe.utils.getSelector;
var success = false;
var expected = { monkeys: 'bananas' };
- utils.getSelector = function (p) {
+ axe.utils.getSelector = function (p) {
success = true;
assert.equal(fixture, p);
return expected;
@@ -94,7 +94,7 @@ describe('DqElement', function () {
var result = new DqElement(fixture);
assert.deepEqual(result.selector, [expected]);
- utils.getSelector = orig;
+ axe.utils.getSelector = orig;
});
diff --git a/test/core/utils/extend-meta-data.js b/test/core/utils/extend-meta-data.js
index b96b41f614..5912544254 100644
--- a/test/core/utils/extend-meta-data.js
+++ b/test/core/utils/extend-meta-data.js
@@ -1,5 +1,5 @@
-describe('utils.extend', function () {
+describe('axe.utils.extend', function () {
'use strict';
it('should merge properties', function () {
@@ -8,7 +8,7 @@ describe('utils.extend', function () {
dogs: 'fail'
};
- utils.extendMetaData(src, {
+ axe.utils.extendMetaData(src, {
cats: 'meow',
dogs: 'woof'
});
@@ -22,7 +22,7 @@ describe('utils.extend', function () {
cats: 'fail',
dogs: 'fail'
};
- utils.extendMetaData(src, {
+ axe.utils.extendMetaData(src, {
cats: function (ctxt) {
assert.equal(ctxt, src);
return 'meow';
@@ -38,7 +38,7 @@ describe('utils.extend', function () {
cats: 'fail',
dogs: 'fail'
};
- utils.extendMetaData(src, {
+ axe.utils.extendMetaData(src, {
cats: function () {
throw new Error('hehe');
},
diff --git a/test/core/utils/finalize-result.js b/test/core/utils/finalize-result.js
index 08e7c5c82f..a1f8efa0a2 100644
--- a/test/core/utils/finalize-result.js
+++ b/test/core/utils/finalize-result.js
@@ -1,5 +1,5 @@
-describe('utils.finalizeRuleResult', function () {
+describe('axe.utils.finalizeRuleResult', function () {
'use strict';
beforeEach(function () {
@@ -7,11 +7,11 @@ describe('utils.finalizeRuleResult', function () {
});
it('should be a function', function () {
- assert.isFunction(utils.finalizeRuleResult);
+ assert.isFunction(axe.utils.finalizeRuleResult);
});
it('should FAIL ruleResult if a failing (return true) none is found', function () {
- var ruleResult = utils.finalizeRuleResult({
+ var ruleResult = axe.utils.finalizeRuleResult({
pageLevel: false,
nodes: [{
none: [{ result: false }],
@@ -34,7 +34,7 @@ describe('utils.finalizeRuleResult', function () {
});
it('should assign FAIL to ruleResult over PASS', function () {
- var ruleResult = utils.finalizeRuleResult({
+ var ruleResult = axe.utils.finalizeRuleResult({
pageLevel: false,
nodes: [{
none: [{ result: false }],
@@ -57,7 +57,7 @@ describe('utils.finalizeRuleResult', function () {
});
it('should assign PASS to ruleResult if there are only passing anys', function () {
- var ruleResult = utils.finalizeRuleResult({
+ var ruleResult = axe.utils.finalizeRuleResult({
pageLevel: false,
nodes: [{
none: [{ result: false }],
@@ -80,7 +80,7 @@ describe('utils.finalizeRuleResult', function () {
});
it('should assign FAIL if there are no passing anys', function () {
- var ruleResult = utils.finalizeRuleResult({
+ var ruleResult = axe.utils.finalizeRuleResult({
pageLevel: false,
nodes: [{
any: [{ result: false }],
@@ -103,7 +103,7 @@ describe('utils.finalizeRuleResult', function () {
});
it('should assign FAIL if there is a single non-passing all', function () {
- var ruleResult = utils.finalizeRuleResult({
+ var ruleResult = axe.utils.finalizeRuleResult({
pageLevel: false,
nodes: [{
any: [{ result: false }],
@@ -126,7 +126,7 @@ describe('utils.finalizeRuleResult', function () {
});
it('should PASS if there are only falsey nones', function () {
- var ruleResult = utils.finalizeRuleResult({
+ var ruleResult = axe.utils.finalizeRuleResult({
pageLevel: false,
nodes: [{
none: [{ result: false }],
@@ -149,7 +149,7 @@ describe('utils.finalizeRuleResult', function () {
});
it('should raise the highest "raisedMetadata" on failing checks', function () {
- var ruleResult = utils.finalizeRuleResult({
+ var ruleResult = axe.utils.finalizeRuleResult({
pageLevel: false,
nodes: [{
none: [{
diff --git a/test/core/utils/find-by.js b/test/core/utils/find-by.js
index ca88971217..0abcb1603a 100644
--- a/test/core/utils/find-by.js
+++ b/test/core/utils/find-by.js
@@ -1,4 +1,4 @@
-describe('utils.findBy', function () {
+describe('axe.utils.findBy', function () {
'use strict';
it('should find the first matching object', function () {
@@ -12,7 +12,7 @@ describe('utils.findBy', function () {
bar: 'baz'
}];
- assert.equal(utils.findBy(array, 'id', 'monkeys'), array[0]);
+ assert.equal(axe.utils.findBy(array, 'id', 'monkeys'), array[0]);
});
it('should return undefined with no match', function () {
@@ -26,12 +26,12 @@ describe('utils.findBy', function () {
bar: 'baz'
}];
- assert.isUndefined(utils.findBy(array, 'id', 'macaque'));
+ assert.isUndefined(axe.utils.findBy(array, 'id', 'macaque'));
});
it('should not throw if passed falsey first parameter', function () {
- assert.isUndefined(utils.findBy(null, 'id', 'macaque'));
+ assert.isUndefined(axe.utils.findBy(null, 'id', 'macaque'));
});
});
\ No newline at end of file
diff --git a/test/core/utils/get-all-checks.js b/test/core/utils/get-all-checks.js
index 75ec4b2454..02f257b96e 100644
--- a/test/core/utils/get-all-checks.js
+++ b/test/core/utils/get-all-checks.js
@@ -1,9 +1,9 @@
-describe('utils.getAllChecks', function () {
+describe('axe.utils.getAllChecks', function () {
'use strict';
it('should be a function', function () {
- assert.isFunction(utils.getAllChecks);
+ assert.isFunction(axe.utils.getAllChecks);
});
it('should concatenate all 3 check collections', function () {
@@ -12,7 +12,7 @@ describe('utils.getAllChecks', function () {
all: ['all:foo', 'all:bar'],
none: ['none:foo', 'none:bar']
};
- assert.deepEqual(utils.getAllChecks(r), [
+ assert.deepEqual(axe.utils.getAllChecks(r), [
'any:foo', 'any:bar',
'all:foo', 'all:bar',
'none:foo', 'none:bar'
@@ -24,7 +24,7 @@ describe('utils.getAllChecks', function () {
any: ['any:foo', 'any:bar'],
none: ['none:foo', 'none:bar']
};
- assert.deepEqual(utils.getAllChecks(r), [
+ assert.deepEqual(axe.utils.getAllChecks(r), [
'any:foo', 'any:bar',
'none:foo', 'none:bar'
]);
@@ -36,7 +36,7 @@ describe('utils.getAllChecks', function () {
all: ['all:foo', 'all:bar'],
none: ['none:foo', 'none:bar']
};
- assert.deepEqual(utils.getAllChecks(r), [
+ assert.deepEqual(axe.utils.getAllChecks(r), [
'all:foo', 'all:bar',
'none:foo', 'none:bar'
]);
@@ -48,7 +48,7 @@ describe('utils.getAllChecks', function () {
any: ['any:foo', 'any:bar'],
all: ['all:foo', 'all:bar']
};
- assert.deepEqual(utils.getAllChecks(r), [
+ assert.deepEqual(axe.utils.getAllChecks(r), [
'any:foo', 'any:bar',
'all:foo', 'all:bar'
]);
diff --git a/test/core/utils/get-check-option.js b/test/core/utils/get-check-option.js
index 5dc4068d04..73e7729425 100644
--- a/test/core/utils/get-check-option.js
+++ b/test/core/utils/get-check-option.js
@@ -1,9 +1,9 @@
-describe('utils.getCheckOption', function () {
+describe('axe.utils.getCheckOption', function () {
'use strict';
it('should prefer options from rules', function () {
- assert.deepEqual(utils.getCheckOption({
+ assert.deepEqual(axe.utils.getCheckOption({
id: 'bananas',
enabled: 'fail',
options: 'fail'
@@ -30,7 +30,7 @@ describe('utils.getCheckOption', function () {
});
});
it('should fallback to global check options if not defined on the rule', function () {
- assert.deepEqual(utils.getCheckOption({
+ assert.deepEqual(axe.utils.getCheckOption({
id: 'bananas',
enabled: 'fail',
options: 'fail'
@@ -57,7 +57,7 @@ describe('utils.getCheckOption', function () {
});
it('should prefer fallback to global check options if not defined on the rule', function () {
- assert.deepEqual(utils.getCheckOption({
+ assert.deepEqual(axe.utils.getCheckOption({
id: 'bananas',
enabled: 'fail',
options: 'fail'
@@ -75,7 +75,7 @@ describe('utils.getCheckOption', function () {
});
it('should otherwise use the check', function () {
- assert.deepEqual(utils.getCheckOption({
+ assert.deepEqual(axe.utils.getCheckOption({
id: 'bananas',
enabled: 'yes',
options: 'please'
diff --git a/test/core/utils/get-selector.js b/test/core/utils/get-selector.js
index 9bc3bcb209..8a0676bff6 100644
--- a/test/core/utils/get-selector.js
+++ b/test/core/utils/get-selector.js
@@ -1,4 +1,4 @@
-describe('utils.getSelector', function () {
+describe('axe.utils.getSelector', function () {
'use strict';
var fixture = document.getElementById('fixture');
@@ -8,14 +8,14 @@ describe('utils.getSelector', function () {
});
it('should be a function', function () {
- assert.isFunction(utils.getSelector);
+ assert.isFunction(axe.utils.getSelector);
});
it('should generate a unique CSS selector', function () {
var node = document.createElement('div');
fixture.appendChild(node);
- var sel = utils.getSelector(node);
+ var sel = axe.utils.getSelector(node);
assert.equal(sel, '#fixture > div');
@@ -29,7 +29,7 @@ describe('utils.getSelector', function () {
node.className = ' ';
fixture.appendChild(node);
- var sel = utils.getSelector(node);
+ var sel = axe.utils.getSelector(node);
assert.equal(sel, '#fixture > div');
@@ -43,7 +43,7 @@ describe('utils.getSelector', function () {
node.id = 'monkeys#are.animals\\ok';
fixture.appendChild(node);
- var result = document.querySelectorAll(utils.getSelector(node));
+ var result = document.querySelectorAll(axe.utils.getSelector(node));
assert.lengthOf(result, 1);
assert.equal(result[0], node);
});
@@ -53,7 +53,7 @@ describe('utils.getSelector', function () {
node.className = '. bb-required';
fixture.appendChild(node);
- var result = document.querySelectorAll(utils.getSelector(node));
+ var result = document.querySelectorAll(axe.utils.getSelector(node));
assert.lengthOf(result, 1);
assert.equal(result[0], node);
});
@@ -68,7 +68,7 @@ describe('utils.getSelector', function () {
}
}
- var result = document.querySelectorAll(utils.getSelector(expected));
+ var result = document.querySelectorAll(axe.utils.getSelector(expected));
assert.lengthOf(result, 1);
assert.equal(result[0], expected);
});
@@ -78,7 +78,7 @@ describe('utils.getSelector', function () {
node.id = 'monkeys';
fixture.appendChild(node);
- var sel = utils.getSelector(node);
+ var sel = axe.utils.getSelector(node);
assert.equal(sel, '#monkeys');
@@ -97,7 +97,7 @@ describe('utils.getSelector', function () {
node.id = 'monkeys';
fixture.appendChild(node);
- var sel = utils.getSelector(node);
+ var sel = axe.utils.getSelector(node);
assert.equal(sel, '#fixture > div:nth-of-type(2)');
@@ -116,7 +116,7 @@ describe('utils.getSelector', function () {
node.className = 'dogs cats';
fixture.appendChild(node);
- var sel = utils.getSelector(node);
+ var sel = axe.utils.getSelector(node);
assert.equal(sel, '#fixture > .dogs.cats');
@@ -135,7 +135,7 @@ describe('utils.getSelector', function () {
node.className = 'monkeys simian';
fixture.appendChild(node);
- var sel = utils.getSelector(node);
+ var sel = axe.utils.getSelector(node);
assert.equal(sel, '#fixture > div:nth-of-type(2)');
@@ -168,7 +168,7 @@ describe('utils.getSelector', function () {
- var sel = utils.getSelector(target);
+ var sel = axe.utils.getSelector(target);
assert.equal(sel, '#fixture > div:nth-of-type(2)');
@@ -179,7 +179,7 @@ describe('utils.getSelector', function () {
});
it('should work on the documentElement', function () {
- var sel = utils.getSelector(document.documentElement);
+ var sel = axe.utils.getSelector(document.documentElement);
var result = document.querySelectorAll(sel);
assert.lengthOf(result, 1);
assert.equal(result[0], document.documentElement);
@@ -188,7 +188,7 @@ describe('utils.getSelector', function () {
it('should work on the documentElement with classes', function () {
var orig = document.documentElement.className;
document.documentElement.className = 'stuff and other things';
- var sel = utils.getSelector(document.documentElement);
+ var sel = axe.utils.getSelector(document.documentElement);
var result = document.querySelectorAll(sel);
assert.lengthOf(result, 1);
assert.equal(result[0], document.documentElement);
@@ -196,7 +196,7 @@ describe('utils.getSelector', function () {
});
it('should work on the body', function () {
- var sel = utils.getSelector(document.body);
+ var sel = axe.utils.getSelector(document.body);
var result = document.querySelectorAll(sel);
assert.lengthOf(result, 1);
assert.equal(result[0], document.body);
@@ -205,14 +205,14 @@ describe('utils.getSelector', function () {
it('should work on namespaced elements', function () {
fixture.innerHTML = 'Hello';
var node = fixture.firstChild;
- var sel = utils.getSelector(node);
+ var sel = axe.utils.getSelector(node);
var result = document.querySelectorAll(sel);
assert.lengthOf(result, 1);
assert.equal(result[0], node);
});
it('shouldn\'t fail if the node\'s parentNode doesnt have children, somehow (Firefox bug)', function () {
- var sel = utils.getSelector({
+ var sel = axe.utils.getSelector({
nodeName: 'a',
parentNode: {
nodeName: 'b'
diff --git a/test/core/utils/is-hidden.js b/test/core/utils/is-hidden.js
index a4c761e4bf..1fad1e0785 100644
--- a/test/core/utils/is-hidden.js
+++ b/test/core/utils/is-hidden.js
@@ -1,4 +1,4 @@
-describe('utils.isHidden', function () {
+describe('axe.utils.isHidden', function () {
'use strict';
var fixture = document.getElementById('fixture');
@@ -8,39 +8,39 @@ describe('utils.isHidden', function () {
});
it('should be a function', function () {
- assert.isFunction(utils.isHidden);
+ assert.isFunction(axe.utils.isHidden);
});
it('should return false on detached elements', function () {
var el = document.createElement('div');
el.innerHTML = 'I am not visible because I am detached!';
- assert.isTrue(utils.isHidden(el));
+ assert.isTrue(axe.utils.isHidden(el));
});
it('should return false on a document', function () {
- assert.isFalse(utils.isHidden(document));
+ assert.isFalse(axe.utils.isHidden(document));
});
it('should return true if `aria-hidden` is set', function () {
fixture.innerHTML = '
Hidden from screen readers
';
var el = document.getElementById('target');
- assert.isTrue(utils.isHidden(el));
+ assert.isTrue(axe.utils.isHidden(el));
});
it('should return true if `display: none` is set', function () {
fixture.innerHTML = '
Hidden from screen readers
';
var el = document.getElementById('target');
- assert.isTrue(utils.isHidden(el));
+ assert.isTrue(axe.utils.isHidden(el));
});
it('should return true if `aria-hidden` is set on parent', function () {
fixture.innerHTML = '
Hidden from screen readers
';
var el = document.getElementById('target');
- assert.isTrue(utils.isHidden(el));
+ assert.isTrue(axe.utils.isHidden(el));
});
it('should know how `visibility` works', function () {
@@ -49,7 +49,7 @@ describe('utils.isHidden', function () {
'';
var el = document.getElementById('target');
- assert.isFalse(utils.isHidden(el));
+ assert.isFalse(axe.utils.isHidden(el));
});
diff --git a/test/core/utils/merge-results.js b/test/core/utils/merge-results.js
index 7485eb4ca8..f8c83bcfb9 100644
--- a/test/core/utils/merge-results.js
+++ b/test/core/utils/merge-results.js
@@ -1,8 +1,8 @@
-describe('utils.mergeResults', function () {
+describe('axe.utils.mergeResults', function () {
'use strict';
it('should normalize empty results', function () {
- var result = utils.mergeResults([{ results: [] }, { results: [{ id: 'a', result: 'b'}]}]);
+ var result = axe.utils.mergeResults([{ results: [] }, { results: [{ id: 'a', result: 'b'}]}]);
assert.deepEqual(result, [{
id: 'a',
result: 'b'
diff --git a/test/core/utils/node-sorter.js b/test/core/utils/node-sorter.js
index 41baefd4a5..1b50568e7c 100644
--- a/test/core/utils/node-sorter.js
+++ b/test/core/utils/node-sorter.js
@@ -1,4 +1,4 @@
-describe('utils.nodeSorter', function () {
+describe('axe.utils.nodeSorter', function () {
'use strict';
function $id(id) {
@@ -9,36 +9,36 @@ describe('utils.nodeSorter', function () {
var fixture = document.getElementById('fixture');
it('should exist', function () {
- assert.isFunction(utils.nodeSorter);
+ assert.isFunction(axe.utils.nodeSorter);
});
it('should return -1 if a comes before b', function () {
fixture.innerHTML = '';
- assert.equal(utils.nodeSorter($id('a'), $id('b')), -1);
+ assert.equal(axe.utils.nodeSorter($id('a'), $id('b')), -1);
});
it('should return -1 if a comes before b - nested', function () {
fixture.innerHTML = '
';
- assert.equal(utils.nodeSorter($id('a'), $id('b')), -1);
+ assert.equal(axe.utils.nodeSorter($id('a'), $id('b')), -1);
});
it('should return 1 if b comes before a', function () {
fixture.innerHTML = '';
- assert.equal(utils.nodeSorter($id('a'), $id('b')), 1);
+ assert.equal(axe.utils.nodeSorter($id('a'), $id('b')), 1);
});
it('should return 1 if b comes before a - nested', function () {
fixture.innerHTML = '
';
- assert.equal(utils.nodeSorter($id('a'), $id('b')), 1);
+ assert.equal(axe.utils.nodeSorter($id('a'), $id('b')), 1);
});
it('should return 0 if a === b', function () {
fixture.innerHTML = '';
- assert.equal(utils.nodeSorter($id('a'), $id('a')), 0);
+ assert.equal(axe.utils.nodeSorter($id('a'), $id('a')), 0);
});
});
\ No newline at end of file
diff --git a/test/core/utils/publish-metadata.js b/test/core/utils/publish-metadata.js
index f671838ce3..cb656c929c 100644
--- a/test/core/utils/publish-metadata.js
+++ b/test/core/utils/publish-metadata.js
@@ -1,4 +1,4 @@
-describe('utils.publishMetaData', function () {
+describe('axe.utils.publishMetaData', function () {
'use strict';
afterEach(function () {
@@ -6,7 +6,7 @@ describe('utils.publishMetaData', function () {
});
it('should be a function', function () {
- assert.isFunction(utils.publishMetaData);
+ assert.isFunction(axe.utils.publishMetaData);
});
it('should pull data from rules from axe._audit.data', function () {
@@ -28,7 +28,7 @@ describe('utils.publishMetaData', function () {
id: 'cats',
nodes: []
};
- utils.publishMetaData(result);
+ axe.utils.publishMetaData(result);
assert.equal(result.foo, expected.foo);
assert.equal(result.bob, expected.bob);
@@ -59,7 +59,7 @@ describe('utils.publishMetaData', function () {
none: []
}]
};
- utils.publishMetaData(result);
+ axe.utils.publishMetaData(result);
assert.equal(result.nodes[0].any[0].foo, expected.foo);
assert.equal(result.nodes[0].any[0].bar, expected.bar);
});
@@ -142,7 +142,7 @@ describe('utils.publishMetaData', function () {
}]
}]
};
- utils.publishMetaData(result);
+ axe.utils.publishMetaData(result);
assert.deepEqual(result, {
id: 'cats',
help: 'cats-rule',
@@ -215,7 +215,7 @@ describe('utils.publishMetaData', function () {
}
}
});
- utils.publishMetaData({
+ axe.utils.publishMetaData({
id: 'cats',
nodes: [{
any: [{
@@ -267,7 +267,7 @@ describe('utils.publishMetaData', function () {
none: []
}]
};
- utils.publishMetaData(result);
+ axe.utils.publishMetaData(result);
assert.deepEqual(result.tags, ['hai']);
});
diff --git a/test/core/utils/queue.js b/test/core/utils/queue.js
index e6e2937312..1fb7e7badd 100644
--- a/test/core/utils/queue.js
+++ b/test/core/utils/queue.js
@@ -1,18 +1,18 @@
-describe('utils.queue', function () {
+describe('axe.utils.queue', function () {
'use strict';
it('should be a function', function () {
- assert.isFunction(utils.queue);
+ assert.isFunction(axe.utils.queue);
});
describe('defer', function () {
it('should be a function', function () {
- var q = utils.queue();
+ var q = axe.utils.queue();
assert.isFunction(q.defer);
});
- it('should push onto the "utils.queue"', function (done) {
- var q = utils.queue();
+ it('should push onto the "axe.utils.queue"', function (done) {
+ var q = axe.utils.queue();
q.defer(function (resolve) {
setTimeout(function () {
@@ -33,7 +33,7 @@ describe('utils.queue', function () {
});
it('should execute resolve immediately if defered functions are already complete', function () {
- var q = utils.queue(),
+ var q = axe.utils.queue(),
complete = false;
q.defer(function (resolve) {
@@ -54,14 +54,14 @@ describe('utils.queue', function () {
});
it('is chainable', function () {
- var q = utils.queue();
+ var q = axe.utils.queue();
assert.equal(q, q.defer(function () {}));
});
it('throws if then was already called', function () {
assert.throws(function () {
- var q = utils.queue();
+ var q = axe.utils.queue();
q.defer(function (resolve) {
resolve();
});
@@ -75,8 +75,8 @@ describe('utils.queue', function () {
});
it('can await another queue', function (done) {
- var q1 = utils.queue();
- var q2 = utils.queue();
+ var q1 = axe.utils.queue();
+ var q2 = axe.utils.queue();
q1.defer(function (resolve) {
setTimeout(function () {
@@ -95,12 +95,12 @@ describe('utils.queue', function () {
describe('then', function () {
it('should be a function', function () {
- var q = utils.queue();
+ var q = axe.utils.queue();
assert.isFunction(q.then);
});
- it('should execute immediately if utils.queue is complete', function () {
- var q = utils.queue();
+ it('should execute immediately if axe.utils.queue is complete', function () {
+ var q = axe.utils.queue();
var result = false;
q.then(function () {
@@ -111,13 +111,13 @@ describe('utils.queue', function () {
});
it('is chainable', function () {
- var q = utils.queue();
+ var q = axe.utils.queue();
assert.equal(q, q.then(function () {}));
});
it('throws when called more than once', function () {
assert.throws(function () {
- var q = utils.queue();
+ var q = axe.utils.queue();
q.defer(function () {});
q.then(function () {});
q.then(function () {});
@@ -128,13 +128,13 @@ describe('utils.queue', function () {
describe('abort', function () {
it('should be a function', function () {
- var q = utils.queue();
+ var q = axe.utils.queue();
assert.isFunction(q.abort);
});
it('stops `then` from being called', function (done) {
- var q = utils.queue();
+ var q = axe.utils.queue();
q.defer(function (resolve) {
setTimeout(function () {
@@ -157,7 +157,7 @@ describe('utils.queue', function () {
});
it('sends a message to `catch`', function (done) {
- var q = utils.queue();
+ var q = axe.utils.queue();
q.defer(function () {});
q.then(function () {});
@@ -173,7 +173,7 @@ describe('utils.queue', function () {
describe('catch', function () {
it('is called when defer throws an error', function (done) {
- var q = utils.queue();
+ var q = axe.utils.queue();
q.defer(function () {
throw 'error! 1';
});
@@ -185,7 +185,7 @@ describe('utils.queue', function () {
});
it('can catch error synchronously', function (done) {
- var q = utils.queue();
+ var q = axe.utils.queue();
var sync = true;
q.defer(function () {
throw 'error! 2';
@@ -200,7 +200,7 @@ describe('utils.queue', function () {
});
it('is called when the reject method is called', function (done) {
- var q = utils.queue();
+ var q = axe.utils.queue();
var errorsCaught = 0;
q.defer(function (resolve, reject) {
@@ -217,7 +217,7 @@ describe('utils.queue', function () {
});
it('will not run `then` if an error is thrown', function (done) {
- var q = utils.queue();
+ var q = axe.utils.queue();
q.defer(function () {
throw 'error! 3';
});
@@ -232,7 +232,7 @@ describe('utils.queue', function () {
});
it('does not continue other tasks if an error occurs', function (done) {
- var q = utils.queue();
+ var q = axe.utils.queue();
var aborted;
q.defer(function () {
throw 'error! 3';
@@ -254,13 +254,13 @@ describe('utils.queue', function () {
});
it('is chainable', function () {
- var q = utils.queue();
+ var q = axe.utils.queue();
assert.equal(q, q.catch(function () {}));
});
it('throws when called more than once', function () {
assert.throws(function () {
- var q = utils.queue();
+ var q = axe.utils.queue();
q.defer(function () {});
q.catch(function () {});
q.catch(function () {});
diff --git a/test/core/utils/respondable.js b/test/core/utils/respondable.js
index 3489c8b177..fc5e35cefc 100644
--- a/test/core/utils/respondable.js
+++ b/test/core/utils/respondable.js
@@ -1,4 +1,4 @@
-describe('utils.respondable', function () {
+describe('axe.utils.respondable', function () {
'use strict';
var mockUUID;
@@ -18,11 +18,11 @@ describe('utils.respondable', function () {
});
it('should be a function', function () {
- assert.isFunction(utils.respondable);
+ assert.isFunction(axe.utils.respondable);
});
it('should accept 5 parameters', function () {
- assert.lengthOf(utils.respondable, 5);
+ assert.lengthOf(axe.utils.respondable, 5);
});
it('should call `postMessage` on first parameter', function () {
@@ -33,7 +33,7 @@ describe('utils.respondable', function () {
}
};
- utils.respondable(win, 'batman', 'nananana');
+ axe.utils.respondable(win, 'batman', 'nananana');
assert.isTrue(success);
});
@@ -45,7 +45,7 @@ describe('utils.respondable', function () {
}
};
- utils.respondable(win, 'batman', { derp: true });
+ axe.utils.respondable(win, 'batman', { derp: true });
});
@@ -60,7 +60,7 @@ describe('utils.respondable', function () {
}
};
- utils.respondable(win, 'batman', 'nananana');
+ axe.utils.respondable(win, 'batman', 'nananana');
});
it('should add the `keepalive`', function (done) {
@@ -73,7 +73,7 @@ describe('utils.respondable', function () {
}
};
- utils.respondable(win, 'superman', 'spidey', 'batman');
+ axe.utils.respondable(win, 'superman', 'spidey', 'batman');
});
it('should add `_respondable` to the message', function (done) {
@@ -86,7 +86,7 @@ describe('utils.respondable', function () {
}
};
- utils.respondable(win, 'batman', 'nananana');
+ axe.utils.respondable(win, 'batman', 'nananana');
});
it('should create a uuid.v1 (time-based uuid)', function () {
@@ -105,7 +105,7 @@ describe('utils.respondable', function () {
return UUID;
};
- utils.respondable(win, 'batman', 'nananana');
+ axe.utils.respondable(win, 'batman', 'nananana');
assert.isTrue(success);
window.uuid.v1 = orig;
@@ -124,7 +124,7 @@ describe('utils.respondable', function () {
});
event.source = window;
- utils.respondable(window, 'Death star', null, true, function (data) {
+ axe.utils.respondable(window, 'Death star', null, true, function (data) {
success = true;
assert.equal(data, 'Help us Obi-Wan');
});
@@ -144,7 +144,7 @@ describe('utils.respondable', function () {
};
event.source = window;
- utils.respondable(window, 'batman', 'nananana', true, function () {
+ axe.utils.respondable(window, 'batman', 'nananana', true, function () {
success = false;
});
document.dispatchEvent(event);
@@ -164,7 +164,7 @@ describe('utils.respondable', function () {
}) + 'joker tricks!';
event.source = window;
- utils.respondable(window, 'batman', 'nananana', true, function () {
+ axe.utils.respondable(window, 'batman', 'nananana', true, function () {
success = false;
});
document.dispatchEvent(event);
@@ -184,7 +184,7 @@ describe('utils.respondable', function () {
});
event.source = window;
- utils.respondable(window, 'batman', 'nananana', true, function () {
+ axe.utils.respondable(window, 'batman', 'nananana', true, function () {
success = false;
});
document.dispatchEvent(event);
@@ -205,7 +205,7 @@ describe('utils.respondable', function () {
});
event.source = window;
- utils.respondable(window, 'batman', 'nananana', true, function () {
+ axe.utils.respondable(window, 'batman', 'nananana', true, function () {
success = false;
});
document.dispatchEvent(event);
@@ -225,7 +225,7 @@ describe('utils.respondable', function () {
});
event.source = window;
- utils.respondable(window, 'batman', 'nananana', true, function () {
+ axe.utils.respondable(window, 'batman', 'nananana', true, function () {
success = false;
});
document.dispatchEvent(event);
@@ -249,7 +249,7 @@ describe('utils.respondable', function () {
});
event.source = window;
- utils.respondable(window, 'Death star', null, true, function (data) {
+ axe.utils.respondable(window, 'Death star', null, true, function (data) {
success = true;
assert.instanceOf(data, ReferenceError);
assert.equal(data.message, 'The exhaust port is open!');
@@ -262,18 +262,18 @@ describe('utils.respondable', function () {
describe('subscribe', function () {
it('should be a function', function () {
- assert.isFunction(utils.respondable.subscribe);
+ assert.isFunction(axe.utils.respondable.subscribe);
});
it('should receive messages', function (done) {
var expected = null;
- utils.respondable.subscribe('catman', function (data) {
+ axe.utils.respondable.subscribe('catman', function (data) {
assert.equal(data, expected);
if (data === 'yay') {
done();
}
});
- utils.respondable(window, 'catman', null, undefined, function (data, keepalive, respond) {
+ axe.utils.respondable(window, 'catman', null, undefined, function (data, keepalive, respond) {
assert.isNull(data);
setTimeout(function () {
respond('yay');
@@ -285,13 +285,13 @@ describe('utils.respondable', function () {
it('should propagate the keepalive setting', function (done) {
var expected = null;
- utils.respondable.subscribe('catman', function (data, keepalive) {
+ axe.utils.respondable.subscribe('catman', function (data, keepalive) {
assert.equal(keepalive, expected);
if (data === 'yayyay') {
done();
}
});
- utils.respondable(window, 'catman', null, undefined, function (data, keepalive, respond) {
+ axe.utils.respondable(window, 'catman', null, undefined, function (data, keepalive, respond) {
assert.isNull(data);
setTimeout(function () {
expected = 'keepy';
@@ -303,7 +303,7 @@ describe('utils.respondable', function () {
it('should allow multiple responses when keepalive', function (done) {
var expected = 2;
var called = 0;
- utils.respondable.subscribe('catman', function (data) {
+ axe.utils.respondable.subscribe('catman', function (data) {
if (data === 'yayyayyay') {
called += 1;
if (called === expected) {
@@ -311,7 +311,7 @@ describe('utils.respondable', function () {
}
}
});
- utils.respondable(window, 'catman', null, undefined, function (data, keepalive, respond) {
+ axe.utils.respondable(window, 'catman', null, undefined, function (data, keepalive, respond) {
assert.isNull(data);
setTimeout(function () {
respond('yayyayyay', true);
@@ -324,12 +324,12 @@ describe('utils.respondable', function () {
it('does not trigger for error messages', function (done) {
var published = false;
- utils.respondable.subscribe('catman', function () {
+ axe.utils.respondable.subscribe('catman', function () {
published = true;
});
var err = new ReferenceError('whoopsy');
- utils.respondable(window, 'catman', err);
+ axe.utils.respondable(window, 'catman', err);
setTimeout(function () {
assert.ok(!published, 'Error events should not trigger');
done();
@@ -339,12 +339,12 @@ describe('utils.respondable', function () {
it('returns an error if the subscribe method responds with an error', function (done) {
var expected = 'Expected owlman to be batman';
var wait = true;
- utils.respondable.subscribe('owlman', function (data, keepalive, respond) {
+ axe.utils.respondable.subscribe('owlman', function (data, keepalive, respond) {
wait = false;
respond(new TypeError(expected));
});
- utils.respondable(window, 'owlman', 'help!', true,
+ axe.utils.respondable(window, 'owlman', 'help!', true,
function (data) {
if (!wait) {
assert.instanceOf(data, TypeError);
@@ -357,7 +357,7 @@ describe('utils.respondable', function () {
it('returns an error if the subscribe method throws', function (done) {
var wait = true;
var expected = 'Expected owlman to be batman';
- utils.respondable.subscribe('owlman', function () {
+ axe.utils.respondable.subscribe('owlman', function () {
wait = false;
throw new TypeError(expected);
});
@@ -365,7 +365,7 @@ describe('utils.respondable', function () {
// use keepalive, because we're running on the same window,
// otherwise it would delete the response before subscribe
// gets to react
- utils.respondable(window, 'owlman', null, true,
+ axe.utils.respondable(window, 'owlman', null, true,
function (data) {
if (!wait) {
assert.instanceOf(data, TypeError);
diff --git a/test/core/utils/rule-should-run.js b/test/core/utils/rule-should-run.js
index 3afd594d08..2c64cf29d0 100644
--- a/test/core/utils/rule-should-run.js
+++ b/test/core/utils/rule-should-run.js
@@ -1,9 +1,9 @@
-describe('utils.ruleShouldRun', function () {
+describe('axe.utils.ruleShouldRun', function () {
'use strict';
it('should return false if rule.pageOnly and !context.page', function () {
- assert.isFalse(utils.ruleShouldRun({
+ assert.isFalse(axe.utils.ruleShouldRun({
pageLevel: true
}, {
page: false
@@ -11,7 +11,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should return false if rule.enabled is false, option.enabled is false and ruleID is not present runOnly', function () {
- assert.isFalse(utils.ruleShouldRun({
+ assert.isFalse(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: false
}, {}, {
@@ -28,7 +28,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should return true if rule.enabled is false, option.enabled is false and ruleID is present in runOnly', function () {
- assert.isTrue(utils.ruleShouldRun({
+ assert.isTrue(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: false
}, {}, {
@@ -45,7 +45,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should return true if rule.enabled is false, option is undefined and ruleID is present in runOnly', function () {
- assert.isTrue(utils.ruleShouldRun({
+ assert.isTrue(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: false
}, {}, {
@@ -57,7 +57,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should return false even if enabled is set to true if ruleID is not present in runOnly', function () {
- assert.isFalse(utils.ruleShouldRun({
+ assert.isFalse(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: true
}, {}, {
@@ -69,7 +69,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should return false if rule.enabled is false', function () {
- assert.isFalse(utils.ruleShouldRun({
+ assert.isFalse(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: false,
tags: ['fruit']
@@ -78,7 +78,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should return true if rule.enabled is true', function () {
- assert.isTrue(utils.ruleShouldRun({
+ assert.isTrue(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: true,
tags: ['fruit']
@@ -87,7 +87,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should return true if option is set to true but rule is set to false', function () {
- assert.isTrue(utils.ruleShouldRun({
+ assert.isTrue(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: false
}, {}, {
@@ -102,7 +102,7 @@ describe('utils.ruleShouldRun', function () {
it('should return false if option is set to false but rule is set to true', function () {
- assert.isFalse(utils.ruleShouldRun({
+ assert.isFalse(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: true
}, {}, {
@@ -116,7 +116,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should use option.rules.enabled over option.runOnly tags', function () {
- assert.isTrue(utils.ruleShouldRun({
+ assert.isTrue(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: true,
tags: ['fruit']
@@ -132,7 +132,7 @@ describe('utils.ruleShouldRun', function () {
}
}));
- assert.isFalse(utils.ruleShouldRun({
+ assert.isFalse(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: true,
tags: ['fruit']
@@ -155,7 +155,7 @@ describe('utils.ruleShouldRun', function () {
describe('runOnly type:tag', function () {
it('should return true if passed an array with a matching tag', function () {
- assert.isTrue(utils.ruleShouldRun({
+ assert.isTrue(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: false,
tags: ['fruit']
@@ -169,7 +169,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should return false if passed an array with a matching tag', function () {
- assert.isFalse(utils.ruleShouldRun({
+ assert.isFalse(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: true,
tags: ['fruit']
@@ -183,7 +183,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should accept string as an include value', function () {
- assert.isTrue(utils.ruleShouldRun({
+ assert.isTrue(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: false,
tags: ['fruit']
@@ -198,7 +198,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should accept array as an include value', function () {
- assert.isTrue(utils.ruleShouldRun({
+ assert.isTrue(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: false,
tags: ['fruit']
@@ -213,7 +213,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should accept string as an exclude value', function () {
- assert.isFalse(utils.ruleShouldRun({
+ assert.isFalse(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: false,
tags: ['fruit', 'tasty']
@@ -228,7 +228,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should accept array as an exclude value', function () {
- assert.isFalse(utils.ruleShouldRun({
+ assert.isFalse(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: false,
tags: ['fruit']
@@ -243,7 +243,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should return true if it matches include but not exclude', function () {
- assert.isTrue(utils.ruleShouldRun({
+ assert.isTrue(axe.utils.ruleShouldRun({
id: 'cabbage',
enabled: false,
tags: ['veggie']
@@ -259,7 +259,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should return false if it matches no include', function () {
- assert.isFalse(utils.ruleShouldRun({
+ assert.isFalse(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: false,
tags: ['fruit']
@@ -275,7 +275,7 @@ describe('utils.ruleShouldRun', function () {
});
it('should return false if it matches include and exclude', function () {
- assert.isFalse(utils.ruleShouldRun({
+ assert.isFalse(axe.utils.ruleShouldRun({
id: 'bananas',
enabled: false,
tags: ['fruit', 'tasty']
diff --git a/test/core/utils/select.js b/test/core/utils/select.js
index 66fa3c3561..57456931df 100644
--- a/test/core/utils/select.js
+++ b/test/core/utils/select.js
@@ -1,5 +1,5 @@
-describe('utils.select', function () {
+describe('axe.utils.select', function () {
'use strict';
function $id(id) {
@@ -14,11 +14,11 @@ describe('utils.select', function () {
it('should be a function', function () {
- assert.isFunction(utils.select);
+ assert.isFunction(axe.utils.select);
});
it('should return an array', function () {
- assert.isArray(utils.select('div', { include: [] }));
+ assert.isArray(axe.utils.select('div', { include: [] }));
});
describe('selector', function () {
@@ -28,7 +28,7 @@ describe('utils.select', function () {
div.id = 'monkeys';
fixture.appendChild(div);
- var result = utils.select('#monkeys', { include: [document] });
+ var result = axe.utils.select('#monkeys', { include: [document] });
assert.equal(result[0], div);
@@ -40,7 +40,7 @@ describe('utils.select', function () {
it('should include', function () {
fixture.innerHTML = '
';
- var result = utils.select('.bananas', {
+ var result = axe.utils.select('.bananas', {
include: [$id('monkeys')]
});
@@ -51,7 +51,7 @@ describe('utils.select', function () {
it('should exclude', function () {
fixture.innerHTML = '
';
- var result = utils.select('.bananas', {
+ var result = axe.utils.select('.bananas', {
include: [$id('fixture')],
exclude: [$id('monkeys')]
});
@@ -72,7 +72,7 @@ describe('utils.select', function () {
'';
- var result = utils.select('.bananas', {
+ var result = axe.utils.select('.bananas', {
include: [$id('include1'), $id('include2')],
exclude: [$id('exclude1'), $id('exclude2')]
});
@@ -95,7 +95,7 @@ describe('utils.select', function () {
'';
- var result = utils.select('.bananas', {
+ var result = axe.utils.select('.bananas', {
include: [$id('include3'), $id('include2'), $id('include1')],
exclude: [$id('exclude1'), $id('exclude2')]
});
@@ -109,7 +109,7 @@ describe('utils.select', function () {
it('should only contain unique elements', function () {
fixture.innerHTML = '
';
- var result = utils.select('.bananas', { include: [$id('fixture'), $id('monkeys')] });
+ var result = axe.utils.select('.bananas', { include: [$id('fixture'), $id('monkeys')] });
assert.lengthOf(result, 1);
assert.equal(result[0], $id('bananas'));
@@ -120,7 +120,7 @@ describe('utils.select', function () {
fixture.innerHTML = '
' +
'
';
- var result = utils.select('.bananas', { include: [$id('two'), $id('one')] });
+ var result = axe.utils.select('.bananas', { include: [$id('two'), $id('one')] });
assert.deepEqual(result, [$id('target1'), $id('target2')]);
diff --git a/test/core/utils/send-command-to-frame.js b/test/core/utils/send-command-to-frame.js
index 0662d0d149..e606bba534 100644
--- a/test/core/utils/send-command-to-frame.js
+++ b/test/core/utils/send-command-to-frame.js
@@ -1,4 +1,4 @@
-describe('utils.sendCommandToFrame', function () {
+describe('axe.utils.sendCommandToFrame', function () {
'use strict';
var fixture = document.getElementById('fixture');
@@ -25,7 +25,7 @@ describe('utils.sendCommandToFrame', function () {
var frame = document.createElement('iframe');
frame.addEventListener('load', function () {
- utils.sendCommandToFrame(frame, {}, function (result) {
+ axe.utils.sendCommandToFrame(frame, {}, function (result) {
assert.equal(result, null);
done();
}, assertNotCalled);
@@ -41,7 +41,7 @@ describe('utils.sendCommandToFrame', function () {
it('should respond once when no keepalive', function (done) {
var frame = document.createElement('iframe');
frame.addEventListener('load', function () {
- utils.sendCommandToFrame(frame, {
+ axe.utils.sendCommandToFrame(frame, {
number: 1
}, function () {
assert.isTrue(true);
@@ -60,7 +60,7 @@ describe('utils.sendCommandToFrame', function () {
var called = 0;
var frame = document.createElement('iframe');
frame.addEventListener('load', function () {
- utils.sendCommandToFrame(frame, {
+ axe.utils.sendCommandToFrame(frame, {
number: number,
keepalive: true
}, function () {
@@ -83,7 +83,7 @@ describe('utils.sendCommandToFrame', function () {
var called = 0;
var frame = document.createElement('iframe');
frame.addEventListener('load', function () {
- utils.sendCommandToFrame(frame, {
+ axe.utils.sendCommandToFrame(frame, {
number: number
}, function () {
called += 1;
diff --git a/test/core/utils/to-array.js b/test/core/utils/to-array.js
index c9b9e31dbe..315331b750 100644
--- a/test/core/utils/to-array.js
+++ b/test/core/utils/to-array.js
@@ -1,4 +1,4 @@
-describe('utils.toArray', function () {
+describe('axe.utils.toArray', function () {
'use strict';
it('should call Array.prototype.slice', function () {
@@ -11,7 +11,7 @@ describe('utils.toArray', function () {
assert.equal(this, arrayLike);
};
- utils.toArray(arrayLike);
+ axe.utils.toArray(arrayLike);
assert.isTrue(called);
@@ -21,7 +21,7 @@ describe('utils.toArray', function () {
it('should return an array', function () {
var arrayLike = {'0': 'cats', length: 1};
- var result = utils.toArray(arrayLike);
+ var result = axe.utils.toArray(arrayLike);
assert.isArray(result);
});
});
\ No newline at end of file