testaro 62.0.3 → 62.1.0

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.
package/aceconfig.js CHANGED
@@ -22,5 +22,6 @@ module.exports = {
22
22
  'recommendation'
23
23
  ],
24
24
  cacheFolder: tmpDir,
25
- outputFolder: tmpDir
25
+ outputFolder: tmpDir,
26
+ puppeteerArgs: ['--no-sandbox', '--disable-setuid-sandbox']
26
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "62.0.3",
3
+ "version": "62.1.0",
4
4
  "description": "Run 1000 web accessibility tests from 11 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/testaro/hovInd.js CHANGED
@@ -123,7 +123,7 @@ exports.reporter = async (page, withItems, sampleSize = 20) => {
123
123
  // Get a sample of the triggers.
124
124
  const sampleIndexes = getSample(locsAll, sampleSize);
125
125
  const sample = locsAll.filter((loc, index) => sampleIndexes.includes(index));
126
- // For each trigger in the sample:
126
+ // For each trigger:
127
127
  for (const loc of sample) {
128
128
  try {
129
129
  // Get its style properties.
@@ -135,7 +135,7 @@ exports.reporter = async (page, withItems, sampleSize = 20) => {
135
135
  // Blur it.
136
136
  await loc.blur({timeout: 500});
137
137
  // If blurring succeeds, try to hover over it.
138
- await loc.hover({timeout: 500});
138
+ await loc.hover({timeout: 600});
139
139
  // If hovering succeeds, get its style properties.
140
140
  const hovStyles = await getHoverStyles(loc);
141
141
  // If all 3 style declarations belong to the same element:
package/testaro/hover.js CHANGED
@@ -17,6 +17,8 @@
17
17
 
18
18
  // Module to perform common operations.
19
19
  const {getBasicResult, getVisibleCountChange} = require('../procs/testaro');
20
+ // Module to perform Playwright operations.
21
+ const playwright = require('playwright');
20
22
 
21
23
  // FUNCTIONS
22
24
 
@@ -47,7 +49,9 @@ exports.reporter = async (page, withItems) => {
47
49
  ].join(', '));
48
50
  const allLocs = await candidateLocs.all();
49
51
  const violations = [];
50
- const data = {};
52
+ const data = {
53
+ hoverableCount: allLocs.length
54
+ };
51
55
  // For each locator:
52
56
  for (const loc of allLocs) {
53
57
  // Get the XPath of the element referenced by the locator.
@@ -63,7 +67,7 @@ exports.reporter = async (page, withItems) => {
63
67
  // Get a locator for the observation root.
64
68
  const rootLoc = page.locator(`xpath=${xPath}`);
65
69
  const loc0 = await rootLoc.locator('*:visible');
66
- // Get a count of the visible elements in the observation tree.
70
+ // Get a pre-hover count of the visible elements in the observation tree.
67
71
  const elementCount0 = await loc0.count();
68
72
  try {
69
73
  // Hover over the element.
@@ -86,9 +90,14 @@ exports.reporter = async (page, withItems) => {
86
90
  }
87
91
  // If hovering throws an error:
88
92
  catch(error) {
89
- // Report that the test was prevented.
93
+ // If the error is a timeout:
94
+ if (error instanceof playwright.errors.TimeoutError) {
95
+ // Skip the locator.
96
+ continue;
97
+ }
98
+ // Otherwise, i.e. if the error is not a timeout, report this and quit.
90
99
  data.prevented = true;
91
- data.error = `ERROR hovering over an element (${error.message})`;
100
+ data.error = `ERROR hovering over an element (${error.message.slice(0, 200)})`;
92
101
  break;
93
102
  }
94
103
  }
package/tests/ibm.js CHANGED
@@ -22,7 +22,6 @@
22
22
 
23
23
  // IMPORTS
24
24
 
25
- const fs = require('fs').promises;
26
25
  // Scanner. Importing and executing 'close' crashed the Node process.
27
26
  const accessibilityChecker = require('accessibility-checker');
28
27
  const {getCompliance} = accessibilityChecker;
@@ -30,7 +29,7 @@ const {getCompliance} = accessibilityChecker;
30
29
  // FUNCTIONS
31
30
 
32
31
  // Runs the IBM test and returns the result.
33
- const run = async (content, timeLimit) => {
32
+ const run = async content => {
34
33
  const nowLabel = (new Date()).toISOString().slice(0, 19);
35
34
  try {
36
35
  const ibmReport = await getCompliance(content, nowLabel);
@@ -66,13 +65,13 @@ const limitRuleTotals = (actReport, rules) => {
66
65
  }
67
66
  };
68
67
  // Trims an IBM report.
69
- const trimActReport = (data, actReport, withItems, rules) => {
68
+ const trimActReport = (actReport, withItems, rules) => {
70
69
  // If the act report includes a summary:
71
70
  if (actReport && actReport.summary) {
72
71
  // Remove excluded rules from the act report.
73
72
  limitRuleTotals(actReport, rules);
74
- // If the act report includes totals:
75
73
  const totals = actReport.summary.counts;
74
+ // If the act report includes totals:
76
75
  if (totals) {
77
76
  // If itemization is required:
78
77
  if (withItems) {
@@ -101,115 +100,67 @@ const trimActReport = (data, actReport, withItems, rules) => {
101
100
  }
102
101
  // Otherwise, i.e. if it excludes totals:
103
102
  else {
104
- // Report this.
105
- const error = 'ERROR: No totals reported';
106
- console.log(error);
107
- data.prevented = true;
108
- data.error = error;
109
- // Return an empty act report.
103
+ // Return an act report with this error.
110
104
  return {
111
- totals: {},
112
- items: []
105
+ totals: null,
106
+ items: [],
107
+ error: 'No totals reported'
113
108
  };
114
109
  }
115
110
  }
116
111
  // Otherwise, i.e. if it excludes a summary:
117
112
  else {
118
- // Report this.
119
- const error = 'ERROR: No summary reported';
120
- console.log(error);
121
- data.prevented = true;
122
- data.error = error;
123
- // Return an empty act report.
113
+ // Return an act report with this error.
124
114
  return {
125
- totals: {},
126
- items: []
127
- };
128
- }
129
- };
130
- // Performs the IBM tests and returns an act report.
131
- const doTest = async (content, withItems, timeLimit, rules) => {
132
- // Conduct the tests.
133
- const data = {};
134
- try {
135
- const runReport = await run(content, timeLimit);
136
- // If there were results:
137
- if (runReport.report) {
138
- // Return a trimmed act report.
139
- const {report} = runReport;
140
- const trimmedReport = trimActReport(data, report, withItems, rules);
141
- return {
142
- data,
143
- result: trimmedReport
144
- };
145
- }
146
- // Otherwise, i.e. if there were no results:
147
- else {
148
- // Return this.
149
- return {
150
- data: runReport,
151
- result: {}
152
- }
153
- }
154
- }
155
- catch(error) {
156
- const message = `Act failed (${error.message.slice(0, 200)})`;
157
- console.log(message);
158
- data.prevented = true;
159
- data.error = message;
160
- return {
161
- data,
162
- result: {}
115
+ totals: null,
116
+ items: [],
117
+ error: 'No summary reported'
163
118
  };
164
119
  }
165
120
  };
166
121
  // Conducts and reports the IBM Equal Access tests.
167
- exports.reporter = async (page, report, actIndex, timeLimit) => {
122
+ exports.reporter = async (page, report, actIndex) => {
168
123
  const act = report.acts[actIndex];
169
124
  const {withItems, withNewContent, rules} = act;
170
125
  const contentType = withNewContent ? 'new' : 'existing';
171
126
  try {
172
127
  const typeContent = contentType === 'existing' ? await page.content() : page.url();
173
- // Perform the tests.
174
- const actReport = await doTest(typeContent, withItems, timeLimit, rules);
175
- // If the testing was finished on time:
176
- if (actReport !== 'timedOut') {
177
- const {data, result} = actReport;
178
- // If the act was prevented:
179
- if (data && data.prevented) {
180
- // Report this.
181
- const message = 'ERROR: Act was prevented';
182
- data.error ??= message;
183
- // Return the failure.
128
+ // Conduct the tests.
129
+ const runReport = await run(typeContent);
130
+ const {report} = runReport;
131
+ // If there were results:
132
+ if (report) {
133
+ // Trim them.
134
+ const trimmedReport = trimActReport(report, withItems, rules);
135
+ const {error} = trimmedReport;
136
+ // If the report was not trimmable:
137
+ if (error) {
138
+ // Return an act report with this error.
184
139
  return {
185
- data,
140
+ data: {
141
+ prevented: true,
142
+ error
143
+ },
186
144
  result: {}
187
- };
188
- }
189
- // Otherwise, i.e. if the act was not prevented:
190
- else {
191
- // Return the result.
192
- return {
193
- data,
194
- result
195
- };
145
+ }
196
146
  }
197
- }
198
- // Otherwise, i.e. if the testing timed out:
199
- else {
200
- // Report this.
147
+ // Otherwise, i.e. if the report was trimmable, return it.
201
148
  return {
202
- data: {
203
- prevented: true,
204
- error: message
205
- },
206
- result: {}
149
+ data: {},
150
+ result: trimmedReport
207
151
  };
208
152
  }
153
+ // Otherwise, i.e. if there was only an error, return it in an act report.
154
+ return {
155
+ data: runReport,
156
+ result: {}
157
+ }
209
158
  }
159
+ // If an error occurred:
210
160
  catch(error) {
211
- const message = `Act crashed (${error.message.slice(0, 200)})`;
212
- console.log(`ERROR: ${message}`);
161
+ const message = `Act failed (${error.message.slice(0, 200)})`;
162
+ console.log(message);
163
+ // Return it in an act report.
213
164
  return {
214
165
  data: {
215
166
  prevented: true,
package/tests/qualWeb.js CHANGED
@@ -42,9 +42,24 @@ exports.reporter = async (page, report, actIndex, timeLimit) => {
42
42
  timeout: timeLimit * 1000,
43
43
  monitor: false
44
44
  };
45
+ try {
45
46
  // Start the QualWeb core engine.
46
- await qualWeb.start(clusterOptions, {headless: true});
47
- // Specify the invariant test options.
47
+ await qualWeb.start(clusterOptions, {
48
+ headless: true,
49
+ args: ['--no-sandbox', '--disable-setuid-sandbox']
50
+ });
51
+ }
52
+ // If the start fails:
53
+ catch(error) {
54
+ return {
55
+ data: {
56
+ prevented: true,
57
+ error: `Core engine start failed (${error.message})`
58
+ },
59
+ result
60
+ };
61
+ }
62
+ // Otherwise, i.e. if the start succeeds, specify the invariant test options.
48
63
  const qualWebOptions = {
49
64
  log: {
50
65
  console: false,
@@ -128,9 +143,22 @@ exports.reporter = async (page, report, actIndex, timeLimit) => {
128
143
  qualWebOptions.modules.push(bpModule);
129
144
  qualWebOptions.execute.bp = true;
130
145
  }
131
- // Get the report.
132
- let actReports = await qualWeb.evaluate(qualWebOptions);
133
- result = actReports[withNewContent ? qualWebOptions.url : 'customHtml'];
146
+ let qwReport;
147
+ try {
148
+ // Get the report.
149
+ qwReport = await qualWeb.evaluate(qualWebOptions);
150
+ }
151
+ catch(error) {
152
+ return {
153
+ data: {
154
+ prevented: true,
155
+ error: `qualWeb evaluation failed (${error.message})`
156
+ },
157
+ result
158
+ };
159
+ }
160
+ // Otherwise, i.e. if the evaluation succeeded, get the report.
161
+ result = qwReport[withNewContent ? qualWebOptions.url : 'customHtml'];
134
162
  // If it contains a copy of the DOM:
135
163
  if (result && result.system && result.system.page && result.system.page.dom) {
136
164
  // Delete the copy.
@@ -184,24 +212,24 @@ exports.reporter = async (page, report, actIndex, timeLimit) => {
184
212
  }
185
213
  else {
186
214
  data.prevented = true;
187
- data.error = 'ERROR: No assertions';
215
+ data.error = 'No assertions';
188
216
  }
189
217
  }
190
218
  else {
191
219
  data.prevented = true;
192
- data.error = `ERROR: No ${section} section`;
220
+ data.error = `No ${section} section`;
193
221
  }
194
222
  }
195
223
  }
196
224
  }
197
225
  else {
198
226
  data.prevented = true;
199
- data.error = 'ERROR: No modules';
227
+ data.error = 'No modules';
200
228
  }
201
229
  }
202
230
  else {
203
231
  data.prevented = true;
204
- data.error = 'ERROR: No DOM';
232
+ data.error = 'No DOM';
205
233
  }
206
234
  // Stop the QualWeb core engine.
207
235
  await qualWeb.stop();
@@ -210,20 +238,14 @@ exports.reporter = async (page, report, actIndex, timeLimit) => {
210
238
  JSON.stringify(result);
211
239
  }
212
240
  catch(error) {
213
- const message = `ERROR: qualWeb result cannot be made JSON (${error.message})`;
214
241
  data.prevented = true;
215
- data.error = message;
216
- };
242
+ data.error = `qualWeb result cannot be made JSON (${error.message})`;
243
+ }
217
244
  }
218
245
  catch(error) {
219
- const message = error.message.slice(0, 200);
220
246
  data.prevented = true;
221
- data.error = message;
222
- result = {
223
- prevented: true,
224
- error: message
225
- };
226
- };
247
+ data.error = `qualWeb evaluation failed (${error.message})`;
248
+ }
227
249
  return {
228
250
  data,
229
251
  result