accessibility-checker 3.1.0 → 3.1.4

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