testaro 5.6.3 → 5.6.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "5.6.3",
3
+ "version": "5.6.4",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -2,7 +2,7 @@
2
2
  "id": "tp12",
3
3
  "what": "Alfa, Axe, Continuum, HTML CodeSniffer, IBM, Tenon, WAVE, and 16 custom tests",
4
4
  "strict": true,
5
- "timeLimit": 300,
5
+ "timeLimit": 400,
6
6
  "commands": [
7
7
  {
8
8
  "type": "launch",
package/tests/role.js CHANGED
@@ -2,15 +2,19 @@
2
2
  role
3
3
  This test reports role assignment that violate either an applicable standard or an applicable
4
4
  recommendation from WAI-ARIA. Invalid roles include those that are abstract and thus prohibited
5
- from direct use, and those that are implicit in HTML elements and thus advised against. The math
6
- role has been removed, because of poor adoption and exclusion from HTML5. The img role has
7
- accessibility uses, so is not classified as deprecated. See:
5
+ from direct use, and those that are implicit in HTML elements and thus advised against. Roles
6
+ that explicitly confirm implicit roles are deemed redundant and can be scored as less serious
7
+ than roles that override implicit roles. The math role has been removed, because of poor
8
+ adoption and exclusion from HTML5. The img role has accessibility uses, so is not classified
9
+ as deprecated. See:
8
10
  https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Role_Img
9
11
  https://www.w3.org/TR/html-aria/
10
12
  https://www.w3.org/TR/wai-aria/#roles_categorization
11
13
  */
12
14
  exports.reporter = async page => await page.$eval('body', body => {
15
+
13
16
  // CONSTANTS
17
+
14
18
  const badRoles = new Set([
15
19
  'article',
16
20
  'banner',
@@ -354,7 +358,32 @@ exports.reporter = async page => await page.$eval('body', body => {
354
358
  };
355
359
  // Array of th and td elements with redundant roles.
356
360
  const redundantCells = [];
361
+ // Elements with role attributes.
362
+ const roleElements = Array.from(body.querySelectorAll('[role]'));
363
+ // th and td elements with redundant roles.
364
+ const gridHeaders = Array.from(
365
+ document.body.querySelectorAll('table[role=grid] th, table[role=treegrid] th')
366
+ );
367
+ const gridCells = Array.from(
368
+ document.body.querySelectorAll('table[role=grid] td, table[role=treegrid] td')
369
+ );
370
+ const tableHeaders = Array.from(
371
+ document.body.querySelectorAll('table[role=table] th, table:not([role]) th')
372
+ );
373
+ const tableCells = Array.from(
374
+ document.body.querySelectorAll('table[role=table] td, table:not([role]) td')
375
+ );
376
+ // Initialized result.
377
+ const data = {
378
+ roleElements: roleElements.length,
379
+ badRoleElements: 0,
380
+ redundantRoleElements: 0,
381
+ tagNames: {}
382
+ };
383
+
357
384
  // FUNCTIONS
385
+
386
+ // Initializes the results.
358
387
  const dataInit = (data, tagName, role) => {
359
388
  if (! data.tagNames[tagName]) {
360
389
  data.tagNames[tagName] = {};
@@ -366,6 +395,7 @@ exports.reporter = async page => await page.$eval('body', body => {
366
395
  };
367
396
  }
368
397
  };
398
+ //
369
399
  const tallyTableRedundancy = (elements, okRoles, tagName) => {
370
400
  elements.forEach(element => {
371
401
  const role = element.getAttribute('role');
@@ -377,35 +407,16 @@ exports.reporter = async page => await page.$eval('body', body => {
377
407
  }
378
408
  });
379
409
  };
410
+
380
411
  // OPERATION
412
+
381
413
  // Remove the deprecated roles from the non-abstract roles.
382
414
  goodRoles.forEach(role => {
383
415
  if (badRoles.has(role)) {
384
416
  goodRoles.delete(role);
385
417
  }
386
418
  });
387
- // Identify all elements with role attributes.
388
- const roleElements = Array.from(body.querySelectorAll('[role]'));
389
- // Initialize the result.
390
- const data = {
391
- roleElements: roleElements.length,
392
- badRoleElements: 0,
393
- redundantRoleElements: 0,
394
- tagNames: {}
395
- };
396
- // Identify the th and td elements with redundant roles.
397
- const gridHeaders = Array.from(
398
- document.body.querySelectorAll('table[role=grid] th, table[role=treegrid] th')
399
- );
400
- const gridCells = Array.from(
401
- document.body.querySelectorAll('table[role=grid] td, table[role=treegrid] td')
402
- );
403
- const tableHeaders = Array.from(
404
- document.body.querySelectorAll('table[role=table] th, table:not([role]) th')
405
- );
406
- const tableCells = Array.from(
407
- document.body.querySelectorAll('table[role=table] td, table:not([role]) td')
408
- );
419
+ // Identify the table elements with redundant roles.
409
420
  tallyTableRedundancy(gridHeaders, ['columnheader', 'rowheader', 'gridcell'], 'TH');
410
421
  tallyTableRedundancy(gridCells, ['gridcell'], 'TD');
411
422
  tallyTableRedundancy(tableHeaders, ['columnheader', 'rowheader', 'cell'], 'TH');
@@ -422,6 +433,7 @@ exports.reporter = async page => await page.$eval('body', body => {
422
433
  const lcTagName = tagName.toLowerCase();
423
434
  // If it is simply redundant:
424
435
  if (role === implicitRoles[lcTagName]) {
436
+ // Update the results.
425
437
  data.redundantRoleElements++;
426
438
  data.tagNames[tagName][role].redundant++;
427
439
  }
@@ -446,18 +458,20 @@ exports.reporter = async page => await page.$eval('body', body => {
446
458
  )
447
459
  )
448
460
  ) {
461
+ // Update the results.
449
462
  data.redundantRoleElements++;
450
463
  data.tagNames[tagName][role].redundant++;
451
464
  }
452
465
  // Otherwise, i.e. if it is absolutely invalid:
453
466
  else {
467
+ // Update the results.
454
468
  data.badRoleElements++;
455
469
  data.tagNames[tagName][role].bad++;
456
470
  }
457
471
  }
458
472
  // Otherwise, i.e. if it is absolutely invalid:
459
473
  else {
460
- // Add the facts to the result.
474
+ // Update the results.
461
475
  data.badRoleElements++;
462
476
  dataInit(data, tagName, role);
463
477
  data.tagNames[tagName][role].bad++;