From 2f64c4f76a74fadfc321bac90c9e9a41708bd851 Mon Sep 17 00:00:00 2001 From: Dan Bjorge Date: Tue, 21 Feb 2023 17:38:23 -0500 Subject: [PATCH 1/4] replace rule-exclusion.ts with @accessibility-insights/axe-config content --- .../src/axe-scanner/axe-configuration.ts | 80 ++++++++++++++++++- .../axe-scanner/axe-puppeteer-factory.spec.ts | 3 +- .../src/axe-scanner/axe-puppeteer-factory.ts | 3 - .../src/axe-scanner/rule-exclusion.ts | 49 ------------ 4 files changed, 78 insertions(+), 57 deletions(-) delete mode 100644 packages/scanner-global-library/src/axe-scanner/rule-exclusion.ts diff --git a/packages/scanner-global-library/src/axe-scanner/axe-configuration.ts b/packages/scanner-global-library/src/axe-scanner/axe-configuration.ts index 24cee67a2..c40341074 100644 --- a/packages/scanner-global-library/src/axe-scanner/axe-configuration.ts +++ b/packages/scanner-global-library/src/axe-scanner/axe-configuration.ts @@ -5,11 +5,83 @@ import type { Spec } from 'axe-core'; export type AxeConfiguration = Spec; -// Note that @axe-core/puppeteer version range ">= 4.2.0 < 4.3.0" does not support -// axe-core's allowedOrigins Spec property, which will cause these configurations to -// be *silently* misapplied. +// This is copied verbatim from the built version of the @accessibility-insights/axe-config +// package in microsoft/accessibility-insights-web. It must be updated with each axe-core update +// and also to pick up any out-of-band rule customizations. +// +// In the future, it would be nice to publish that package and pick it up via NPM instead of +// copying it here. See https://github.com/microsoft/accessibility-insights-service/issues/571 +const accessibilityInsightsWebAxeConfiguration = { + "restoreScroll": true, + "runOnly": { + "type": "rule", + "values": [ + "area-alt", + "aria-allowed-attr", + "aria-allowed-role", + "aria-command-name", + "aria-hidden-body", + "aria-hidden-focus", + "aria-input-field-name", + "aria-meter-name", + "aria-progressbar-name", + "aria-required-attr", + "aria-required-children", + "aria-required-parent", + "aria-roledescription", + "aria-roles", + "aria-toggle-field-name", + "aria-tooltip-name", + "aria-valid-attr-value", + "aria-valid-attr", + "audio-caption", + "autocomplete-valid", + "avoid-inline-spacing", + "blink", + "button-name", + "bypass", + "color-contrast", + "definition-list", + "dlitem", + "document-title", + "duplicate-id-active", + "duplicate-id-aria", + "frame-focusable-content", + "frame-tested", + "frame-title", + "html-has-lang", + "html-lang-valid", + "html-xml-lang-mismatch", + "image-alt", + "input-button-name", + "input-image-alt", + "label", + "link-in-text-block", + "link-name", + "list", + "listitem", + "marquee", + "meta-refresh", + "meta-viewport", + "nested-interactive", + "object-alt", + "presentation-role-conflict", + "role-img-alt", + "select-name", + "server-side-image-map", + "svg-img-alt", + "td-headers-attr", + "th-has-data-cells", + "valid-lang", + "video-caption" + ] + }, + "pingWaitTime": 1000 +}; export const cloudAxeConfiguration: AxeConfiguration = { + ...accessibilityInsightsWebAxeConfiguration, + // We allow this for our own cloud workers because we can verify *both* that they // only use isolated, non-privileged browser contexts *and* they run in a network // environment that does not contain any private endpoints which expose secrets. @@ -17,6 +89,8 @@ export const cloudAxeConfiguration: AxeConfiguration = { }; export const localAxeConfiguration: AxeConfiguration = { + ...accessibilityInsightsWebAxeConfiguration, + // Local cases still use isolated, non-privileged browser contexts, but they may // be running in an environment with sensitive local/network endpoints, so we don't // allow cross-origin scanning. diff --git a/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.spec.ts b/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.spec.ts index 7b102bf11..c8e56a2b1 100644 --- a/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.spec.ts +++ b/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.spec.ts @@ -8,7 +8,6 @@ import { AxePuppeteer } from '@axe-core/puppeteer'; import * as Puppeteer from 'puppeteer'; import { IMock, Mock, MockBehavior, Times } from 'typemoq'; import { AxePuppeteerFactory } from './axe-puppeteer-factory'; -import { RuleExclusion } from './rule-exclusion'; import { AxeConfiguration } from './axe-configuration'; /* eslint-disable @typescript-eslint/no-explicit-any */ @@ -23,7 +22,7 @@ describe('AxePuppeteerFactory', () => { page = Mock.ofType(); fsMock = Mock.ofInstance(fs, MockBehavior.Strict); axeConfiguration = { allowedOrigins: ['test origin'] }; - testSubject = new AxePuppeteerFactory(axeConfiguration, new RuleExclusion(), fsMock.object); + testSubject = new AxePuppeteerFactory(axeConfiguration, fsMock.object); }); it('create axe puppeteer instance', async () => { diff --git a/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.ts b/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.ts index 53b5a3e11..6a34a78f7 100644 --- a/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.ts +++ b/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.ts @@ -7,14 +7,12 @@ import { inject, injectable } from 'inversify'; import { isEmpty } from 'lodash'; import * as Puppeteer from 'puppeteer'; import { iocTypes } from '../ioc-types'; -import { RuleExclusion } from './rule-exclusion'; import { AxeConfiguration } from './axe-configuration'; @injectable() export class AxePuppeteerFactory { constructor( @inject(iocTypes.AxeConfiguration) private readonly axeConfiguration: AxeConfiguration, - private readonly ruleExclusion: RuleExclusion = new RuleExclusion(), private readonly fileSystemObj: typeof fs = fs, ) {} @@ -23,7 +21,6 @@ export class AxePuppeteerFactory { return new AxePuppeteer(page, axeSource) .configure(this.axeConfiguration) - .disableRules(this.ruleExclusion.accessibilityRuleExclusionList) .setLegacyMode(legacyMode); } diff --git a/packages/scanner-global-library/src/axe-scanner/rule-exclusion.ts b/packages/scanner-global-library/src/axe-scanner/rule-exclusion.ts deleted file mode 100644 index 8fb38f7e9..000000000 --- a/packages/scanner-global-library/src/axe-scanner/rule-exclusion.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import { injectable } from 'inversify'; - -@injectable() -export class RuleExclusion { - public accessibilityRuleExclusionList = [ - 'accesskeys', - 'aria-dialog-name', - 'aria-text', - 'aria-treeitem-name', - 'bypass', - 'css-orientation-lock', - 'duplicate-id', - 'empty-heading', - 'focus-order-semantics', - 'form-field-multiple-labels', - 'frame-tested', - 'frame-title-unique', - 'heading-order', - 'hidden-content', - 'identical-links-same-purpose', - 'image-redundant-alt', - 'label-content-name-mismatch', - 'label-title-only', - 'landmark-banner-is-top-level', - 'landmark-complementary-is-top-level', - 'landmark-contentinfo-is-top-level', - 'landmark-main-is-top-level', - 'landmark-no-duplicate-banner', - 'landmark-no-duplicate-contentinfo', - 'landmark-no-duplicate-main', - 'landmark-one-main', - 'landmark-unique', - 'meta-viewport-large', - 'no-autoplay-audio', - 'p-as-heading', - 'page-has-heading-one', - 'region', - 'scope-attr-valid', - 'scrollable-region-focusable', - 'skip-link', - 'tabindex', - 'table-duplicate-name', - 'table-fake-caption', - 'td-has-header', - ]; -} From 1c79e3fc45d7ece33205476ad483a04ccb36630a Mon Sep 17 00:00:00 2001 From: Dan Bjorge Date: Tue, 21 Feb 2023 18:02:03 -0500 Subject: [PATCH 2/4] yarn format:fix --- .../src/axe-scanner/axe-configuration.ts | 129 +++++++++--------- .../src/axe-scanner/axe-puppeteer-factory.ts | 4 +- 2 files changed, 65 insertions(+), 68 deletions(-) diff --git a/packages/scanner-global-library/src/axe-scanner/axe-configuration.ts b/packages/scanner-global-library/src/axe-scanner/axe-configuration.ts index c40341074..56b2c9dc9 100644 --- a/packages/scanner-global-library/src/axe-scanner/axe-configuration.ts +++ b/packages/scanner-global-library/src/axe-scanner/axe-configuration.ts @@ -12,71 +12,70 @@ export type AxeConfiguration = Spec; // In the future, it would be nice to publish that package and pick it up via NPM instead of // copying it here. See https://github.com/microsoft/accessibility-insights-service/issues/571 const accessibilityInsightsWebAxeConfiguration = { - "restoreScroll": true, - "runOnly": { - "type": "rule", - "values": [ - "area-alt", - "aria-allowed-attr", - "aria-allowed-role", - "aria-command-name", - "aria-hidden-body", - "aria-hidden-focus", - "aria-input-field-name", - "aria-meter-name", - "aria-progressbar-name", - "aria-required-attr", - "aria-required-children", - "aria-required-parent", - "aria-roledescription", - "aria-roles", - "aria-toggle-field-name", - "aria-tooltip-name", - "aria-valid-attr-value", - "aria-valid-attr", - "audio-caption", - "autocomplete-valid", - "avoid-inline-spacing", - "blink", - "button-name", - "bypass", - "color-contrast", - "definition-list", - "dlitem", - "document-title", - "duplicate-id-active", - "duplicate-id-aria", - "frame-focusable-content", - "frame-tested", - "frame-title", - "html-has-lang", - "html-lang-valid", - "html-xml-lang-mismatch", - "image-alt", - "input-button-name", - "input-image-alt", - "label", - "link-in-text-block", - "link-name", - "list", - "listitem", - "marquee", - "meta-refresh", - "meta-viewport", - "nested-interactive", - "object-alt", - "presentation-role-conflict", - "role-img-alt", - "select-name", - "server-side-image-map", - "svg-img-alt", - "td-headers-attr", - "th-has-data-cells", - "valid-lang", - "video-caption" - ] - }, - "pingWaitTime": 1000 + runOnly: { + type: 'rule', + values: [ + 'area-alt', + 'aria-allowed-attr', + 'aria-allowed-role', + 'aria-command-name', + 'aria-hidden-body', + 'aria-hidden-focus', + 'aria-input-field-name', + 'aria-meter-name', + 'aria-progressbar-name', + 'aria-required-attr', + 'aria-required-children', + 'aria-required-parent', + 'aria-roledescription', + 'aria-roles', + 'aria-toggle-field-name', + 'aria-tooltip-name', + 'aria-valid-attr-value', + 'aria-valid-attr', + 'audio-caption', + 'autocomplete-valid', + 'avoid-inline-spacing', + 'blink', + 'button-name', + 'bypass', + 'color-contrast', + 'definition-list', + 'dlitem', + 'document-title', + 'duplicate-id-active', + 'duplicate-id-aria', + 'frame-focusable-content', + 'frame-tested', + 'frame-title', + 'html-has-lang', + 'html-lang-valid', + 'html-xml-lang-mismatch', + 'image-alt', + 'input-button-name', + 'input-image-alt', + 'label', + 'link-in-text-block', + 'link-name', + 'list', + 'listitem', + 'marquee', + 'meta-refresh', + 'meta-viewport', + 'nested-interactive', + 'object-alt', + 'presentation-role-conflict', + 'role-img-alt', + 'select-name', + 'server-side-image-map', + 'svg-img-alt', + 'td-headers-attr', + 'th-has-data-cells', + 'valid-lang', + 'video-caption', + ], + }, + pingWaitTime: 1000, }; export const cloudAxeConfiguration: AxeConfiguration = { diff --git a/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.ts b/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.ts index 6a34a78f7..42c3506ab 100644 --- a/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.ts +++ b/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.ts @@ -19,9 +19,7 @@ export class AxePuppeteerFactory { public async createAxePuppeteer(page: Puppeteer.Page, contentSourcePath?: string, legacyMode: boolean = false): Promise { const axeSource = await this.getAxeSource(contentSourcePath); - return new AxePuppeteer(page, axeSource) - .configure(this.axeConfiguration) - .setLegacyMode(legacyMode); + return new AxePuppeteer(page, axeSource).configure(this.axeConfiguration).setLegacyMode(legacyMode); } private async getAxeSource(contentSourcePath?: string): Promise { From aeca3bad768e5db747bc320431da675e005e90eb Mon Sep 17 00:00:00 2001 From: Dan Bjorge Date: Tue, 21 Feb 2023 18:59:24 -0500 Subject: [PATCH 3/4] move run options to separate type from AxeConfiguration --- .../src/axe-scanner/axe-configuration.ts | 79 +------------------ .../axe-scanner/axe-puppeteer-factory.spec.ts | 9 ++- .../src/axe-scanner/axe-puppeteer-factory.ts | 4 +- .../src/axe-scanner/axe-run-options.ts | 79 +++++++++++++++++++ .../scanner-global-library/src/ioc-types.ts | 1 + .../src/setup-scanner-container.spec.ts | 9 +++ .../src/setup-scanner-container.ts | 3 + 7 files changed, 106 insertions(+), 78 deletions(-) create mode 100644 packages/scanner-global-library/src/axe-scanner/axe-run-options.ts diff --git a/packages/scanner-global-library/src/axe-scanner/axe-configuration.ts b/packages/scanner-global-library/src/axe-scanner/axe-configuration.ts index 56b2c9dc9..24cee67a2 100644 --- a/packages/scanner-global-library/src/axe-scanner/axe-configuration.ts +++ b/packages/scanner-global-library/src/axe-scanner/axe-configuration.ts @@ -5,82 +5,11 @@ import type { Spec } from 'axe-core'; export type AxeConfiguration = Spec; -// This is copied verbatim from the built version of the @accessibility-insights/axe-config -// package in microsoft/accessibility-insights-web. It must be updated with each axe-core update -// and also to pick up any out-of-band rule customizations. -// -// In the future, it would be nice to publish that package and pick it up via NPM instead of -// copying it here. See https://github.com/microsoft/accessibility-insights-service/issues/571 -const accessibilityInsightsWebAxeConfiguration = { - runOnly: { - type: 'rule', - values: [ - 'area-alt', - 'aria-allowed-attr', - 'aria-allowed-role', - 'aria-command-name', - 'aria-hidden-body', - 'aria-hidden-focus', - 'aria-input-field-name', - 'aria-meter-name', - 'aria-progressbar-name', - 'aria-required-attr', - 'aria-required-children', - 'aria-required-parent', - 'aria-roledescription', - 'aria-roles', - 'aria-toggle-field-name', - 'aria-tooltip-name', - 'aria-valid-attr-value', - 'aria-valid-attr', - 'audio-caption', - 'autocomplete-valid', - 'avoid-inline-spacing', - 'blink', - 'button-name', - 'bypass', - 'color-contrast', - 'definition-list', - 'dlitem', - 'document-title', - 'duplicate-id-active', - 'duplicate-id-aria', - 'frame-focusable-content', - 'frame-tested', - 'frame-title', - 'html-has-lang', - 'html-lang-valid', - 'html-xml-lang-mismatch', - 'image-alt', - 'input-button-name', - 'input-image-alt', - 'label', - 'link-in-text-block', - 'link-name', - 'list', - 'listitem', - 'marquee', - 'meta-refresh', - 'meta-viewport', - 'nested-interactive', - 'object-alt', - 'presentation-role-conflict', - 'role-img-alt', - 'select-name', - 'server-side-image-map', - 'svg-img-alt', - 'td-headers-attr', - 'th-has-data-cells', - 'valid-lang', - 'video-caption', - ], - }, - pingWaitTime: 1000, -}; +// Note that @axe-core/puppeteer version range ">= 4.2.0 < 4.3.0" does not support +// axe-core's allowedOrigins Spec property, which will cause these configurations to +// be *silently* misapplied. export const cloudAxeConfiguration: AxeConfiguration = { - ...accessibilityInsightsWebAxeConfiguration, - // We allow this for our own cloud workers because we can verify *both* that they // only use isolated, non-privileged browser contexts *and* they run in a network // environment that does not contain any private endpoints which expose secrets. @@ -88,8 +17,6 @@ export const cloudAxeConfiguration: AxeConfiguration = { }; export const localAxeConfiguration: AxeConfiguration = { - ...accessibilityInsightsWebAxeConfiguration, - // Local cases still use isolated, non-privileged browser contexts, but they may // be running in an environment with sensitive local/network endpoints, so we don't // allow cross-origin scanning. diff --git a/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.spec.ts b/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.spec.ts index c8e56a2b1..331a7e1ae 100644 --- a/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.spec.ts +++ b/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.spec.ts @@ -9,6 +9,7 @@ import * as Puppeteer from 'puppeteer'; import { IMock, Mock, MockBehavior, Times } from 'typemoq'; import { AxePuppeteerFactory } from './axe-puppeteer-factory'; import { AxeConfiguration } from './axe-configuration'; +import { AxeRunOptions } from './axe-run-options'; /* eslint-disable @typescript-eslint/no-explicit-any */ @@ -17,12 +18,14 @@ describe('AxePuppeteerFactory', () => { let page: IMock; let fsMock: IMock; let axeConfiguration: AxeConfiguration; + let axeRunOptions: AxeRunOptions; beforeEach(() => { page = Mock.ofType(); fsMock = Mock.ofInstance(fs, MockBehavior.Strict); axeConfiguration = { allowedOrigins: ['test origin'] }; - testSubject = new AxePuppeteerFactory(axeConfiguration, fsMock.object); + axeRunOptions = { runOnly: ['test-rule'] }; + testSubject = new AxePuppeteerFactory(axeConfiguration, axeRunOptions, fsMock.object); }); it('create axe puppeteer instance', async () => { @@ -30,6 +33,7 @@ describe('AxePuppeteerFactory', () => { expect(axePuppeteer).toBeDefined(); expect(axePuppeteer).toBeInstanceOf(AxePuppeteer); expect((axePuppeteer as any).config).toStrictEqual(axeConfiguration); + expect((axePuppeteer as any).axeOptions).toStrictEqual(axeRunOptions); }); it('create axe puppeteer instance, sourcePath is empty', async () => { @@ -37,6 +41,7 @@ describe('AxePuppeteerFactory', () => { expect(axePuppeteer).toBeDefined(); expect(axePuppeteer).toBeInstanceOf(AxePuppeteer); expect((axePuppeteer as any).config).toStrictEqual(axeConfiguration); + expect((axePuppeteer as any).axeOptions).toStrictEqual(axeRunOptions); }); it('create axe puppeteer instance, sourcePath is not empty', async () => { @@ -51,6 +56,7 @@ describe('AxePuppeteerFactory', () => { expect(axePuppeteer).toBeDefined(); expect(axePuppeteer).toBeInstanceOf(AxePuppeteer); expect((axePuppeteer as any).config).toStrictEqual(axeConfiguration); + expect((axePuppeteer as any).axeOptions).toStrictEqual(axeRunOptions); }); it('create axe puppeteer instance, legacyMode is true', async () => { @@ -58,5 +64,6 @@ describe('AxePuppeteerFactory', () => { expect(axePuppeteer).toBeDefined(); expect(axePuppeteer).toBeInstanceOf(AxePuppeteer); expect((axePuppeteer as any).config).toStrictEqual(axeConfiguration); + expect((axePuppeteer as any).axeOptions).toStrictEqual(axeRunOptions); }); }); diff --git a/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.ts b/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.ts index 42c3506ab..181896b9b 100644 --- a/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.ts +++ b/packages/scanner-global-library/src/axe-scanner/axe-puppeteer-factory.ts @@ -8,18 +8,20 @@ import { isEmpty } from 'lodash'; import * as Puppeteer from 'puppeteer'; import { iocTypes } from '../ioc-types'; import { AxeConfiguration } from './axe-configuration'; +import { AxeRunOptions } from './axe-run-options'; @injectable() export class AxePuppeteerFactory { constructor( @inject(iocTypes.AxeConfiguration) private readonly axeConfiguration: AxeConfiguration, + @inject(iocTypes.AxeRunOptions) private readonly axeRunOptions: AxeRunOptions, private readonly fileSystemObj: typeof fs = fs, ) {} public async createAxePuppeteer(page: Puppeteer.Page, contentSourcePath?: string, legacyMode: boolean = false): Promise { const axeSource = await this.getAxeSource(contentSourcePath); - return new AxePuppeteer(page, axeSource).configure(this.axeConfiguration).setLegacyMode(legacyMode); + return new AxePuppeteer(page, axeSource).configure(this.axeConfiguration).options(this.axeRunOptions).setLegacyMode(legacyMode); } private async getAxeSource(contentSourcePath?: string): Promise { diff --git a/packages/scanner-global-library/src/axe-scanner/axe-run-options.ts b/packages/scanner-global-library/src/axe-scanner/axe-run-options.ts new file mode 100644 index 000000000..1c82ba6e1 --- /dev/null +++ b/packages/scanner-global-library/src/axe-scanner/axe-run-options.ts @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import type { RunOptions } from 'axe-core'; + +export type AxeRunOptions = RunOptions; + +// This is copied verbatim from the built version of the @accessibility-insights/axe-config +// package in microsoft/accessibility-insights-web. It must be updated with each axe-core update +// and also to pick up any out-of-band rule customizations. +// +// In the future, it would be nice to publish that package and pick it up via NPM instead of +// copying it here. See https://github.com/microsoft/accessibility-insights-service/issues/571 +export const webAxeRunOptions: AxeRunOptions = { + runOnly: { + type: 'rule', + values: [ + 'area-alt', + 'aria-allowed-attr', + 'aria-allowed-role', + 'aria-command-name', + 'aria-hidden-body', + 'aria-hidden-focus', + 'aria-input-field-name', + 'aria-meter-name', + 'aria-progressbar-name', + 'aria-required-attr', + 'aria-required-children', + 'aria-required-parent', + 'aria-roledescription', + 'aria-roles', + 'aria-toggle-field-name', + 'aria-tooltip-name', + 'aria-valid-attr-value', + 'aria-valid-attr', + 'audio-caption', + 'autocomplete-valid', + 'avoid-inline-spacing', + 'blink', + 'button-name', + 'bypass', + 'color-contrast', + 'definition-list', + 'dlitem', + 'document-title', + 'duplicate-id-active', + 'duplicate-id-aria', + 'frame-focusable-content', + 'frame-tested', + 'frame-title', + 'html-has-lang', + 'html-lang-valid', + 'html-xml-lang-mismatch', + 'image-alt', + 'input-button-name', + 'input-image-alt', + 'label', + 'link-in-text-block', + 'link-name', + 'list', + 'listitem', + 'marquee', + 'meta-refresh', + 'meta-viewport', + 'nested-interactive', + 'object-alt', + 'presentation-role-conflict', + 'role-img-alt', + 'select-name', + 'server-side-image-map', + 'svg-img-alt', + 'td-headers-attr', + 'th-has-data-cells', + 'valid-lang', + 'video-caption', + ], + }, + pingWaitTime: 1000, +}; diff --git a/packages/scanner-global-library/src/ioc-types.ts b/packages/scanner-global-library/src/ioc-types.ts index 34a6a1164..7da2e24b8 100644 --- a/packages/scanner-global-library/src/ioc-types.ts +++ b/packages/scanner-global-library/src/ioc-types.ts @@ -3,5 +3,6 @@ export const iocTypes = { AxeConfiguration: 'AxeConfiguration', + AxeRunOptions: 'AxeRunOptions', AzureAuthClientCredentialProvider: 'azureAuthClientCredentialProvider', }; diff --git a/packages/scanner-global-library/src/setup-scanner-container.spec.ts b/packages/scanner-global-library/src/setup-scanner-container.spec.ts index ef7ae4177..756602b9d 100644 --- a/packages/scanner-global-library/src/setup-scanner-container.spec.ts +++ b/packages/scanner-global-library/src/setup-scanner-container.spec.ts @@ -7,6 +7,7 @@ import { Container } from 'inversify'; import { AxePuppeteerFactory } from './axe-scanner/axe-puppeteer-factory'; import { setupCloudScannerContainer, setupLocalScannerContainer } from './setup-scanner-container'; import { cloudAxeConfiguration, localAxeConfiguration } from './axe-scanner/axe-configuration'; +import { webAxeRunOptions } from './axe-scanner/axe-run-options'; import { iocTypes } from './ioc-types'; /* eslint-disable @typescript-eslint/no-explicit-any */ @@ -27,6 +28,10 @@ describe(setupCloudScannerContainer, () => { expect(container.get(iocTypes.AxeConfiguration)).toBe(cloudAxeConfiguration); }); + it('should use webAxeRunOptions', () => { + expect(container.get(iocTypes.AxeRunOptions)).toBe(webAxeRunOptions); + }); + function verifySingletonResolution(key: any): void { expect(container.get(key)).toBeDefined(); expect(container.get(key)).toBe(container.get(key)); @@ -44,4 +49,8 @@ describe(setupLocalScannerContainer, () => { it('should use localAxeConfiguration', () => { expect(container.get(iocTypes.AxeConfiguration)).toBe(localAxeConfiguration); }); + + it('should use webAxeRunOptions', () => { + expect(container.get(iocTypes.AxeRunOptions)).toBe(webAxeRunOptions); + }); }); diff --git a/packages/scanner-global-library/src/setup-scanner-container.ts b/packages/scanner-global-library/src/setup-scanner-container.ts index 616108433..63f16d1ba 100644 --- a/packages/scanner-global-library/src/setup-scanner-container.ts +++ b/packages/scanner-global-library/src/setup-scanner-container.ts @@ -3,11 +3,13 @@ import * as inversify from 'inversify'; import { cloudAxeConfiguration, localAxeConfiguration } from './axe-scanner/axe-configuration'; +import { webAxeRunOptions } from './axe-scanner/axe-run-options'; import { AxePuppeteerFactory } from './axe-scanner/axe-puppeteer-factory'; import { iocTypes } from './ioc-types'; export function setupCloudScannerContainer(container: inversify.Container): inversify.Container { container.bind(iocTypes.AxeConfiguration).toConstantValue(cloudAxeConfiguration); + container.bind(iocTypes.AxeRunOptions).toConstantValue(webAxeRunOptions); container.bind(AxePuppeteerFactory).toSelf().inSingletonScope(); return container; @@ -15,6 +17,7 @@ export function setupCloudScannerContainer(container: inversify.Container): inve export function setupLocalScannerContainer(container: inversify.Container): inversify.Container { container.bind(iocTypes.AxeConfiguration).toConstantValue(localAxeConfiguration); + container.bind(iocTypes.AxeRunOptions).toConstantValue(webAxeRunOptions); return container; } From cfb9a316f82a570e65592404c776a05d65b4334f Mon Sep 17 00:00:00 2001 From: Dan Bjorge Date: Tue, 21 Feb 2023 19:07:17 -0500 Subject: [PATCH 4/4] Update webAxeRunOptions with in-progress PRs dropping bypass and frame-tested --- .../scanner-global-library/src/axe-scanner/axe-run-options.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/scanner-global-library/src/axe-scanner/axe-run-options.ts b/packages/scanner-global-library/src/axe-scanner/axe-run-options.ts index 1c82ba6e1..600da58c5 100644 --- a/packages/scanner-global-library/src/axe-scanner/axe-run-options.ts +++ b/packages/scanner-global-library/src/axe-scanner/axe-run-options.ts @@ -38,7 +38,6 @@ export const webAxeRunOptions: AxeRunOptions = { 'avoid-inline-spacing', 'blink', 'button-name', - 'bypass', 'color-contrast', 'definition-list', 'dlitem', @@ -46,7 +45,6 @@ export const webAxeRunOptions: AxeRunOptions = { 'duplicate-id-active', 'duplicate-id-aria', 'frame-focusable-content', - 'frame-tested', 'frame-title', 'html-has-lang', 'html-lang-valid',