accessibility-checker 3.1.49 → 3.1.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +75 -67
  2. package/bin/achecker.js +14 -17
  3. package/bin/achecker.js.map +1 -1
  4. package/index.d.ts +6 -4
  5. package/index.js +9 -8
  6. package/index.js.map +1 -1
  7. package/lib/ACBrowserManager.d.ts +2 -2
  8. package/lib/ACBrowserManager.js +2 -3
  9. package/lib/ACBrowserManager.js.map +1 -1
  10. package/lib/ACEngineManager.d.ts +1 -12
  11. package/lib/ACEngineManager.js +72 -40
  12. package/lib/ACEngineManager.js.map +1 -1
  13. package/lib/ACHelper.js +126 -137
  14. package/lib/ACHelper.js.map +1 -1
  15. package/lib/api/IChecker.d.ts +3 -114
  16. package/lib/api/IChecker.js +1 -1
  17. package/lib/api/IChecker.js.map +1 -1
  18. package/lib/common/api-ext/Fetch.d.ts +16 -0
  19. package/lib/common/api-ext/Fetch.js +83 -0
  20. package/lib/common/api-ext/Fetch.js.map +1 -0
  21. package/lib/common/api-ext/IAbstractAPI.d.ts +34 -0
  22. package/lib/common/api-ext/IAbstractAPI.js +18 -0
  23. package/lib/common/api-ext/IAbstractAPI.js.map +1 -0
  24. package/lib/common/config/ACConfigManager.d.ts +7 -0
  25. package/lib/{ACConfigManager.js → common/config/ACConfigManager.js} +28 -19
  26. package/lib/common/config/ACConfigManager.js.map +1 -0
  27. package/lib/{ACConstants.d.ts → common/config/ACConstants.d.ts} +2 -2
  28. package/lib/{ACConstants.js → common/config/ACConstants.js} +7 -5
  29. package/lib/common/config/ACConstants.js.map +1 -0
  30. package/lib/common/config/IArchive.d.ts +37 -0
  31. package/lib/{reporters/multiScanReportUtil.d.ts → common/config/IArchive.js} +4 -5
  32. package/lib/common/config/IArchive.js.map +1 -0
  33. package/lib/common/config/IConfig.d.ts +146 -0
  34. package/lib/common/config/IConfig.js +36 -0
  35. package/lib/common/config/IConfig.js.map +1 -0
  36. package/lib/common/report/ACReporterCSV.d.ts +27 -0
  37. package/lib/common/report/ACReporterCSV.js +105 -0
  38. package/lib/common/report/ACReporterCSV.js.map +1 -0
  39. package/lib/common/report/ACReporterHTML.d.ts +26 -0
  40. package/lib/common/report/ACReporterHTML.js +94 -0
  41. package/lib/common/report/ACReporterHTML.js.map +1 -0
  42. package/lib/common/report/ACReporterJSON.d.ts +46 -0
  43. package/lib/common/report/ACReporterJSON.js +140 -0
  44. package/lib/common/report/ACReporterJSON.js.map +1 -0
  45. package/lib/{log/ACMetricsLogger.d.ts → common/report/ACReporterMetrics.d.ts} +11 -6
  46. package/lib/{log/ACMetricsLogger.js → common/report/ACReporterMetrics.js} +85 -70
  47. package/lib/common/report/ACReporterMetrics.js.map +1 -0
  48. package/lib/common/report/ACReporterXLSX.d.ts +37 -0
  49. package/lib/common/report/ACReporterXLSX.js +1004 -0
  50. package/lib/common/report/ACReporterXLSX.js.map +1 -0
  51. package/lib/common/report/BaselineManager.d.ts +169 -0
  52. package/lib/common/report/BaselineManager.js +355 -0
  53. package/lib/common/report/BaselineManager.js.map +1 -0
  54. package/lib/common/report/ReporterManager.d.ts +79 -0
  55. package/lib/common/report/ReporterManager.js +552 -0
  56. package/lib/common/report/ReporterManager.js.map +1 -0
  57. package/lib/common/report/genReport.js.map +1 -0
  58. package/package.json +1 -1
  59. package/lib/ACConfigManager.d.ts +0 -7
  60. package/lib/ACConfigManager.js.map +0 -1
  61. package/lib/ACConstants.js.map +0 -1
  62. package/lib/ACReportManager.d.ts +0 -590
  63. package/lib/ACReportManager.js +0 -1201
  64. package/lib/ACReportManager.js.map +0 -1
  65. package/lib/api/IEngine.d.ts +0 -129
  66. package/lib/api/IEngine.js +0 -110
  67. package/lib/api/IEngine.js.map +0 -1
  68. package/lib/log/ACMetricsLogger.js.map +0 -1
  69. package/lib/reporters/ACReporterCSV.d.ts +0 -103
  70. package/lib/reporters/ACReporterCSV.js +0 -193
  71. package/lib/reporters/ACReporterCSV.js.map +0 -1
  72. package/lib/reporters/ACReporterHTML.d.ts +0 -114
  73. package/lib/reporters/ACReporterHTML.js +0 -360
  74. package/lib/reporters/ACReporterHTML.js.map +0 -1
  75. package/lib/reporters/ACReporterJSON.d.ts +0 -114
  76. package/lib/reporters/ACReporterJSON.js +0 -277
  77. package/lib/reporters/ACReporterJSON.js.map +0 -1
  78. package/lib/reporters/ACReporterXLSX.d.ts +0 -109
  79. package/lib/reporters/ACReporterXLSX.js +0 -405
  80. package/lib/reporters/ACReporterXLSX.js.map +0 -1
  81. package/lib/reporters/ReportUtil.d.ts +0 -33
  82. package/lib/reporters/ReportUtil.js +0 -65
  83. package/lib/reporters/ReportUtil.js.map +0 -1
  84. package/lib/reporters/genReport.js.map +0 -1
  85. package/lib/reporters/multiScanData.d.ts +0 -27
  86. package/lib/reporters/multiScanData.js +0 -190
  87. package/lib/reporters/multiScanData.js.map +0 -1
  88. package/lib/reporters/multiScanReport.d.ts +0 -25
  89. package/lib/reporters/multiScanReport.js +0 -1729
  90. package/lib/reporters/multiScanReport.js.map +0 -1
  91. package/lib/reporters/multiScanReportUtil.js +0 -49
  92. package/lib/reporters/multiScanReportUtil.js.map +0 -1
  93. /package/lib/{reporters → common/report}/genReport.d.ts +0 -0
  94. /package/lib/{reporters → common/report}/genReport.js +0 -0
