Files
react-native-devtools-frontend/front_end/sdk/LowTextContrastIssue.ts
T
Alex Rudenko d6594130ef Report low contrast issues
This CL adds the logic to trigger contrast checks on DevTools
startup or on page load events. The check is only triggered if
the corresponding experiment (contrastIssues) is enabled.
Deduplication of the reported issues happens in the IssueManager
on the frontend since the same issue might be reported twice
if there are multiple documents on the target page.

Bug: chromium:1155460
Change-Id: Ib0d5115c527ceb9da9d2ed2dfa48cfdca6f82f60
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2573360
Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
Reviewed-by: Simon Zünd <szuend@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
2021-02-04 12:39:48 +00:00

42 lines
1.4 KiB
TypeScript

// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {ls} from '../common/common.js'; // eslint-disable-line rulesdir/es_modules_import
import {Issue, IssueCategory, IssueKind, MarkdownIssueDescription} from './Issue.js'; // eslint-disable-line no-unused-vars
export class LowTextContrastIssue extends Issue {
private issueDetails: Protocol.Audits.LowTextContrastIssueDetails;
constructor(issueDetails: Protocol.Audits.LowTextContrastIssueDetails) {
super('LowTextContrastIssue');
this.issueDetails = issueDetails;
}
primaryKey(): string {
// We intend to keep only one issue per element so other issues for the element will be discarded even
// if the issue content is slightly different.
return `${this.code()}-(${this.issueDetails.violatingNodeId})`;
}
getCategory(): IssueCategory {
return IssueCategory.LowTextContrast;
}
details(): Protocol.Audits.LowTextContrastIssueDetails {
return this.issueDetails;
}
getDescription(): MarkdownIssueDescription {
return {
file: 'issues/descriptions/LowTextContrast.md',
substitutions: undefined,
issueKind: IssueKind.BreakingChange,
links: [
{link: 'https://web.dev/color-and-contrast-accessibility/', linkTitle: ls`Color and contrast accessibility`},
],
};
}
}