Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into cdt-proccessor
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Jul 6, 2023
2 parents 417f613 + c23b356 commit 315a9f7
Show file tree
Hide file tree
Showing 37 changed files with 2,422 additions and 403 deletions.
14 changes: 14 additions & 0 deletions cli/test/fixtures/a11y/a11y_tester.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@
<div id="duplicate-id-aria"></div>
<input type="text" aria-labelledby="duplicate-id-aria"/>
</section>
<p>empty-heading</p>
<section>
<h1 id="empty-heading"></h1>
</section>
<p>form-field-multiple-labels</p>
<section>
<label for="form-field-multiple-labels" id="label1">label1</label>
Expand All @@ -160,6 +164,11 @@
<h1>top header</h1>
<h3>sub-sub-header</h3>
</section>
<p>identical-links-same-purpose</p>
<section>
<a id="identical-links-same-purpose-1" href="https://example.com/" aria-label="a link"></a>
<a id="identical-links-same-purpose-2" href="https://google.com/" aria-label="a link"></a>
</section>
<p>image-alt</p>
<section>
<img
Expand Down Expand Up @@ -239,6 +248,11 @@ <h3>sub-sub-header</h3>
<tr><td>foo</td><td>foo</td><tr>
</table>
</section>
<p>target-size</p>
<section>
<button id="target-size-1">+</button>
<span role="button" tabindex="0" id="target-size-2">o</span>
</section>
<p>td-has-header</p>
<section>
<table id="td-has-header">
Expand Down
72 changes: 68 additions & 4 deletions cli/test/smokehouse/test-definitions/a11y.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,22 @@ const expectations = {
],
},
},
'empty-heading': {
score: null,
details: {
items: [
{
node: {
'type': 'node',
'selector': 'body > section > h1#empty-heading',
'snippet': '<h1 id="empty-heading">',
'explanation': 'Fix any of the following:\n Element does not have text that is visible to screen readers\n aria-label attribute does not exist or is empty\n aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty\n Element has no title attribute',
'nodeLabel': 'body > section > h1#empty-heading',
},
},
],
},
},
'form-field-multiple-labels': {
score: null,
scoreDisplayMode: 'informative',
Expand All @@ -507,7 +523,7 @@ const expectations = {
node: {
'type': 'node',
'selector': 'body > section > input#form-field-multiple-labels',
'path': '2,HTML,1,BODY,47,SECTION,2,INPUT',
'path': '2,HTML,1,BODY,49,SECTION,2,INPUT',
'snippet': '<input type="checkbox" id="form-field-multiple-labels">',
'explanation': 'Fix all of the following:\n Multiple label elements is not widely supported in assistive technologies. Ensure the first label contains all necessary information.',
'nodeLabel': 'body > section > input#form-field-multiple-labels',
Expand All @@ -518,7 +534,7 @@ const expectations = {
{
relatedNode: {
'type': 'node',
'path': '2,HTML,1,BODY,47,SECTION,0,LABEL',
'path': '2,HTML,1,BODY,49,SECTION,0,LABEL',
'selector': 'body > section > label#label1',
'snippet': '<label for="form-field-multiple-labels" id="label1">',
'nodeLabel': 'label1',
Expand All @@ -527,7 +543,7 @@ const expectations = {
{
relatedNode: {
'type': 'node',
'path': '2,HTML,1,BODY,47,SECTION,1,LABEL',
'path': '2,HTML,1,BODY,49,SECTION,1,LABEL',
'selector': 'body > section > label',
'snippet': '<label for="form-field-multiple-labels">',
'nodeLabel': 'label2',
Expand Down Expand Up @@ -563,7 +579,7 @@ const expectations = {
node: {
'type': 'node',
'selector': 'body > section > h3',
'path': '2,HTML,1,BODY,51,SECTION,1,H3',
'path': '2,HTML,1,BODY,53,SECTION,1,H3',
'snippet': '<h3>',
'explanation': 'Fix any of the following:\n Heading order invalid',
'nodeLabel': 'sub-sub-header',
Expand Down Expand Up @@ -592,6 +608,22 @@ const expectations = {
score: null,
scoreDisplayMode: 'notApplicable',
},
'identical-links-same-purpose': {
score: null,
details: {
items: [
{
node: {
'type': 'node',
'selector': 'body > section > a#identical-links-same-purpose-1',
'snippet': '<a id="identical-links-same-purpose-1" href="https://example.com/" aria-label="a link">',
'explanation': 'Fix all of the following:\n Check that links have the same purpose, or are intentionally ambiguous.',
'nodeLabel': 'a link',
},
},
],
},
},
'image-alt': {
score: 0,
details: {
Expand Down Expand Up @@ -658,6 +690,22 @@ const expectations = {
// ],
// },
// },
'landmark-one-main': {
score: null,
details: {
items: [
{
node: {
'type': 'node',
'selector': 'html',
'snippet': '<html>',
'explanation': 'Fix all of the following:\n Document does not have a main landmark',
'nodeLabel': 'html',
},
},
],
},
},
'link-in-text-block': {
score: 0,
details: {
Expand Down Expand Up @@ -802,6 +850,22 @@ const expectations = {
],
},
},
'target-size': {
score: null,
details: {
items: [
{
node: {
'type': 'node',
'selector': 'body > section > span#target-size-2',
'snippet': '<span role="button" tabindex="0" id="target-size-2">',
'explanation': 'Fix any of the following:\n Target has insufficient size (8px by 17px, should be at least 24px by 24px)\n Target has insufficient offset from its closest neighbor (12px should be at least 24px)',
'nodeLabel': 'o',
},
},
],
},
},
'td-has-header': {
score: 0,
details: {
Expand Down
45 changes: 45 additions & 0 deletions core/audits/accessibility/empty-heading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @license Copyright 2023 The Lighthouse Authors. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

/**
* @fileoverview Ensures that headings are not empty.
* See base class in axe-audit.js for audit() implementation.
*/

import AxeAudit from './axe-audit.js';
import * as i18n from '../../lib/i18n/i18n.js';

const UIStrings = {
/** Title of an accesibility audit that checks if all heading elements have content. This title is descriptive of the successful state and is shown to users when no user action is required. */
title: 'All heading elements contain content.',
/** Title of an accesibility audit that checks if all heading elements have content. This title is descriptive of the failing state and is shown to users when there is a failure that needs to be addressed. */
failureTitle: 'Heading elements do not contain content.',
/** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
description: 'A heading with no content or inaccessible text prevent screen reader users from ' +
'accessing information on the page\'s structure. ' +
'[Learn more about headings](https://dequeuniversity.com/rules/axe/4.7/empty-heading).',
};

const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);

class EmptyHeading extends AxeAudit {
/**
* @return {LH.Audit.Meta}
*/
static get meta() {
return {
id: 'empty-heading',
title: str_(UIStrings.title),
failureTitle: str_(UIStrings.failureTitle),
description: str_(UIStrings.description),
scoreDisplayMode: AxeAudit.SCORING_MODES.INFORMATIVE,
requiredArtifacts: ['Accessibility'],
};
}
}

export default EmptyHeading;
export {UIStrings};
45 changes: 45 additions & 0 deletions core/audits/accessibility/identical-links-same-purpose.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @license Copyright 2023 The Lighthouse Authors. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

/**
* @fileoverview Ensures that identical links have the same purpose.
* See base class in axe-audit.js for audit() implementation.
*/

import AxeAudit from './axe-audit.js';
import * as i18n from '../../lib/i18n/i18n.js';

const UIStrings = {
/** Title of an accesibility audit that checks if identical links have the same purpose. This title is descriptive of the successful state and is shown to users when no user action is required. */
title: 'Identical links have the same purpose.',
/** Title of an accesibility audit that checks if identical links have the same purpose. This title is descriptive of the failing state and is shown to users when there is a failure that needs to be addressed. */
failureTitle: 'Identical links do not have the same purpose.',
/** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
description: 'Links with the same destination should have the same description, to help users ' +
'understand the link\'s purpose and decide whether to follow it. ' +
'[Learn more about identical links](https://dequeuniversity.com/rules/axe/4.7/identical-links-same-purpose).',
};

const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);

class IdenticalLinksSamePurpose extends AxeAudit {
/**
* @return {LH.Audit.Meta}
*/
static get meta() {
return {
id: 'identical-links-same-purpose',
title: str_(UIStrings.title),
failureTitle: str_(UIStrings.failureTitle),
description: str_(UIStrings.description),
scoreDisplayMode: AxeAudit.SCORING_MODES.INFORMATIVE,
requiredArtifacts: ['Accessibility'],
};
}
}

export default IdenticalLinksSamePurpose;
export {UIStrings};
44 changes: 44 additions & 0 deletions core/audits/accessibility/landmark-one-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @license Copyright 2023 The Lighthouse Authors. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

/**
* @fileoverview Ensures that the document has a main landmark.
* See base class in axe-audit.js for audit() implementation.
*/

import AxeAudit from './axe-audit.js';
import * as i18n from '../../lib/i18n/i18n.js';

const UIStrings = {
/** Title of an accesibility audit that checks if the document has a main landmark. This title is descriptive of the successful state and is shown to users when no user action is required. */
title: 'Document has a main landmark.',
/** Title of an accesibility audit that checks if the document has a main landmark. This title is descriptive of the failing state and is shown to users when there is a failure that needs to be addressed. */
failureTitle: 'Document does not have a main landmark.',
/** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
description: 'One main landmark helps screen reader users navigate a web page. ' +
'[Learn more about landmarks](https://dequeuniversity.com/rules/axe/4.7/landmark-one-main).',
};

const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);

class LandmarkOneMain extends AxeAudit {
/**
* @return {LH.Audit.Meta}
*/
static get meta() {
return {
id: 'landmark-one-main',
title: str_(UIStrings.title),
failureTitle: str_(UIStrings.failureTitle),
description: str_(UIStrings.description),
scoreDisplayMode: AxeAudit.SCORING_MODES.INFORMATIVE,
requiredArtifacts: ['Accessibility'],
};
}
}

export default LandmarkOneMain;
export {UIStrings};
45 changes: 45 additions & 0 deletions core/audits/accessibility/target-size.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @license Copyright 2023 The Lighthouse Authors. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

/**
* @fileoverview Ensures that touch targets have sufficient size and spacing.
* See base class in axe-audit.js for audit() implementation.
*/

import AxeAudit from './axe-audit.js';
import * as i18n from '../../lib/i18n/i18n.js';

const UIStrings = {
/** Title of an accesibility audit that checks if all touch targets have sufficient size and spacing. This title is descriptive of the successful state and is shown to users when no user action is required. */
title: 'Touch targets have sufficient size and spacing.',
/** Title of an accesibility audit that checks if all touch targets have sufficient size and spacing. This title is descriptive of the failing state and is shown to users when there is a failure that needs to be addressed. */
failureTitle: 'Touch targets do not have sufficient size or spacing.',
/** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
description: 'Touch targets with sufficient size and spacing help users who may have ' +
'difficulty targeting small controls activate the targets. ' +
'[Learn more about touch targets](https://dequeuniversity.com/rules/axe/4.7/target-size).',
};

const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);

class TargetSize extends AxeAudit {
/**
* @return {LH.Audit.Meta}
*/
static get meta() {
return {
id: 'target-size',
title: str_(UIStrings.title),
failureTitle: str_(UIStrings.failureTitle),
description: str_(UIStrings.description),
scoreDisplayMode: AxeAudit.SCORING_MODES.INFORMATIVE,
requiredArtifacts: ['Accessibility'],
};
}
}

export default TargetSize;
export {UIStrings};
12 changes: 12 additions & 0 deletions core/audits/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,18 @@ class Audit {
details: product.details,
};
}

/**
* @param {LH.Artifacts} artifacts
* @param {LH.Audit.Context} context
* @returns {LH.Artifacts.MetricComputationDataInput}
*/
static makeMetricComputationDataInput(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const gatherContext = artifacts.GatherContext;
return {trace, devtoolsLog, gatherContext, settings: context.settings, URL: artifacts.URL};
}
}

export {Audit};
Loading

0 comments on commit 315a9f7

Please sign in to comment.