diff --git a/lib/commons/text/form-control-value.js b/lib/commons/text/form-control-value.js
index e892781aa5..b4ef057cc0 100644
--- a/lib/commons/text/form-control-value.js
+++ b/lib/commons/text/form-control-value.js
@@ -13,7 +13,7 @@ import isHiddenForEveryone from '../dom/is-hidden-for-everyone';
import { nodeLookup, querySelectorAll } from '../../core/utils';
import log from '../../core/log';
-const controlValueRoles = [
+export const controlValueRoles = [
'textbox',
'progressbar',
'scrollbar',
diff --git a/lib/commons/text/subtree-text.js b/lib/commons/text/subtree-text.js
index a3d669f342..09fbe6a581 100644
--- a/lib/commons/text/subtree-text.js
+++ b/lib/commons/text/subtree-text.js
@@ -1,8 +1,10 @@
import accessibleTextVirtual from './accessible-text-virtual';
import namedFromContents from '../aria/named-from-contents';
import getOwnedVirtual from '../aria/get-owned-virtual';
+import getRole from '../aria/get-role';
import getElementsByContentType from '../standards/get-elements-by-content-type';
import getElementSpec from '../standards/get-element-spec';
+import { controlValueRoles } from './form-control-value';
/**
* Get the accessible text for an element that can get its name from content
@@ -16,20 +18,23 @@ function subtreeText(virtualNode, context = {}) {
const { alreadyProcessed } = accessibleTextVirtual;
context.startNode = context.startNode || virtualNode;
const { strict, inControlContext, inLabelledByContext } = context;
+ const role = getRole(virtualNode);
const { contentTypes } = getElementSpec(virtualNode, {
noMatchAccessibleName: true
});
if (
alreadyProcessed(virtualNode, context) ||
virtualNode.props.nodeType !== 1 ||
- contentTypes?.includes('embedded') // canvas, video, etc
+ contentTypes?.includes('embedded') || // canvas, video, etc
+ controlValueRoles.includes(role)
) {
return '';
}
if (
- !namedFromContents(virtualNode, { strict }) &&
- !context.subtreeDescendant
+ !context.subtreeDescendant &&
+ !context.inLabelledByContext &&
+ !namedFromContents(virtualNode, { strict })
) {
return '';
}
@@ -40,6 +45,7 @@ function subtreeText(virtualNode, context = {}) {
* chosen to ignore this, but only for direct content, not for labels / aria-labelledby.
* That way in `a[href] > article > #text` the text is used for the accessible name,
* See: https://github.com/dequelabs/axe-core/issues/1461
+ * See: https://github.com/w3c/accname/issues/120
*/
if (!strict) {
const subtreeDescendant = !inControlContext && !inLabelledByContext;
diff --git a/lib/commons/text/unsupported.js b/lib/commons/text/unsupported.js
index 04d63f1836..197b41600f 100644
--- a/lib/commons/text/unsupported.js
+++ b/lib/commons/text/unsupported.js
@@ -1,5 +1,7 @@
-const unsupported = {
- accessibleNameFromFieldValue: ['combobox', 'listbox', 'progressbar']
+export default {
+ // Element's who's value is not consistently picked up in the accessible name
+ // Supported in Chrome 114, Firefox 115, but not Safari 16.5:
+ //
+ //
+ accessibleNameFromFieldValue: ['progressbar']
};
-
-export default unsupported;
diff --git a/test/commons/text/accessible-text.js b/test/commons/text/accessible-text.js
index 3fd2ca785e..fd0552f0cd 100644
--- a/test/commons/text/accessible-text.js
+++ b/test/commons/text/accessible-text.js
@@ -1,6 +1,6 @@
describe('text.accessibleTextVirtual', () => {
const fixture = document.getElementById('fixture');
- const shadowSupport = axe.testUtils.shadowSupport;
+ const { html, shadowSupport } = axe.testUtils;
afterEach(() => {
fixture.innerHTML = '';
@@ -9,26 +9,32 @@ describe('text.accessibleTextVirtual', () => {
it('is called through accessibleText with a DOM node', () => {
const accessibleText = axe.commons.text.accessibleText;
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('input');
assert.equal(accessibleText(target), '');
});
it('should match the first example from the ARIA spec', () => {
- fixture.innerHTML =
- '' +
- ' ' +
- ' ' +
- ' File ' +
- ' ' +
- ' ' +
- ' New ' +
- ' Open… ' +
- ' …' +
- ' ' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const rule2a = axe.utils.querySelectorAll(axe._tree, '#rule2a')[0];
@@ -39,29 +45,35 @@ describe('text.accessibleTextVirtual', () => {
});
it('should match the second example from the ARIA spec', () => {
- fixture.innerHTML =
- '' +
- ' Meeting alarms ' +
- ' ' +
- ' Beep ' +
- ' Display the meeting title ' +
- ' ' +
- ' ' +
- ' ' +
- ' Flash the screen' +
- ' ' +
- ' ' +
- ' times' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+ Meeting alarms
+
+ Beep
+
+
+ Display the meeting title
+
+
+
+ Flash the screen
+
+
+ times
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const rule2a = axe.utils.querySelectorAll(axe._tree, '#beep')[0];
const rule2b = axe.utils.querySelectorAll(axe._tree, '#flash')[0];
assert.equal(axe.commons.text.accessibleTextVirtual(rule2a), 'Beep');
- // Chrome 72: "Flash the screen 3 times"
- // Firefox 62: "Flash the screen 3 times"
- // Safari 12.0: "Flash the screen 3 times"
assert.equal(
axe.commons.text.accessibleTextVirtual(rule2b),
'Flash the screen 3 times'
@@ -69,12 +81,22 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use aria-labelledby if present', () => {
- fixture.innerHTML =
- 'This is of everything
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is
+
+ of everything
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t1')[0];
@@ -85,12 +107,22 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use recusive aria-labelledby properly', () => {
- fixture.innerHTML =
- 'This is of everything
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is
+
+ of everything
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t1')[0];
@@ -101,12 +133,15 @@ describe('text.accessibleTextVirtual', () => {
});
it('should include hidden text referred to with aria-labelledby', () => {
- fixture.innerHTML =
- 'This is a ' +
- 'hidden ' +
- 'secret
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is a
+ hidden
+ secret
+
+ HTML Label
+ '
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t1')[0];
@@ -117,8 +152,9 @@ describe('text.accessibleTextVirtual', () => {
});
it('should allow setting the initial includeHidden value', () => {
- fixture.innerHTML =
- 'hidden label ';
+ fixture.innerHTML = html`
+ hidden label
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#lbl1')[0];
@@ -138,12 +174,16 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use aria-label if present with no labelledby', () => {
- fixture.innerHTML =
- 'This is of everything
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is
+
+ of everything
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t1')[0];
@@ -151,13 +191,16 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use alt on imgs with no ARIA', () => {
- fixture.innerHTML =
- 'This is of everything
' +
- ' ' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is of
+ everything
+
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#target')[0];
@@ -168,13 +211,16 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use alt on image inputs with no ARIA', () => {
- fixture.innerHTML =
- 'This is of everything
' +
- ' ' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is of
+ everything
+
+
+ This is a label
+ HTML Label
+ '
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#target')[0];
@@ -185,13 +231,16 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use not use alt on text inputs with no ARIA', () => {
- fixture.innerHTML =
- 'This is of everything
' +
- ' ' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is of
+ everything
+
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#target')[0];
@@ -199,12 +248,15 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use HTML label if no ARIA information', () => {
- fixture.innerHTML =
- 'This is of everything
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is of
+ everything
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t1')[0];
@@ -212,12 +264,22 @@ describe('text.accessibleTextVirtual', () => {
});
it('should handle last ditch title attribute', () => {
- fixture.innerHTML =
- 'This is of
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is
+
+ of
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t2label')[0];
@@ -228,12 +290,22 @@ describe('text.accessibleTextVirtual', () => {
});
it('should handle totally empty elements', () => {
- fixture.innerHTML =
- 'This is of
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is
+
+ of
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t2label')[0];
@@ -244,20 +316,28 @@ describe('text.accessibleTextVirtual', () => {
});
it('should handle author name-from roles properly', () => {
- fixture.innerHTML =
- 'This is ' +
- ' ' +
- ' of everything
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is
+
+ of everything
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t2label')[0];
- // Chrome 86: This is This is a label of
- // Firefox 82: This is ARIA Label everything
- // Safari 14.0: This is This is a label of everything
+ // Chrome 114: "This is the value of "
+ // Firefox 115: "This is ARIA Label the value everything"
+ // Safari 16.5: This is the value This is a label of everything
assert.equal(
axe.commons.text.accessibleTextVirtual(target),
'This is This is a label of everything'
@@ -265,9 +345,11 @@ describe('text.accessibleTextVirtual', () => {
});
it('should only show each node once when label is before input', () => {
- fixture.innerHTML =
- 'My form input ' +
- '
';
+ fixture.innerHTML = html`
+
+ My form input
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#target')[0];
assert.equal(
@@ -277,10 +359,12 @@ describe('text.accessibleTextVirtual', () => {
});
it('should only show each node once when label follows input', () => {
- fixture.innerHTML =
- '' +
- '
' +
- 'My form input ';
+ fixture.innerHTML = html`
+
+
+
+ My form input
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#target')[0];
assert.equal(
@@ -290,12 +374,22 @@ describe('text.accessibleTextVirtual', () => {
});
it('should handle nested inputs in normal context', () => {
- fixture.innerHTML =
- 'This is of everything
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is
+
+ of everything
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t2label')[0];
@@ -306,18 +400,28 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use handle nested inputs properly in labelledby context', () => {
- // Chrome 72: This is This is a label of everything
- // Firefox 62: This is ARIA Label the value of everything
- // Safari 12.0: THis is This is a label of everything
- fixture.innerHTML =
- 'This is of everything
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is
+
+ of everything
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t2')[0];
+ // Chrome 114: This is the value of everything
+ // Firefox 115: This is ARIA Label the value of everything
+ // Safari 16.5: THis is This is a label of everything
assert.equal(
axe.commons.text.accessibleTextVirtual(target),
'This is ARIA Label of everything'
@@ -325,12 +429,15 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use ignore hidden inputs', () => {
- fixture.innerHTML =
- 'This is of everything
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is of
+ everything
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t2')[0];
@@ -341,18 +448,22 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use handle inputs with no type as if they were text inputs', () => {
- fixture.innerHTML =
- 'This is of everything
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is
+
+ of everything
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t2')[0];
- // Chrome 70: "This is This is a label of everything"
- // Firefox 62: "This is the value of everything"
- // Safari 12.0: "This is This is a label of everything"
+ // Chrome 114: "This is the value of everything"
+ // Firefox 115: "This is the value of everything"
+ // Safari 16.5: "This is This is a label of everything"
assert.equal(
axe.commons.text.accessibleTextVirtual(target),
'This is the value of everything'
@@ -360,39 +471,49 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use handle nested selects properly in labelledby context', () => {
- fixture.innerHTML =
- 'This is ' +
- 'first second third ' +
- ' of everything
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is
+
+ first
+ second
+ third
+
+ of everything
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t2')[0];
- // Chrome 70: "This is This is a label of everything"
- // Firefox 62: "This is of everything"
- // Safari 12.0: "This is first third label of"
+ // Chrome 114: "This is first third of everything"
+ // Firefox 115: "This is of everything"
+ // Safari 16.5: "This is first third of everything"
assert.equal(
axe.commons.text.accessibleTextVirtual(target),
- 'This is of everything'
+ 'This is first third of everything'
);
});
it('should use handle nested textareas properly in labelledby context', () => {
- fixture.innerHTML =
- 'This is of everything
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+
+ This is
+
+ of everything
+
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t2')[0];
- // Chrome 70: "This is This is a label of everything"
- // Firefox 62: "This is ARIA Label the value of everything"
- // Safari 12.0: "This is This is a label of everything"
+ // Chrome 114: "This is the value of everything"
+ // Firefox 115: "This is the value of everything"
+ // Safari 16.5: "This is This is a label of everything"
assert.equal(
axe.commons.text.accessibleTextVirtual(target),
'This is the value of everything'
@@ -400,13 +521,21 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use handle ARIA labels properly in labelledby context', () => {
- fixture.innerHTML =
- 'This span ' +
- ' is of everything
' +
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ fixture.innerHTML = html`
+ This
+ span
+ is
+
+ of everything
+
+ This is a label
+ HTML Label
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t2')[0];
@@ -417,73 +546,82 @@ describe('text.accessibleTextVirtual', () => {
});
it('should come up empty if input is labeled only by select options', () => {
- fixture.innerHTML =
- '' +
- '' +
- ' Chosen ' +
- ' Not Selected ' +
- ' ' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+
+ Chosen
+ Not Selected
+
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#target')[0];
- // Chrome 70: ""
- // Firefox 62: "Chosen"
- // Safari 12.0: "Chosen"
- assert.equal(axe.commons.text.accessibleTextVirtual(target), '');
+ // Chrome 114: "Chosen"
+ // Firefox 115: "Chosen"
+ // Safari 16.5: "Chosen"
+ assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Chosen');
});
it("should be empty if input is labeled by labeled select (ref'd string labels have spotty support)", () => {
- fixture.innerHTML =
- 'My Select ' +
- '' +
- '' +
- ' Chosen ' +
- ' Not Selected ' +
- ' ' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+ My Select
+
+
+ Chosen
+ Not Selected
+
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#target')[0];
- assert.equal(axe.commons.text.accessibleTextVirtual(target), '');
+ // Chrome 114: "Chosen"
+ // Firefox 115: "Chosen"
+ // Safari 16.5: "Chosen"
+ assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Chosen');
});
it('should be empty for an empty label wrapping a select', () => {
- fixture.innerHTML =
- '' +
- ' ' +
- '' +
- 'Please choose a region ' +
- 'Coastal ' +
- 'Forest ' +
- 'Grasslands ' +
- 'Mountains ' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+
+
+ Please choose a region
+ Coastal
+ Forest
+ Grasslands
+ Mountains
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#target')[0];
assert.equal(axe.commons.text.accessibleTextVirtual(target), '');
});
it('should not return select options if input is aria-labelled by a select', () => {
- fixture.innerHTML =
- '' +
- '' +
- ' Chosen ' +
- ' Not Selected ' +
- ' ' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+
+ Chosen
+ Not Selected
+
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#target')[0];
- // Chrome 70: ""
- // Firefox 62: ""
- // Safari 12.0: "Chosen"
- assert.equal(axe.commons.text.accessibleTextVirtual(target), '');
+ // Chrome 114: "Chosen"
+ // Firefox 115: "Chosen"
+ // Safari 16.5: "Chosen"
+ assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Chosen');
});
it('shoud properly fall back to title', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html`
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'a')[0];
@@ -491,7 +629,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should give text even for role=presentation on anchors', () => {
- fixture.innerHTML = 'Hello ';
+ fixture.innerHTML = html` Hello `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'a')[0];
@@ -499,7 +637,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should give text even for role=presentation on buttons', () => {
- fixture.innerHTML = 'Hello ';
+ fixture.innerHTML = html` Hello `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'button')[0];
@@ -507,21 +645,21 @@ describe('text.accessibleTextVirtual', () => {
});
it('should give text even for role=presentation on summary', () => {
- fixture.innerHTML = 'Hello ';
+ fixture.innerHTML = html` Hello `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'summary')[0];
assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Hello');
});
it('shoud properly fall back to title', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'a')[0];
assert.equal(axe.commons.text.accessibleTextVirtual(target), 'Hello');
});
it('should give text even for role=none on anchors', () => {
- fixture.innerHTML = 'Hello ';
+ fixture.innerHTML = html` Hello `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'a')[0];
@@ -529,7 +667,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should give text even for role=none on buttons', () => {
- fixture.innerHTML = 'Hello ';
+ fixture.innerHTML = html` Hello `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'button')[0];
@@ -537,7 +675,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should give text even for role=none on summary', () => {
- fixture.innerHTML = 'Hello ';
+ fixture.innerHTML = html` Hello `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'summary')[0];
@@ -545,7 +683,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should not add extra spaces around phrasing elements', () => {
- fixture.innerHTML = 'HelloWorld ';
+ fixture.innerHTML = html` HelloWorld `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'a')[0];
@@ -553,7 +691,12 @@ describe('text.accessibleTextVirtual', () => {
});
it('should add spaces around non-phrasing elements', () => {
- fixture.innerHTML = 'HelloWorld
';
+ fixture.innerHTML = html`
+ Hello
+ World
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'a')[0];
@@ -570,7 +713,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use for input buttons', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -619,18 +762,29 @@ describe('text.accessibleTextVirtual', () => {
(shadowSupport.v1 ? it : xit)(
'should only find aria-labelledby element in the same context ',
() => {
- fixture.innerHTML =
- 'This is of everything
' +
- '
';
+ fixture.innerHTML = html`
+
+ This is
+
+ of everything
+
+
+ `;
const shadow = document
.getElementById('shadow')
.attachShadow({ mode: 'open' });
- shadow.innerHTML =
- 'This is a label
' +
- 'HTML Label ' +
- ' ';
+ shadow.innerHTML = html`
+ This is a label
+ HTML Label
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, '#t1')[0];
@@ -644,7 +798,7 @@ describe('text.accessibleTextVirtual', () => {
(shadowSupport.v1 ? it : xit)(
'should find attributes within a shadow tree',
() => {
- fixture.innerHTML = '
';
+ fixture.innerHTML = html`
`;
const shadow = document
.getElementById('shadow')
@@ -683,14 +837,15 @@ describe('text.accessibleTextVirtual', () => {
(shadowSupport.v1 ? it : xit)(
'should find fallback content for shadow DOM',
() => {
- fixture.innerHTML = '
';
+ fixture.innerHTML = html`
`;
const shadow = document
.getElementById('shadow')
.attachShadow({ mode: 'open' });
- shadow.innerHTML =
- ' ' +
- 'Fallback content heroes ';
+ shadow.innerHTML = html`
+
+ Fallback content heroes
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -703,9 +858,13 @@ describe('text.accessibleTextVirtual', () => {
describe('figure', () => {
it('should check aria-labelledby', () => {
- fixture.innerHTML =
- 'Hello
' +
- 'Not part of a11yName Fail ';
+ fixture.innerHTML = html`
+ Hello
+
+ Not part of a11yName
+ Fail
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'figure')[0];
@@ -713,8 +872,13 @@ describe('text.accessibleTextVirtual', () => {
});
it('should check aria-label', () => {
- fixture.innerHTML =
- 'Not part of a11yName Fail ';
+ fixture.innerHTML = html`
+
+ Not part of a11yName
+ Fail
+
+ ';
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'figure')[0];
@@ -740,7 +904,12 @@ describe('text.accessibleTextVirtual', () => {
});
it('should fall back to innerText of figure', () => {
- fixture.innerHTML = 'Hello ';
+ fixture.innerHTML = html`
+
+ Hello
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'figure')[0];
@@ -766,9 +935,11 @@ describe('text.accessibleTextVirtual', () => {
describe('img', () => {
it('should work with aria-labelledby attribute', () => {
- fixture.innerHTML =
- 'Hello
World
' +
- ' ';
+ fixture.innerHTML = html`
+ Hello
+ World
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'img')[0];
@@ -779,7 +950,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should work with aria-label attribute', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'img')[0];
@@ -790,7 +961,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should work with alt attribute', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'img')[0];
@@ -801,7 +972,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should work with title attribute', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'img')[0];
@@ -814,7 +985,7 @@ describe('text.accessibleTextVirtual', () => {
describe('input buttons', () => {
it('should find value for input type=button', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -822,7 +993,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find value for input type=reset', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -830,7 +1001,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find value for input type=submit', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -838,7 +1009,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should provide a default value for input type="submit"', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -849,7 +1020,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should provide a default value for input type="reset"', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -859,7 +1030,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find title for input type=button', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -867,7 +1038,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find title for input type=reset', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -879,7 +1050,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find title for input type=submit', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -893,9 +1064,11 @@ describe('text.accessibleTextVirtual', () => {
describe('tables', () => {
it('should work with aria-labelledby', () => {
- fixture.innerHTML =
- 'Hello
World
' +
- '';
+ fixture.innerHTML = html`
+ Hello
+ World
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'table')[0];
@@ -906,7 +1079,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should work with aria-label', () => {
- fixture.innerHTML = '';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'table')[0];
@@ -929,7 +1102,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should work with the title attribute', () => {
- fixture.innerHTML = '';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'table')[0];
@@ -940,7 +1113,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should work with the summary attribute', () => {
- fixture.innerHTML = '';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'table')[0];
@@ -951,10 +1124,12 @@ describe('text.accessibleTextVirtual', () => {
});
it('should prefer summary attribute over title attribute', () => {
- // Chrome 70: "Hello world"
- // Firefox 62: "Hello world"
- // Safari 12.0: "FAIL"
- fixture.innerHTML = '';
+ // Chrome 114: "Hello world"
+ // Firefox 115: "Hello world"
+ // Safari 16.5: "Hello world"
+ fixture.innerHTML = html`
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'table')[0];
@@ -971,11 +1146,11 @@ describe('text.accessibleTextVirtual', () => {
it('should find aria-labelledby', () => {
types.forEach(function (type) {
const t = type ? ' type="' + type + '"' : '';
- fixture.innerHTML =
- 'Hello
World
' +
- ' ';
+ fixture.innerHTML = html`
+ Hello
+ World
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -990,7 +1165,7 @@ describe('text.accessibleTextVirtual', () => {
it('should find aria-label', () => {
types.forEach(function (type) {
const t = type ? ' type="' + type + '"' : '';
- fixture.innerHTML = ' ';
+ fixture.innerHTML = ` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -1005,8 +1180,7 @@ describe('text.accessibleTextVirtual', () => {
it('should find an implicit label', () => {
types.forEach(function (type) {
const t = type ? ' type="' + type + '"' : '';
- fixture.innerHTML =
- 'Hello World' + ' ';
+ fixture.innerHTML = `Hello World `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -1021,8 +1195,7 @@ describe('text.accessibleTextVirtual', () => {
it('should find an explicit label', () => {
types.forEach(function (type) {
const t = type ? ' type="' + type + '"' : '';
- fixture.innerHTML =
- 'Hello World ' + ' ';
+ fixture.innerHTML = `Hello World `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -1037,8 +1210,7 @@ describe('text.accessibleTextVirtual', () => {
it('should find implicit labels with id that does not match to a label', () => {
types.forEach(function (type) {
const t = type ? ' type="' + type + '"' : '';
- fixture.innerHTML =
- 'Hello World' + ' ';
+ fixture.innerHTML = `Hello World `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -1053,7 +1225,7 @@ describe('text.accessibleTextVirtual', () => {
it('should find a placeholder attribute', () => {
types.forEach(function (type) {
const t = type ? ' type="' + type + '"' : '';
- fixture.innerHTML = ' ';
+ fixture.innerHTML = ` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -1068,7 +1240,7 @@ describe('text.accessibleTextVirtual', () => {
it('should find a title attribute', () => {
types.forEach(function (type) {
const t = type ? ' type="' + type + '"' : '';
- fixture.innerHTML = ' ';
+ fixture.innerHTML = ` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -1083,7 +1255,7 @@ describe('text.accessibleTextVirtual', () => {
it('should otherwise be empty string', () => {
types.forEach(function (type) {
const t = type ? ' type="' + type + '"' : '';
- fixture.innerHTML = ' ';
+ fixture.innerHTML = ` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -1094,9 +1266,11 @@ describe('text.accessibleTextVirtual', () => {
describe('textarea', () => {
it('should find aria-labelledby', () => {
- fixture.innerHTML =
- 'Hello
World
' +
- '';
+ fixture.innerHTML = html`
+ Hello
+ World
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'textarea')[0];
@@ -1107,7 +1281,9 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find aria-label', () => {
- fixture.innerHTML = '';
+ fixture.innerHTML = html`
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'textarea')[0];
@@ -1118,8 +1294,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find an implicit label', () => {
- fixture.innerHTML =
- 'Hello World' + ' ';
+ fixture.innerHTML = `Hello World `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'textarea')[0];
@@ -1130,8 +1305,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find an explicit label', () => {
- fixture.innerHTML =
- 'Hello World ' + '';
+ fixture.innerHTML = `Hello World `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'textarea')[0];
@@ -1142,7 +1316,9 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find a placeholder attribute', () => {
- fixture.innerHTML = '';
+ fixture.innerHTML = html`
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'textarea')[0];
@@ -1153,7 +1329,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find a title attribute', () => {
- fixture.innerHTML = '';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'textarea')[0];
@@ -1164,7 +1340,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should otherwise be empty string', () => {
- fixture.innerHTML = '';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'textarea')[0];
@@ -1174,9 +1350,11 @@ describe('text.accessibleTextVirtual', () => {
describe('image inputs', () => {
it('should find aria-labelledby', () => {
- fixture.innerHTML =
- 'Hello
World
' +
- ' ';
+ fixture.innerHTML = html`
+ Hello
+ World
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -1187,7 +1365,9 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find aria-label', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html`
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -1198,7 +1378,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find an alt attribute', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -1209,7 +1389,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find a title attribute', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -1220,7 +1400,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should otherwise be "Submit" string', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'input')[0];
@@ -1230,9 +1410,11 @@ describe('text.accessibleTextVirtual', () => {
describe('a', () => {
it('should find aria-labelledby', () => {
- fixture.innerHTML =
- 'Hello
World
' +
- ' ';
+ fixture.innerHTML = html`
+ Hello
+ World
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'a')[0];
@@ -1243,7 +1425,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find aria-label', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'a')[0];
@@ -1254,7 +1436,11 @@ describe('text.accessibleTextVirtual', () => {
});
it('should check subtree', () => {
- fixture.innerHTML = 'Hello World ';
+ fixture.innerHTML = html`
+ Hello World
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'a')[0];
@@ -1265,7 +1451,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find a title attribute', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'a')[0];
@@ -1276,7 +1462,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should otherwise be empty string', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'a')[0];
@@ -1284,16 +1470,15 @@ describe('text.accessibleTextVirtual', () => {
});
it('should use text from a table with a single cell and role=presentation', () => {
- fixture.innerHTML =
- '' +
- ' ' +
- '' +
- '' +
- 'Descriptive Link Text' +
- ' ' +
- ' ' +
- '
' +
- '';
+ fixture.innerHTML = html`
+
+
+
+ Descriptive Link Text
+
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'a')[0];
@@ -1306,9 +1491,11 @@ describe('text.accessibleTextVirtual', () => {
describe('button', () => {
it('should find aria-labelledby', () => {
- fixture.innerHTML =
- 'Hello
World
' +
- ' ';
+ fixture.innerHTML = html`
+ Hello
+ World
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'button')[0];
@@ -1319,7 +1506,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find aria-label', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'button')[0];
@@ -1342,7 +1529,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should find a title attribute', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'button')[0];
@@ -1353,7 +1540,7 @@ describe('text.accessibleTextVirtual', () => {
});
it('should otherwise be empty string', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, 'button')[0];
@@ -1393,7 +1580,10 @@ describe('text.accessibleTextVirtual', () => {
it('should find aria-labelledby', () => {
tags.forEach(function (tag) {
- fixture.innerHTML = 'Hello
World
';
+ fixture.innerHTML = html`
+ Hello
+ World
+ `;
axe.testUtils.flatTreeSetup(fixture);
const elm = document.createElement(tag);
@@ -1438,7 +1628,7 @@ describe('text.accessibleTextVirtual', () => {
it('should otherwise be empty string', () => {
tags.forEach(function (tag) {
- fixture.innerHTML = '<' + tag + '>' + tag + '>';
+ fixture.innerHTML = `<${tag}>${tag}>`;
axe.testUtils.flatTreeSetup(fixture);
const target = axe.utils.querySelectorAll(axe._tree, tag)[0];
@@ -1479,44 +1669,48 @@ describe('text.accessibleTextVirtual', () => {
});
afterEach(() => {
- fixture.innerHTML = '';
+ fixture.innerHTML = html``;
axe._tree = null;
});
it('passes test 1', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html`
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'Rich');
});
it('passes test 2', () => {
- fixture.innerHTML =
- 'Rich\'s button
' +
- ' ';
+ fixture.innerHTML = html`
+ Rich's button
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), "Rich's button");
});
it('passes test 3', () => {
- fixture.innerHTML =
- 'Rich\'s button
' +
- ' ';
+ fixture.innerHTML = html`
+ Rich's button
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), "Rich's button");
});
it('passes test 4', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'Reset');
});
it('passes test 5', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html` `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'foo');
@@ -1531,61 +1725,76 @@ describe('text.accessibleTextVirtual', () => {
});
it('passes test 7', () => {
- fixture.innerHTML =
- 'States: ' + ' ';
+ fixture.innerHTML = html`
+ States:
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'States:');
});
it('passes test 8', () => {
- fixture.innerHTML =
- '' +
- 'foo' +
- ' ' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+ foo
+
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'foo David');
});
it('passes test 9', () => {
- fixture.innerHTML =
- '' +
- 'crazy' +
- ' ' +
- ' clown ' +
- ' rich ' +
- ' ' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+ crazy
+
+ clown
+ rich
+
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'crazy');
});
ariaValuetext('passes test 10', () => {
- fixture.innerHTML =
- '' +
- ' crazy' +
- ' ' +
- '
' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+ crazy
+
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'crazy Monday');
});
it('passes test 11', () => {
- fixture.innerHTML =
- '' +
- ' crazy' +
- ' ' +
- '
' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+ crazy
+
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'crazy 4');
@@ -1600,31 +1809,39 @@ describe('text.accessibleTextVirtual', () => {
});
pseudoText('passes test 13', () => {
- fixture.innerHTML =
- '' +
- 'fruit ' +
- ' ';
+ fixture.innerHTML = html`
+
+ fruit
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'fancy fruit');
});
pseudoText('passes test 14', () => {
- fixture.innerHTML =
- '' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'test content');
});
it('passes test 15', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html`
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), '1');
@@ -1641,9 +1858,10 @@ describe('text.accessibleTextVirtual', () => {
// To the best of my knowledge, this test is incorrect
// Chrome and Firefox seem to return "peanuts", so does axe-core.
xit('passes test 17', () => {
- fixture.innerHTML =
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), '');
@@ -1660,9 +1878,10 @@ describe('text.accessibleTextVirtual', () => {
// To the best of my knowledge, this test is incorrect
// Chrome and Firefox seem to return "peanuts", so does axe-core.
xit('passes test 19', () => {
- fixture.innerHTML =
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), '');
@@ -1677,87 +1896,119 @@ describe('text.accessibleTextVirtual', () => {
});
it('passes test 21', () => {
- fixture.innerHTML =
- ' ' +
- ' ' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'peanuts popcorn apple jacks');
});
it('passes test 22', () => {
- fixture.innerHTML =
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'l peanuts');
});
it('passes test 23', () => {
- fixture.innerHTML =
- ' ' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'l peanuts popcorn');
});
it('passes test 24', () => {
- fixture.innerHTML =
- ' ' +
- ' ' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'l peanuts popcorn apple jacks');
});
it('passes test 25', () => {
- fixture.innerHTML =
- ' ' +
- ' ' +
- ' ' +
- ' ';
+ fixture.innerHTML = html`
+
+
+
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 't peanuts popcorn apple jacks');
});
it('passes test 26', () => {
- fixture.innerHTML =
- 'foo
' +
- 'bar ';
+ fixture.innerHTML = html`
+ foo
+ bar
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'bar');
});
it('passes test 27', () => {
- fixture.innerHTML = 'foo
';
+ fixture.innerHTML = html` foo
`;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'Tag');
});
it('passes test 28', () => {
- fixture.innerHTML =
- 'foo
' +
- 'bar ';
+ fixture.innerHTML = html`
+ foo
+ bar
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'bar');
});
it('passes test 29', () => {
- fixture.innerHTML =
- 'foo
' +
- 'bar ' +
- 'baz ';
+ fixture.innerHTML = html`
+ foo
+ bar
+ baz
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'bar baz');
@@ -1765,288 +2016,373 @@ describe('text.accessibleTextVirtual', () => {
// Should only pass in strict mode
it('passes test 30', () => {
- fixture.innerHTML = 'Div with text
';
+ fixture.innerHTML = html` Div with text
`;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target, { strict: true }), '');
});
it('passes test 31', () => {
- fixture.innerHTML = 'foo
';
+ fixture.innerHTML = html` foo
`;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'foo');
});
it('passes test 32', () => {
- fixture.innerHTML =
- '' +
- '
';
+ fixture.innerHTML = html`
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'Tag');
});
it('passes test 33', () => {
- fixture.innerHTML =
- 'foo
' +
- 'bar ';
+ fixture.innerHTML = html`
+ foo
+ bar
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'foo');
});
it('passes test 34', () => {
- fixture.innerHTML =
- 'ABC ';
+ fixture.innerHTML = html`
+ ABC
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'Tag');
});
it('passes test 35', () => {
- fixture.innerHTML =
- 'foo ' +
- 'bar
';
+ fixture.innerHTML = html`
+ foo
+ bar
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'bar');
});
it('passes test 36', () => {
- fixture.innerHTML =
- ' ' +
- 'foo
';
+ fixture.innerHTML = html`
+
+ foo
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'Tag foo');
});
it('passes test 37', () => {
- fixture.innerHTML = 'ABC ';
+ fixture.innerHTML = html` ABC `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'ABC');
});
it('passes test 38', () => {
- fixture.innerHTML = ' ';
+ fixture.innerHTML = html`
+
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'Tag');
});
it('passes test 39', () => {
- fixture.innerHTML =
- ' ' +
- 'foo
' +
- 'bar
' +
- 'baz
';
+ fixture.innerHTML = html`
+
+ foo
+ bar
+ baz
+ `;
axe.testUtils.flatTreeSetup(fixture);
const target = fixture.querySelector('#test');
assert.equal(accessibleText(target), 'foo bar baz');
});
it('passes test 40', () => {
- fixture.innerHTML =
- ' ' +
- '