Skip to content

Commit

Permalink
Merge branch 'master' into learnMore-2002-nam
Browse files Browse the repository at this point in the history
  • Loading branch information
drjoho authored Aug 28, 2024
2 parents d754d2b + 1ec0962 commit a690091
Show file tree
Hide file tree
Showing 12 changed files with 429 additions and 107 deletions.
3 changes: 2 additions & 1 deletion accessibility-checker-engine/src/v4/api/IRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ export type Issue = RuleResult & {
ruleTime: number,
message: string,
bounds?: Bounds,
snippet: string
snippet: string,
level?: string
}

export type RuleContextHierarchy = { [namespace: string] : IMapResult[] };
Expand Down
28 changes: 14 additions & 14 deletions accessibility-checker-extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*****************************************************************************/

import { getDevtoolsController } from "../devtools/devtoolsController";
import { IArchiveDefinition, IIssue, IMessage, IReport, IRuleset, ISessionState, ISettings } from "../interfaces/interfaces";
import { IArchiveDefinition, IIssue, IMessage, IReport, IRuleset, ISessionState, ISettings, IssueValue } from "../interfaces/interfaces";
import { CommonMessaging } from "../messaging/commonMessaging";
import { Controller, eControllerType, ListenerType } from "../messaging/controller";
import Config from "../util/config";
Expand Down Expand Up @@ -394,6 +394,63 @@ class BackgroundController extends Controller {
}
delete result.node;
}

// Process report before returning it to avoid large message passing of pass messages
if (report) {
let valueMap: { [key: string]: { [key2: string]: string } } = {
"VIOLATION": {
"POTENTIAL": "Needs review",
"FAIL": "Violation",
"PASS": "Pass",
"MANUAL": "Needs review"
},
"RECOMMENDATION": {
"POTENTIAL": "Recommendation",
"FAIL": "Recommendation",
"PASS": "Pass",
"MANUAL": "Recommendation"
},
"INFORMATION": {
"POTENTIAL": "Needs review",
"FAIL": "Violation",
"PASS": "Pass",
"MANUAL": "Recommendation"
}
};

let valueToStringSingular = (value: IssueValue) => {
return valueMap[value[0]][value[1]];
}
for (const result of report.results) {
if (result.ruleTime > 50) {
console.info(`[PERF: ${result.ruleId}] ${result.ruleTime}`);
}
}
// let passResults = [];
let remainResults = [];
let counts = {
"Violation": 0,
"Needs review": 0,
"Recommendation": 0,
"Pass": 0,
total: 0
};
let xpaths : string[] = report.results.map((result) => result.path.dom);
report.testedUniqueElements = Array.from(new Set(xpaths)).length;
for (const result of report.results) {
let sing = valueToStringSingular(result.value);
++counts[sing as eLevel];
++counts.total;
if (result.value[1] === "PASS" && result.value[0] !== "INFORMATION") {
// passResults.push(result);
} else {
remainResults.push(result);
}
}
report.results = remainResults;
report.counts = counts;
}

return report;
} catch (err) {
console.error(err);
Expand All @@ -418,11 +475,6 @@ class BackgroundController extends Controller {
this.metrics.sendLogsV2();
getDevtoolsController(toolTabId, false, "remote").setScanningState("processing");
if (report) {
for (const result of report.results) {
if (result.ruleTime > 50) {
console.info(`[PERF: ${result.ruleId}] ${result.ruleTime}`);
}
}
report.results.sort((resultA, resultB) => {
let valueA = UtilIssue.valueToStringSingular(resultA.value);
let valueB = UtilIssue.valueToStringSingular(resultB.value);
Expand All @@ -435,29 +487,6 @@ class BackgroundController extends Controller {
if (valueB === "Recommendation") return 1;
return 0;
});
// let passResults = [];
let remainResults = [];
let counts = {
"Violation": 0,
"Needs review": 0,
"Recommendation": 0,
"Pass": 0,
total: 0
};
let xpaths : string[] = report.results.map((result) => result.path.dom);
report.testedUniqueElements = Array.from(new Set(xpaths)).length;
for (const result of report.results) {
let sing = UtilIssue.valueToStringSingular(result.value);
++counts[sing as eLevel];
++counts.total;
if (result.value[1] === "PASS" && result.value[0] !== "INFORMATION") {
// passResults.push(result);
} else {
remainResults.push(result);
}
}
report.results = remainResults;
report.counts = counts;
}

getDevtoolsController(toolTabId, false, "remote").setReport(report);
Expand Down
6 changes: 3 additions & 3 deletions accessibility-checker-extension/test/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a690091

Please sign in to comment.