@@ -1,1201 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.ACReportManager = void 0;
40
- var IChecker_1 = require("./api/IChecker");
41
- var ACConfigManager_1 = require("./ACConfigManager");
42
- var ACMetricsLogger_1 = require("./log/ACMetricsLogger");
43
- var path = require("path");
44
- var ACEngineManager_1 = require("./ACEngineManager");
45
- var __1 = require("..");
46
- var DeepDiff = require("deep-diff");
47
- var ACReporterCSV_1 = require("./reporters/ACReporterCSV");
48
- var ACReporterXLSX_1 = require("./reporters/ACReporterXLSX");
49
- var ReportUtil_1 = require("./reporters/ReportUtil");
50
- var ACReporterHTML_1 = require("./reporters/ACReporterHTML");
51
- var ACReporterJSON_1 = require("./reporters/ACReporterJSON");
52
- var IEngine_1 = require("./api/IEngine");
53
- var ACReportManager = /** @class */ (function () {
54
- function ACReportManager() {
55
- }
56
- ACReportManager.initialize = function (logger) {
57
- return __awaiter(this, void 0, void 0, function () {
58
- var _a;
59
- return __generator(this, function (_b) {
60
- switch (_b.label) {
61
- case 0:
62
- if (ACReportManager.config)
63
- return [2 /*return*/];
64
- _a = ACReportManager;
65
- return [4 /*yield*/, ACConfigManager_1.ACConfigManager.getConfigUnsupported()];
66
- case 1:
67
- _a.config = _b.sent();
68
- if (ACReportManager.config.ruleServer.includes("localhost")) {
69
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
70
- }
71
- // Initialize the scanSummary object with summary information for accessibility-checker
72
- ACReportManager.scanSummary = (0, ReportUtil_1.initializeSummary)(ACReportManager.config);
73
- ACReportManager.reporters = {
74
- html: new ACReporterHTML_1.ACReporterHTML(ACReportManager.config, ACReportManager.scanSummary),
75
- json: new ACReporterJSON_1.ACReporterJSON(ACReportManager.config, ACReportManager.scanSummary),
76
- csv: new ACReporterCSV_1.ACReporterCSV(ACReportManager.config, ACReportManager.scanSummary),
77
- xlsx: new ACReporterXLSX_1.ACReporterXLSX(ACReportManager.config, ACReportManager.scanSummary)
78
- };
79
- ACReportManager.metricsLogger = new ACMetricsLogger_1.ACMetricsLogger("accessibility-checker", logger, ACReportManager.config.policies);
80
- // Initialize the global object which will store all the diff results for a scan that is run, using
81
- // actual and expected.
82
- ACReportManager.diffResults = {};
83
- // Initialize the global object which will store all the scan results indexed by the label.
84
- ACReportManager.scanResults = {};
85
- return [2 /*return*/];
86
- }
87
- });
88
- });
89
- };
90
- /**
91
- * This function is responsible for checking if the provided label is unique or not.
92
- *
93
- * @param {String} label - Provide the label which should be checked if it exists or not
94
- *
95
- * @return {boolean} labelExists - return false if the label is not unique, otherwise return true
96
- *
97
- * PRIVATE METHOD
98
- *
99
- * @memberOf this
100
- */
101
- ACReportManager.isLabelUnique = function (label) {
102
- ACReportManager.config.DEBUG && console.log("ACReportManager:START 'aChecker.isLabelUnique' function");
103
- // Variable Decleration
104
- var labelExists = false;
105
- ACReportManager.config.DEBUG && console.log("Checking if label: " + label + " is unique.");
106
- // Check if the label that is provided was already used or not, by simply calling the some API on the array
107
- // and passing it a callback function which checks if the label exists in the global paceScanSummary object.
108
- labelExists = ACReportManager.scanSummary.pageScanSummary.some(function (scanSummary) {
109
- return scanSummary.label === label;
110
- });
111
- ACReportManager.config.DEBUG && console.log("END 'aChecker.isLabelUnique' function");
112
- return !labelExists;
113
- };
114
- ;
115
- /**
116
- * This function is responsible for sending the scan results to the karma server accessibility-checker reporter. The
117
- * accessibility-checker reporter is responsible for writing the results to a file. The reporter will also keep track of
118
- * the summary results, on the server side.
119
- *
120
- * @param {Object} results - Provide the full results object which is to be reported/saved to file.
121
- * refer to return in function "aChecker.buildReport" prolog
122
- *
123
- * @return N/A
124
- *
125
- * PRIVATE METHOD
126
- *
127
- * @memberOf this
128
- */
129
- ACReportManager.sendResultsToReporter = function (unFilteredResults, results, profile) {
130
- return __awaiter(this, void 0, void 0, function () {
131
- return __generator(this, function (_a) {
132
- switch (_a.label) {
133
- case 0:
134
- ACReportManager.config.DEBUG && console.log("ACReportManager:sendResultsToReporter:", ACReportManager.config.outputFormat);
135
- if (ACReportManager.config.outputFormat.indexOf("json") != -1) {
136
- ACReportManager.reporters.json.report(results);
137
- }
138
- if (ACReportManager.config.outputFormat.includes("csv")) {
139
- ACReportManager.reporters.csv.report(results);
140
- }
141
- if (ACReportManager.config.outputFormat.includes("xlsx")) {
142
- ACReportManager.reporters.xlsx.report(results);
143
- }
144
- if (!(ACReportManager.config.outputFormat.indexOf("html") != -1)) return [3 /*break*/, 2];
145
- return [4 /*yield*/, ACReportManager.reporters.html.report(unFilteredResults)];
146
- case 1:
147
- _a.sent();
148
- _a.label = 2;
149
- case 2:
150
- // Only perform the profiling if profiling was not disabled on purpose
151
- if (!ACReportManager.config.label || ACReportManager.config.label.indexOf("IBMa-Node-TeSt") === -1) {
152
- // Meter the usage here
153
- ACReportManager.metricsLogger.profileV2(results.summary.scanTime, profile);
154
- }
155
- return [2 /*return*/];
156
- }
157
- });
158
- });
159
- };
160
- ;
161
- ACReportManager.sendScreenShotToReporter = function (screenshotResult) {
162
- };
163
- ;
164
- /**
165
- * This function is responsible for building the results object in a specific format which will be provided back to
166
- * the user to do any thing they want to do with it. (compare, print it, save to db, etc...)
167
- *
168
- * Note: This function converts it to match with the following format outlined at:
169
- * https://github.com/IBMa/equal-access/tree/master/karma-accessibility-checker
170
- *
171
- * @param {Object} results - The results object which we need to build the report based on, following is the format the
172
- * object needs to follow:
173
- * {
174
- * "report": {
175
- * "numChecked": 227,
176
- * "numTrigger": 1,
177
- * "ruleTime": 5,
178
- * "totalTime": 8,
179
- * "issues": [
180
- * {
181
- * "severityCode": "eISHigh",
182
- * "messageCode": "rpt.g377.elemUniqueId",
183
- * "ruleId": "377",
184
- * "help": "idhi_accessibility_check_g377.html",
185
- * "msgArgs": [
186
- * "div",
187
- * "firstDiv"
188
- * ],
189
- * "xpath": "/html[1]/body[1]/div[2]/div[2]",
190
- * "snippet": "<div id=\"firstDiv\">",
191
- * "bounds": {
192
- * "left": 10,
193
- * "top": 181,
194
- * "height": 0,
195
- * "width": 1249
196
- * },
197
- * "level": "violation"
198
- * }
199
- * ],
200
- * "docTitle": "Helo World"
201
- * },
202
- * "counts": {
203
- * "violation": 1,
204
- * "potentialviolation": 0,
205
- * "recommendation": 0,
206
- * "potentialrecommendation": 0,
207
- * "manual": 0
208
- * },
209
- * "issueMessages": {
210
- * "messages": {
211
- * "rpt.g377.elemUniqueId": "The {0} element has the id \"{1}\" that is either empty or already in use."
212
- * },
213
- * "lang": "en-us"
214
- * }
215
- * }
216
- *
217
- * @param {String} URL - The URL which the report is being built for
218
- * @param {String} label - A label to identify what this report is going to be for, in the case not using URL or local files.
219
- * @param {String} startScan - The start time of the scan.
220
- *
221
- * @return {Object} results - return the formatted results based in the following format:
222
- *
223
- * {
224
- * "scanID": "ef3aec68-f073-4f9c-b372-421ae00bd55d",
225
- * "toolID": "karma-ibma-v1.0.0",
226
- * "summary": {
227
- * "counts": {
228
- * "violation": 5,
229
- * "potentialviolation": 0,
230
- * "recommendation": 5,
231
- * "potentialrecommendation": 0,
232
- * "manual": 1
233
- * },
234
- * "scanTime": 80,
235
- * "policies": [
236
- * "CI162_5_2_DCP080115"
237
- * ],
238
- * "reportLevels": [
239
- * "violation",
240
- * "potentialviolation",
241
- * "recommendation",
242
- * "potentialrecommendation",
243
- * "manual"
244
- * ],
245
- * "startScan": "2016-06-06T00:52:41.603Z"
246
- * },
247
- * "URL": "",
248
- * "label": "unitTestContent",
249
- * "screenshot": "<placeholder>",
250
- * "issueMessages": {
251
- * "messages": {
252
- * "rpt.g377.elemUniqueId": "The {0} element has the id \"{1}\" that is either empty or already in use."
253
- * },
254
- * "lang": "en-us"
255
- * },
256
- * "reports": [
257
- * {
258
- * "frameIdx": "0",
259
- * "frameTitle": "Frame 0",
260
- * "issues": [
261
- * {
262
- * "severity": "Low",
263
- * "message": "If style sheets are ignored or unsupported, ensure that pages are still readable and usable.",
264
- * "messageCode": "rpt.g1.styleTrigger",
265
- * "ruleId": "1",
266
- * "help": "idhi_accessibility_check_g1.html",
267
- * "msgArgs": [],
268
- * "bounds": {
269
- * "left": 0,
270
- * "top": 0,
271
- * "height": 0,
272
- * "width": 0
273
- * },
274
- * "level": "manual",
275
- * "xpath": "/html[1]/head[1]/style[1]",
276
- * "snippet": "<style type=\"text/css\">"
277
- * }
278
- * ....
279
- * ]
280
- * },
281
- * {
282
- * "frameIdx": "1",
283
- * "frameTitle": "Frame 1",
284
- * "issues": [
285
- * {
286
- * "severity": "High",
287
- * "message": "The table element with WAI-ARIA presentation role has structural element(s) and/or attribute(s) td.",
288
- * "messageCode": "rpt.g471.tableStructure",
289
- * "ruleId": "471",
290
- * "help": "idhi_accessibility_check_g471.html",
291
- * "msgArgs": [
292
- * "table",
293
- * "td"
294
- * ],
295
- * "bounds": {
296
- * "left": 10,
297
- * "top": 990,
298
- * "height": 219,
299
- * "width": 335
300
- * },
301
- * "level": "violation",
302
- * "xpath": "/html[1]/body[1]/div[2]/table[3]",
303
- * "snippet": "<table id=\"layout_table3\" role=\"presentation\">"
304
- * }
305
- * ....
306
- * ]
307
- * }
308
- * ]
309
- * }
310
- *
311
- * PRIVATE METHOD
312
- *
313
- * @memberOf this
314
- */
315
- ACReportManager.buildReport = function (inReport, counts, URL, label, startScan) {
316
- var report = JSON.parse(JSON.stringify(inReport));
317
- // Build the scan summary object which will be added to the build report
318
- // Note: This summary is only for this single scan.
319
- report.summary = {
320
- counts: counts,
321
- scanTime: inReport.totalTime,
322
- ruleArchive: ACReportManager.config.ruleArchiveLabel,
323
- policies: ACReportManager.config.policies,
324
- reportLevels: ACReportManager.config.reportLevels,
325
- startScan: startScan,
326
- URL: URL
327
- };
328
- // Add scanID (UUID) to the individual pages
329
- report.scanID = ACReportManager.config.scanID;
330
- // Add toolID to the individual pages
331
- report.toolID = ACReportManager.config.toolID;
332
- // Add the URL to the object it it is defined
333
- if (URL !== null && typeof URL !== "undefined") {
334
- report.summary.URL = URL;
335
- }
336
- // Add the label to the result object, label should always be
337
- // defined no matter what as it is required to be provided by the user.
338
- report.label = label;
339
- // Add the screenshot base64 object to the results object
340
- // TODO: Find a way to actually extract the screenshot, since karma
341
- // allows the use of any browesr, some browser do not allow taking screenshot
342
- // so would have to alalyze which browser allow it and take it for only those.
343
- // PhantonJS, any selenium drived browser.
344
- //results.screenshot = "<placeholder>";
345
- // Clean up the results object
346
- delete report.counts;
347
- delete report.ruleTime;
348
- delete report.totalTime;
349
- // set ignore:true for previously seen violations
350
- // retrieve baseline
351
- var baselineReport = ACReportManager.getBaseline(label);
352
- // set ignore:true for previously seen violations and set ignore to false if no ignore fields exist yet
353
- if (baselineReport) {
354
- report = ACReportManager.ignoreExtraBaselineViolations(report, baselineReport);
355
- }
356
- else { //add ignored field
357
- report.summary.counts.ignored = 0;
358
- }
359
- var lvlIdx = {
360
- "violation": 1,
361
- "potentialviolation": 2,
362
- "recommendation": 3,
363
- "potentialrecommendation": 4,
364
- "manual": 5,
365
- "pass": 6
366
- };
367
- report.results.sort(function (a, b) {
368
- var aLvl = lvlIdx[a.level];
369
- var bLvl = lvlIdx[b.level];
370
- if (!aLvl)
371
- aLvl = 7;
372
- if (!bLvl)
373
- bLvl = 7;
374
- return aLvl != bLvl && aLvl - bLvl ||
375
- b.ruleId != a.ruleId && b.ruleId.localeCompare(a.ruleId) ||
376
- b.path.dom.localeCompare(a.path.dom);
377
- });
378
- return report;
379
- };
380
- ;
381
- /**
382
- * This function is responsible for filtering the violations so that, only the violations levels that
383
- * are provided in reportLevels are presented in the report.
384
- *
385
- * TODO: Possibly we can add this to the engine, so that the results are not provided by the engine
386
- * when user has provided the reportLevels object.
387
- *
388
- * @param {Object} results - Provide the violation results, which follow the following format:
389
- * {
390
- * "report": {
391
- * "numChecked": 227,
392
- * "numTrigger": 1,
393
- * "ruleTime": 5,
394
- * "totalTime": 8,
395
- * "issues": [
396
- * {
397
- * "severityCode": "eISHigh",
398
- * "messageCode": "rpt.g377.elemUniqueId",
399
- * "ruleId": "377",
400
- * "help": "idhi_accessibility_check_g377.html",
401
- * "msgArgs": [
402
- * "div",
403
- * "firstDiv"
404
- * ],
405
- * "xpath": "/html[1]/body[1]/div[2]/div[2]",
406
- * "snippet": "<div id=\"firstDiv\">",
407
- * "bounds": {
408
- * "left": 10,
409
- * "top": 181,
410
- * "height": 0,
411
- * "width": 1249
412
- * },
413
- * "level": "violation"
414
- * }
415
- * ],
416
- * "docTitle": "Helo World"
417
- * },
418
- * "counts": {
419
- * "level.violation": 1,
420
- * "level.potentialviolation": 0,
421
- * "level.recommendation": 0,
422
- * "level.potentialrecommendation": 0,
423
- * "level.manual": 0
424
- * },
425
- * "issueMessages": {
426
- * "messages": {
427
- * "rpt.g377.elemUniqueId": "The {0} element has the id \"{1}\" that is either empty or already in use."
428
- * },
429
- * "lang": "en-us"
430
- * }
431
- * }
432
- *
433
- * @return {Object} results - return results object which only contains the violation that were requested,
434
- * follows the following format:
435
- * {
436
- * "report": {
437
- * "numChecked": 227,
438
- * "numTrigger": 1,
439
- * "ruleTime": 5,
440
- * "totalTime": 8,
441
- * "issues": [
442
- * {
443
- * "severityCode": "eISHigh",
444
- * "messageCode": "rpt.g377.elemUniqueId",
445
- * "ruleId": "377",
446
- * "help": "idhi_accessibility_check_g377.html",
447
- * "msgArgs": [
448
- * "div",
449
- * "firstDiv"
450
- * ],
451
- * "xpath": "/html[1]/body[1]/div[2]/div[2]",
452
- * "snippet": "<div id=\"firstDiv\">",
453
- * "bounds": {
454
- * "left": 10,
455
- * "top": 181,
456
- * "height": 0,
457
- * "width": 1249
458
- * },
459
- * "level": "violation"
460
- * }
461
- * ],
462
- * "docTitle": "Helo World"
463
- * },
464
- * "counts": {
465
- * "level.violation": 1,
466
- * "level.potentialviolation": 0,
467
- * "level.recommendation": 0,
468
- * "level.potentialrecommendation": 0,
469
- * "level.manual": 0
470
- * },
471
- * "issueMessages": {
472
- * "messages": {
473
- * "rpt.g377.elemUniqueId": "The {0} element has the id \"{1}\" that is either empty or already in use."
474
- * },
475
- * "lang": "en-us"
476
- * }
477
- * }
478
- *
479
- * The return object is pretty much filtered failures (results.report.fail), wrapped around another object with extra frameIdx value.
480
- *
481
- * PRIVATE METHOD
482
- *
483
- * @memberOf this
484
- */
485
- ACReportManager.filterViolations = function (report) {
486
- // Variable Decleration
487
- var reportLevels = ACReportManager.config.reportLevels;
488
- var pageResults = report.results;
489
- // Loop over all the violations and filter them, if the violation level does not match with, what user has
490
- // requested to be reported. Also handle hidden at this point right now.
491
- // TODO: Posible to filter the results directly in the engine, to avoid the need to do all this in each of the tools.
492
- for (var i = 0; i < pageResults.length; ++i) {
493
- // Remove violation which are not in the reportLevels
494
- if (reportLevels) {
495
- var reportLevel = pageResults[i].level;
496
- // Make sure the level is actually defined before trying to perform any action on it
497
- if (reportLevel !== null && typeof reportLevel !== "undefined") {
498
- // Remove the violation from the object if report level is not in the reportLevels array.
499
- if (reportLevels.indexOf(reportLevel) === -1) {
500
- pageResults.splice(i--, 1);
501
- continue;
502
- }
503
- }
504
- else {
505
- // In the case that level is null or not found remove this violation from the results.
506
- pageResults.splice(i--, 1);
507
- }
508
- }
509
- }
510
- return report;
511
- };
512
- ;
513
- ACReportManager.setLevels = function (report) {
514
- // Variable Decleration
515
- var reportLevels = ACReportManager.config.reportLevels;
516
- var pageResults = report.results;
517
- // Loop over all the violations and filter them, if the violation level does not match with, what user has
518
- // requested to be reported. Also handle hidden at this point right now.
519
- // TODO: Posible to filter the results directly in the engine, to avoid the need to do all this in each of the tools.
520
- for (var _i = 0, pageResults_1 = pageResults; _i < pageResults_1.length; _i++) {
521
- var pageResult = pageResults_1[_i];
522
- // Set the default ignore value to false if disableIgnore field in config file is not true
523
- pageResult.ignored = false;
524
- // Remove violation which are not in the reportLevels
525
- if (reportLevels) {
526
- // Fetch the level from the results
527
- var reportValue = pageResult.value;
528
- var reportLevel = void 0;
529
- if (reportValue[1] === "PASS") {
530
- reportLevel = IEngine_1.eRuleLevel.pass;
531
- }
532
- else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") {
533
- reportLevel = IEngine_1.eRuleLevel.manual;
534
- }
535
- else if (reportValue[0] === "VIOLATION") {
536
- if (reportValue[1] === "FAIL") {
537
- reportLevel = IEngine_1.eRuleLevel.violation;
538
- }
539
- else if (reportValue[1] === "POTENTIAL") {
540
- reportLevel = IEngine_1.eRuleLevel.potentialviolation;
541
- }
542
- }
543
- else if (reportValue[0] === "RECOMMENDATION") {
544
- if (reportValue[1] === "FAIL") {
545
- reportLevel = IEngine_1.eRuleLevel.recommendation;
546
- }
547
- else if (reportValue[1] === "POTENTIAL") {
548
- reportLevel = IEngine_1.eRuleLevel.potentialrecommendation;
549
- }
550
- }
551
- pageResult.level = reportLevel;
552
- }
553
- }
554
- return report;
555
- };
556
- /**
557
- * This function is responsible for iterating over all the issue elements and updating the counts object.
558
- *
559
- * @param {Object} pageResults - Provide the page results object, in the following format:
560
- * {
561
- * "report": {
562
- * "numChecked": 227,
563
- * "numTrigger": 1,
564
- * "ruleTime": 5,
565
- * "totalTime": 8,
566
- * "issues": [
567
- * {
568
- * "severityCode": "eISHigh",
569
- * "messageCode": "rpt.g377.elemUniqueId",
570
- * "ruleId": "377",
571
- * "help": "idhi_accessibility_check_g377.html",
572
- * "msgArgs": [
573
- * "div",
574
- * "firstDiv"
575
- * ],
576
- * "xpath": "/html[1]/body[1]/div[2]/div[2]",
577
- * "snippet": "<div id=\"firstDiv\">",
578
- * "bounds": {
579
- * "left": 10,
580
- * "top": 181,
581
- * "height": 0,
582
- * "width": 1249
583
- * },
584
- * "level": "violation"
585
- * }
586
- * ],
587
- * "docTitle": "Helo World"
588
- * },
589
- * "counts": {
590
- * "level.violation": 1,
591
- * "level.potentialviolation": 0,
592
- * "level.recommendation": 0,
593
- * "level.potentialrecommendation": 0,
594
- * "level.manual": 0
595
- * },
596
- * "issueMessages": {
597
- * "messages": {
598
- * "rpt.g377.elemUniqueId": "The {0} element has the id \"{1}\" that is either empty or already in use."
599
- * },
600
- * "lang": "en-us"
601
- * }
602
- * }
603
- * ......
604
- *
605
- * @return {Object} pageResults - return the results object with the count object updated
606
- * {
607
- * "report": {
608
- * "numChecked": 227,
609
- * "numTrigger": 1,
610
- * "ruleTime": 5,
611
- * "totalTime": 8,
612
- * "issues": [
613
- * {
614
- * "severityCode": "eISHigh",
615
- * "messageCode": "rpt.g377.elemUniqueId",
616
- * "ruleId": "377",
617
- * "help": "idhi_accessibility_check_g377.html",
618
- * "msgArgs": [
619
- * "div",
620
- * "firstDiv"
621
- * ],
622
- * "xpath": "/html[1]/body[1]/div[2]/div[2]",
623
- * "snippet": "<div id=\"firstDiv\">",
624
- * "bounds": {
625
- * "left": 10,
626
- * "top": 181,
627
- * "height": 0,
628
- * "width": 1249
629
- * },
630
- * "level": "violation"
631
- * }
632
- * ],
633
- * "docTitle": "Helo World"
634
- * },
635
- * "counts": {
636
- * "level.violation": 1,
637
- * "level.potentialviolation": 0,
638
- * "level.recommendation": 0,
639
- * "level.potentialrecommendation": 0,
640
- * "level.manual": 0
641
- * },
642
- * "issueMessages": {
643
- * "messages": {
644
- * "rpt.g377.elemUniqueId": "The {0} element has the id \"{1}\" that is either empty or already in use."
645
- * },
646
- * "lang": "en-us"
647
- * }
648
- * }
649
- *
650
- * PRIVATE METHOD
651
- *
652
- * @memberOf this
653
- */
654
- ACReportManager.getCounts = function (report) {
655
- // Variable Decleration
656
- var reportLevels = ACReportManager.config.reportLevels;
657
- // Build violation count object which will contain the updated count based on filter which
658
- // which occured in filterViolations function.
659
- var violationCount = {};
660
- // In the case that report levels are provided then populate the count object in
661
- // violationCount object with the levels which were provided in reportLevels
662
- // array/
663
- if (reportLevels) {
664
- // Iterate over the report levels and populate the pageResultsWithCount counts
665
- // object
666
- reportLevels.forEach(function (levels) {
667
- violationCount[levels] = 0;
668
- });
669
- }
670
- // Populate the pageResultsWithCount counts object with all the levels
671
- else {
672
- violationCount = {
673
- "violation": 0,
674
- "potentialviolation": 0,
675
- "recommendation": 0,
676
- "potentialrecommendation": 0,
677
- "manual": 0,
678
- "pass": 0
679
- };
680
- }
681
- // Iterate over the page results
682
- for (var _i = 0, _a = report.results; _i < _a.length; _i++) {
683
- var item = _a[_i];
684
- if (item.level in violationCount) {
685
- ++violationCount[item.level];
686
- }
687
- }
688
- // Update the results count object with the new one which considers filtered results
689
- return violationCount;
690
- };
691
- ;
692
- /**
693
- * This function is responsible for updating/creating the global violation summary for the engine karma run
694
- * for browser that it is running on. Will take the pageCount object which is part of the page object and
695
- * add extract the values for each of the levels and add them to the global object. This will provide an overall
696
- * summary of violations for all testcases run and all scans done.
697
- *
698
- * @param {Object} pageCount - Provide the page count object, in the following format:
699
- *
700
- * @return N/A - Global summary object is updated with the counts
701
- *
702
- * PRIVATE METHOD
703
- *
704
- * @memberOf this
705
- */
706
- ACReportManager.addToSummaryCount = function (pageCount) {
707
- // Variable Decleration
708
- var ACScanSummary = ACReportManager.scanSummary.counts || {};
709
- var addedToSummary = false;
710
- // In the case ACScanSummary is empty, simply assign pageCount to ACScanSummary
711
- if (Object.keys(ACScanSummary).length === 0) {
712
- // Set pageCount as the summary count
713
- ACScanSummary = pageCount;
714
- addedToSummary = true;
715
- }
716
- // In the case that this is not first scan, handle adding up the summary
717
- if (!addedToSummary) {
718
- // Go through the pageCount object and for each of the levels, extract the value
719
- // and add it to the accessibility-checker violation summary object.
720
- // This will keep track of an overall summary of the violations for all testscases, that
721
- // were run for a single karma run.
722
- for (var level in pageCount) {
723
- ACScanSummary[level] += pageCount[level];
724
- }
725
- }
726
- // Assign the new violation summary back to the global object
727
- ACReportManager.scanSummary.counts = ACScanSummary;
728
- };
729
- ;
730
- /**
731
- * This function is responsible for comparing the scan results with baseline or checking that there are
732
- * no violations which fall into the failsLevels levels. In the case a baseline is found then baseline will
733
- * be used to perform the check, in the case no baseline is provided then we comply with only failing if
734
- * there is a sinble violation which falls into failLevels.
735
- *
736
- * @param {Object} actual - the actual results object provided by the user, this object should follow the
737
- * same format as outlined in the return of aChecker.buildReport function.
738
- *
739
- * @return {int} - return 0 in the case actual matches baseline or no violations fall into failsLevels,
740
- * return 1 in the case actual results does not match baseline results,
741
- * return 2 in the case that there is a failure based on failLevels (this means no baseline found).
742
- * return -1 in the case that there is an exception that occured in the results object which came from the scan engine.
743
- *
744
- * PUBLIC API
745
- *
746
- * @memberOf this
747
- */
748
- ACReportManager.assertCompliance = function (actualResults) {
749
- // In the case that the details object contains Error object, this means that the scan engine through an
750
- // exception, therefore we should not compare results just fail instead.
751
- if (actualResults.details instanceof Error) {
752
- return IChecker_1.eAssertResult.ERROR;
753
- }
754
- actualResults = actualResults;
755
- // Get the label directly from the results object, the same label has to match
756
- // the baseline object which is available in the global space.
757
- var label = actualResults.label;
758
- // Fetch the baseline object based on the label provided
759
- var expected = ACReportManager.getBaseline(label);
760
- // In the case there are no baseline found then run a different assertion algo,
761
- // when there is baseline compare the baselines in the case there is no baseline then
762
- // check to make sure there are no violations that are listed in the fails on.
763
- if (expected !== null && typeof (expected) !== "undefined") {
764
- // Run the diff algo to get the list of differences
765
- var differences = ACReportManager.diffResultsWithExpected(actualResults, expected, true);
766
- // console.log("difference=" + JSON.stringify(differences, null, ' '));
767
- // In the case that there are no differences then that means it passed
768
- if (differences === null || typeof (differences) === "undefined") {
769
- return IChecker_1.eAssertResult.PASS;
770
- }
771
- else {
772
- // Re-sort results and check again
773
- var modActual = JSON.parse(JSON.stringify(actualResults.results));
774
- modActual.sort(function (a, b) {
775
- var cc = b.category.localeCompare(a.category);
776
- if (cc !== 0)
777
- return cc;
778
- var pc = b.path.dom.localeCompare(a.path.dom);
779
- if (pc !== 0)
780
- return pc;
781
- return b.ruleId.localeCompare(a.ruleId);
782
- });
783
- var modExpected = JSON.parse(JSON.stringify(expected.results));
784
- modExpected.sort(function (a, b) {
785
- var cc = b.category.localeCompare(a.category);
786
- if (cc != 0)
787
- return cc;
788
- var pc = b.path.dom.localeCompare(a.path.dom);
789
- if (pc !== 0)
790
- return pc;
791
- return b.ruleId.localeCompare(a.ruleId);
792
- });
793
- var differences2 = ACReportManager.diffResultsWithExpected({
794
- results: modActual,
795
- summary: actualResults.summary
796
- }, {
797
- results: modExpected,
798
- summary: expected.summary
799
- }, true);
800
- if (differences2 === null || typeof (differences2) === "undefined") {
801
- return IChecker_1.eAssertResult.PASS;
802
- }
803
- else {
804
- // In the case that there are failures add the whole diff array to
805
- // global space indexed by the label so that user can access it.
806
- ACReportManager.diffResults[label] = differences;
807
- return IChecker_1.eAssertResult.BASELINE_MISMATCH;
808
- }
809
- }
810
- }
811
- else {
812
- // In the case that there was no baseline data found compare the results based on
813
- // the failLevels array, which was defined by the user.
814
- var returnCode = ACReportManager.compareBasedOnFailLevels(actualResults);
815
- // In the case there are no violations that match the fail on then return as success
816
- if (returnCode === 0) {
817
- return IChecker_1.eAssertResult.PASS;
818
- }
819
- else {
820
- // In the case there are some violation that match in the fail on then return 2
821
- // to identify that there was a failure, and we used a 2nd method for compare.
822
- return IChecker_1.eAssertResult.FAIL;
823
- }
824
- }
825
- };
826
- ;
827
- /**
828
- * This function is responsible for checking if any of the issues reported have any level that falls
829
- * into the failsLevel array.
830
- *
831
- * @param {Object} results - Provide the scan results, object which would be in the
832
- * the same format as outlined in the return of aChecker.buildReport function.
833
- *
834
- * @return {int} - return 1 in the case a single issue was found which is in the failsLevel array.
835
- * return -1 in the case that there is an exception that occured in the results object which came from the scan engine.
836
- *
837
- * PRIVATE METHOD
838
- *
839
- * @memberOf this
840
- */
841
- ACReportManager.compareBasedOnFailLevels = function (report) {
842
- // In the case that the details object contains Error object, this means that the scan engine through an
843
- // exception, therefore we should not compare results just fail instead.
844
- if (report.details instanceof Error) {
845
- return -1;
846
- }
847
- // Variable Decleration
848
- var failLevels = ACReportManager.config.failLevels;
849
- // Loop over all the issues to check for any level that is in failLevels
850
- // console.log(report);
851
- for (var _i = 0, _a = report.results; _i < _a.length; _i++) {
852
- var issue = _a[_i];
853
- // In the case current level is in the failsLevel array them fail, with out checking further
854
- // currently we are not saving exactly which results failed, as all the issues are going to be saved to
855
- // results file.
856
- if (failLevels.indexOf(issue.level) > -1) {
857
- // return 1 as there was a fialure
858
- return 1;
859
- }
860
- }
861
- // return 0 as there were no levels that fall into the failLevels
862
- return 0;
863
- };
864
- ;
865
- /**
866
- * This function is responsible for comparing actual with expected and returning all the differences as an array.
867
- *
868
- * @param {Object} actual - Provide the actual object to be used for compare
869
- * @param {Object} expected - Provide the expected object to be used for compare
870
- * @param {boolean} clean - Provide a boolean if both the actual and expected objects need to be cleaned
871
- * cleaning refers to converting the objects to match with a basic compliance
872
- * compare of xpath and ruleId.
873
- *
874
- * @return {Object} differences - return an array of diff objects that were found, following is the format of the object:
875
- * [
876
- * {
877
- * "kind": "E",
878
- * "path": [
879
- * "reports",
880
- * 0,
881
- * "issues",
882
- * 10,
883
- * "xpath"
884
- * ],
885
- * "lhs": "/html[1]/body[1]/div[2]/table[5]",
886
- * "rhs": "/html[1]/body[1]/div[2]/table[5]d",
887
- * },
888
- * {
889
- * "kind": "E",
890
- * "path": [
891
- * "label"
892
- * ],
893
- * "lhs": "Table-layoutMultiple",
894
- * "rhs": "dependencies/tools-rules-html/v2/a11y/test/g471/Table-layoutMultiple.html",
895
- * }
896
- * ]
897
- *
898
- * PUBLIC API
899
- *
900
- * @memberOf this
901
- */
902
- ACReportManager.diffResultsWithExpected = function (actual, expected, clean) {
903
- // In the case clean is set to true then run the cleanComplianceObjectBeforeCompare function on
904
- // both the actual and expected objects passed in. This is to make sure that the objcet follow a
905
- // simalar structure before compareing the objects.
906
- if (clean) {
907
- // Clean actual and expected objects
908
- actual = ACReportManager.cleanComplianceObjectBeforeCompare(actual);
909
- expected = ACReportManager.cleanComplianceObjectBeforeCompare(expected);
910
- }
911
- // Run Deep diff function to compare the actual and expected values.
912
- var differences = DeepDiff.diff(actual, expected);
913
- if (differences) {
914
- differences = differences.filter(function (difference) { return !(difference.kind === "E"
915
- && difference.path.length === 4
916
- && difference.path[2] === "bounds"
917
- && Math.abs(difference.lhs - difference.rhs) <= 1); });
918
- if (differences.length === 0)
919
- return undefined;
920
- }
921
- // Return the results of the diff, which will include the differences between the objects
922
- return differences;
923
- };
924
- ;
925
- /**
926
- * This function is responsible for cleaning up the compliance baseline or actual results, based on
927
- * a pre-defined set of criterias, such as the following:
928
- * 1. No need to compare summary object
929
- * 2. Only need to compare the ruleId and xpath in for each of the issues
930
- *
931
- * @param {Object} objectToClean - Provide either an baseline or actual results object which would be in the
932
- * the same format as outlined in the return of aChecker.buildReport function.
933
- *
934
- * @return {Object} objectToClean - return an object that was cleaned to only contain the information that is
935
- * needed for compare. Following is a sample of how the cleaned object will look like:
936
- * {
937
- * "label": "unitTestContent",
938
- * "reports": [
939
- * {
940
- * "frameIdx": "0",
941
- * "frameTitle": "Frame 0",
942
- * "issues": [
943
- * {
944
- * "ruleId": "1",
945
- * "xpath": "/html[1]/head[1]/style[1]"
946
- * }
947
- * ....
948
- * ]
949
- * },
950
- * {
951
- * "frameIdx": "1",
952
- * "frameTitle": "Frame 1",
953
- * "issues": [
954
- * {
955
- * "ruleId": "471",
956
- * "xpath": "/html[1]/body[1]/div[2]/table[3]"
957
- * }
958
- * ....
959
- * ]
960
- * }
961
- * ]
962
- * }
963
- *
964
- * PRIVATE METHOD
965
- *
966
- * @memberOf this
967
- */
968
- ACReportManager.cleanComplianceObjectBeforeCompare = function (objectToClean) {
969
- // Clone the object so that we do not reference the original or else it causes the original
970
- // results object or baseline object to get updated, which we do not want as users are allowed
971
- // access to the raw results object and baseline object.
972
- // Convert the object into string and then parse it as a JSON object which will lose its reference
973
- objectToClean = JSON.parse(JSON.stringify(objectToClean));
974
- // Remove the summary object, scanID, toolID, issueMessage
975
- delete objectToClean.summary;
976
- delete objectToClean.nls;
977
- delete objectToClean.scanID;
978
- delete objectToClean.toolID;
979
- delete objectToClean.issueMessages;
980
- delete objectToClean.numExecuted;
981
- var _loop_1 = function (idx) {
982
- var issue = objectToClean.results[idx];
983
- if (issue.level === "pass") {
984
- objectToClean.results.splice(idx--, 1);
985
- }
986
- else {
987
- issue.xpath = issue.path.dom;
988
- // Loop over all the keys in a single issue object and remove all the
989
- // keys that are not needed for compare
990
- Object.keys(issue).forEach(function (key) {
991
- // Remove all the keys which are not in the baselineIssueList
992
- if (ACReportManager.baselineIssueList.indexOf(key) === -1) {
993
- delete issue[key];
994
- }
995
- });
996
- // Make sure that the xpath in the case there is a [1] we replace it with ""
997
- // to support some browser which return it differently
998
- issue.xpath = issue.xpath.replace(/\[1\]/g, "");
999
- }
1000
- out_idx_1 = idx;
1001
- };
1002
- var out_idx_1;
1003
- // Loop over all the issues and remove the keys that are not needed for the compare
1004
- // Only leave the ruleId and xpath keys for compare.
1005
- for (var idx = 0; idx < objectToClean.results.length; ++idx) {
1006
- _loop_1(idx);
1007
- idx = out_idx_1;
1008
- }
1009
- ;
1010
- return objectToClean;
1011
- };
1012
- ;
1013
- /**
1014
- * This function is responsible for getting the baseline object for a label that was provided.
1015
- *
1016
- * @param {String} label - Provide a lable for which to get the baseline for.
1017
- *
1018
- * @return {Object} - return the baseline object from global space based on label provided, the object will be
1019
- * in the same format as outlined in the return of aChecker.buildReport function.
1020
- *
1021
- * PUBLIC API
1022
- *
1023
- * @memberOf this
1024
- */
1025
- ACReportManager.getBaseline = function (label) {
1026
- try {
1027
- var retVal = require(path.join(path.join(process.cwd(), ACReportManager.config.baselineFolder), label));
1028
- if (retVal && retVal.results) {
1029
- if (!this.refactorMap) {
1030
- this.refactorMap = {};
1031
- var rules = ACEngineManager_1.ACEngineManager.getRulesSync();
1032
- for (var _i = 0, rules_1 = rules; _i < rules_1.length; _i++) {
1033
- var rule = rules_1[_i];
1034
- if (rule.refactor) {
1035
- for (var key in rule.refactor) {
1036
- this.refactorMap[key] = rule;
1037
- }
1038
- }
1039
- }
1040
- }
1041
- for (var _a = 0, _b = retVal.results; _a < _b.length; _a++) {
1042
- var result = _b[_a];
1043
- if (result.ruleId in this.refactorMap) {
1044
- var mapping = this.refactorMap[result.ruleId].refactor[result.ruleId];
1045
- result.ruleId = this.refactorMap[result.ruleId].id;
1046
- result.reasonId = mapping[result.reasonId];
1047
- }
1048
- }
1049
- }
1050
- return retVal;
1051
- }
1052
- catch (e) {
1053
- // console.error("getBaseline Error:", e);
1054
- return null;
1055
- }
1056
- };
1057
- ;
1058
- /**
1059
- * This function is responsible for getting the diff results based on label for a scan that was already performed.
1060
- *
1061
- * @param {String} label - Provide a lable for which to get the diff results for.
1062
- *
1063
- * @return {Object} - return the diff results object from global space based on label provided, the object will be
1064
- * in the same format as outlined in the return of aChecker.diffResultsWithExpected function.
1065
- *
1066
- * PUBLIC API
1067
- *
1068
- * @memberOf this
1069
- */
1070
- ACReportManager.getDiffResults = function (label) {
1071
- return ACReportManager.diffResults && ACReportManager.diffResults[label];
1072
- };
1073
- ;
1074
- /**
1075
- * This function is responsible for printing the scan results to console.
1076
- *
1077
- * @param {Object} results - Provide the results from the scan.
1078
- *
1079
- * @return {String} resultsString - String representation of the results/violations.
1080
- *
1081
- * PUBLIC API
1082
- *
1083
- * @memberOf this
1084
- */
1085
- ACReportManager.stringifyResults = function (reportP) {
1086
- if (!reportP.results) {
1087
- return "ERROR: ".concat(JSON.stringify(reportP));
1088
- }
1089
- var report = reportP;
1090
- // console.log(report);
1091
- // Variable Decleration
1092
- var resultsString = "Scan: ".concat(report.label, "\n");
1093
- // Loop over the reports and build the string version of the the issues within each report
1094
- report.results && report.results.forEach(function (issue) {
1095
- if (ACReportManager.config.reportLevels.includes(issue.level)) {
1096
- // Build string of the issues with only level, messageCode, xpath and snippet.
1097
- resultsString += "- Message: " + issue.message +
1098
- "\n Level: " + issue.level +
1099
- "\n XPath: " + issue.path.dom +
1100
- "\n Snippet: " + issue.snippet +
1101
- "\n Help: " + ACEngineManager_1.ACEngineManager.getHelpURL(issue) +
1102
- "\n";
1103
- }
1104
- });
1105
- return resultsString;
1106
- };
1107
- ;
1108
- ACReportManager.ignoreExtraBaselineViolations = function (actualReport, baselineReport) {
1109
- // Using for loop to make is sync code
1110
- var ignoredCount = 0;
1111
- var changedCounts = actualReport.summary.counts;
1112
- var currentActualReport = actualReport.results;
1113
- var currentBaselineReport = baselineReport;
1114
- // a report exists in the baseline for the iframe
1115
- var legacyBaseline = false;
1116
- if (currentBaselineReport && currentBaselineReport.length === 1) {
1117
- legacyBaseline = !!currentBaselineReport[0].issues;
1118
- }
1119
- var _loop_2 = function (issue) {
1120
- var currentRuleID = issue.ruleId;
1121
- var currentLevel = issue.level;
1122
- var currentXPATH = issue.path.dom;
1123
- //check if the issue exists in baseline already
1124
- var result = legacyBaseline && currentBaselineReport[0].issues.filter(function (issue) { return issue.ruleId in __1.ruleIdToLegacyId && __1.ruleIdToLegacyId[issue.ruleId] === currentRuleID && issue.level === currentLevel && issue.xpath === currentXPATH; })
1125
- || !legacyBaseline && currentBaselineReport.results.filter(function (issue) { return issue.ruleId === currentRuleID && issue.level === currentLevel && issue.path.dom === currentXPATH; });
1126
- if (result && result.length !== 0) {
1127
- //violation exists in baseline, add ignore:true
1128
- issue.ignored = true;
1129
- ignoredCount++;
1130
- if (issue.level === "violation") {
1131
- changedCounts.violation--;
1132
- }
1133
- if (issue.level === "potentialviolation") {
1134
- changedCounts.potentialviolation--;
1135
- }
1136
- if (issue.level === "recommendation") {
1137
- changedCounts.recommendation--;
1138
- }
1139
- if (issue.level === "potentialrecommendation") {
1140
- changedCounts.potentialrecommendation--;
1141
- }
1142
- if (issue.level === "manual") {
1143
- changedCounts.manual--;
1144
- }
1145
- if (issue.level === "pass") {
1146
- changedCounts.pass--;
1147
- }
1148
- }
1149
- else {
1150
- issue.ignored = false;
1151
- }
1152
- };
1153
- for (var _i = 0, currentActualReport_1 = currentActualReport; _i < currentActualReport_1.length; _i++) {
1154
- var issue = currentActualReport_1[_i];
1155
- _loop_2(issue);
1156
- }
1157
- // adding ignore count to summary
1158
- changedCounts.ignored = ignoredCount;
1159
- actualReport.summary.counts = changedCounts;
1160
- return actualReport;
1161
- };
1162
- // Array that contains the list of entries that need to be compared between the actual and baseline objects only.
1163
- // Note: This is used by the cleanComplianceObjectBeforeCompare function to filter the report based on this.
1164
- ACReportManager.baselineIssueList = ["ruleId", "xpath"];
1165
- /**
1166
- * This function is responsible for indexing the results into global spaces based on label.
1167
- *
1168
- * @param {Object} results - Results object which will be provided to the user/wroten to the file.
1169
- * Refer to aChecker.buildReport function's return to figure out what the object
1170
- * will look like.
1171
- *
1172
- * @return - N/A - Global object is updated with the results
1173
- *
1174
- * PRIVATE METHOD
1175
- *
1176
- * @memberOf this
1177
- */
1178
- ACReportManager.addResultsToGlobal = function (results) {
1179
- // Build the single page summary object to follow the following format:
1180
- // "label": "dependencies/tools-rules-html/v2/a11y/test/g471/Table-DataNoSummaryARIA.html",
1181
- // "counts": {
1182
- // "violation": 1,
1183
- // "potentialviolation": 0,
1184
- // "recommendation": 0,
1185
- // "potentialrecommendation": 0,
1186
- // "manual": 0
1187
- // }
1188
- var pageSummaryObject = {
1189
- label: results.label,
1190
- counts: results.summary.counts
1191
- };
1192
- // Add the summary count for this scan to the pageScanSummary object which is in the global space
1193
- // Index this by the label.
1194
- ACReportManager.scanSummary.pageScanSummary.push(pageSummaryObject);
1195
- // Add the scan results to global space
1196
- ACReportManager.scanResults[results.label] = results;
1197
- };
1198
- return ACReportManager;
1199
- }());
1200
- exports.ACReportManager = ACReportManager;
1201
- //# sourceMappingURL=ACReportManager.js.map