testaro 60.9.0 → 60.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "60.9.0",
3
+ "version": "60.10.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": {
@@ -39,19 +39,12 @@ const os = require('os');
39
39
 
40
40
  // CONSTANTS
41
41
 
42
- const headedBrowser = process.env.HEADED_BROWSER === 'true';
43
- const debug = process.env.DEBUG === 'true';
44
- const waits = Number.parseInt(process.env.WAITS) || 0;
45
42
  const tmpDir = os.tmpdir();
46
43
 
47
- // VARIABLES
48
-
49
- const actIndex = Number.parseInt(process.argv[2]);
50
-
51
44
  // FUNCTIONS
52
45
 
53
46
  // Performs the tests of the act specified by the caller.
54
- const doTestAct = async () => {
47
+ const doTestAct = async actIndex => {
55
48
  const reportPath = `${tmpDir}/report.json`;
56
49
  // Get the report from the temporary directory.
57
50
  const reportJSON = await fs.readFile(reportPath, 'utf8');
@@ -68,6 +61,7 @@ const doTestAct = async () => {
68
61
  // Launch a browser, navigate to the URL, and update the run-module page export.
69
62
  await launch(
70
63
  report,
64
+ actIndex,
71
65
  'high',
72
66
  browserID,
73
67
  targetURL
@@ -88,7 +82,7 @@ const doTestAct = async () => {
88
82
  page = require('../run').page;
89
83
  }
90
84
  }
91
- // If the page exists:
85
+ // If the page exists or the tool is Testaro:
92
86
  if (page || which === 'testaro') {
93
87
  try {
94
88
  // Make the act reporter perform the specified tests of the tool.
@@ -142,4 +136,4 @@ const doTestAct = async () => {
142
136
  }
143
137
  };
144
138
 
145
- doTestAct();
139
+ doTestAct(Number.parseInt(process.argv[2]));
package/run.js CHANGED
@@ -111,7 +111,6 @@ const tmpDir = os.tmpdir();
111
111
  // Facts about the current session.
112
112
  let actCount = 0;
113
113
  // Facts about the current act.
114
- let actIndex = 0;
115
114
  let browser;
116
115
  let cleanupInProgress = false;
117
116
  let browserCloseIntentional = false;
@@ -290,9 +289,9 @@ const browserClose = exports.browserClose = async () => {
290
289
  };
291
290
  // Launches a browser and navigates to a URL.
292
291
  const launch = exports.launch = async (
293
- report, headEmulation, tempBrowserID, tempURL, retries = 2
292
+ report, actIndex, headEmulation, tempBrowserID, tempURL, retries = 2
294
293
  ) => {
295
- const act = report.acts[actIndex];
294
+ const act = report.acts[actIndex] || {};
296
295
  const {device} = report;
297
296
  const deviceID = device && device.id;
298
297
  const browserID = tempBrowserID || report.browserID || '';
@@ -435,12 +434,8 @@ const launch = exports.launch = async (
435
434
  page = await browserContext.newPage();
436
435
  // Wait until it is stable.
437
436
  await page.waitForLoadState('domcontentloaded', {timeout: 5000});
438
- const isTestaroTest = act.type === 'test' && act.which === 'testaro';
439
- // Add a script to the page to compute the accessible name of an element.
440
- await page.addInitScript({path: require.resolve('./dist/nameComputation.js')});
441
- // Add a script to the page to:
442
- await page.addInitScript(isTestaroTest => {
443
- // Mask automation detection.
437
+ // Add a script to the page to mask automation detection.
438
+ await page.addInitScript(() => {
444
439
  Object.defineProperty(navigator, 'webdriver', {get: () => undefined});
445
440
  window.chrome = {runtime: {}};
446
441
  Object.defineProperty(navigator, 'plugins', {
@@ -449,8 +444,14 @@ const launch = exports.launch = async (
449
444
  Object.defineProperty(navigator, 'languages', {
450
445
  get: () => ['en-US', 'en']
451
446
  });
452
- // If the act is a testaro test act:
453
- if (isTestaroTest) {
447
+ });
448
+ const isTestaroTest = act.type === 'test' && act.which === 'testaro';
449
+ // If the act is a testaro test act:
450
+ if (isTestaroTest) {
451
+ // Add a script to the page to compute the accessible name of an element.
452
+ await page.addInitScript({path: require.resolve('./dist/nameComputation.js')});
453
+ // Add a script to the page to:
454
+ await page.addInitScript(() => {
454
455
  // Add a window method to compute the accessible name of an element.
455
456
  window.getAccessibleName = element => {
456
457
  const nameIsComputable = element
@@ -560,8 +561,8 @@ const launch = exports.launch = async (
560
561
  // Return the XPath.
561
562
  return `/${segments.join('/')}`;
562
563
  };
563
- }
564
- }, isTestaroTest);
564
+ });
565
+ }
565
566
  // Navigate to the specified URL.
566
567
  const navResult = await goTo(report, page, url, 15000, 'domcontentloaded');
567
568
  // If the navigation succeeded:
@@ -603,7 +604,7 @@ const launch = exports.launch = async (
603
604
  );
604
605
  await wait(1000 * waitSeconds + 100);
605
606
  // Then retry the launch and navigation.
606
- return launch(report, headEmulation, tempBrowserID, tempURL, retries - 1);
607
+ return launch(report, actIndex, headEmulation, tempBrowserID, tempURL, retries - 1);
607
608
  }
608
609
  // Otherwise, i.e. if no retries remain:
609
610
  else {
@@ -828,9 +829,8 @@ const doActs = async (report, opts = {}) => {
828
829
  const standard = report.standard || 'only';
829
830
  const reportPath = `${tmpDir}/report.json`;
830
831
  // For each act in the report.
831
- for (const doActsIndex in acts) {
832
+ for (const actIndex in acts) {
832
833
  if (signal && signal.aborted) throw new Error('doActs aborted');
833
- actIndex = doActsIndex;
834
834
  // If the job has not been aborted:
835
835
  if (report.jobData && ! report.jobData.aborted) {
836
836
  let act = acts[actIndex];
@@ -908,6 +908,7 @@ const doActs = async (report, opts = {}) => {
908
908
  // Launch a browser, navigate to a page, and add the result to the act.
909
909
  await launch(
910
910
  report,
911
+ actIndex,
911
912
  'high',
912
913
  actLaunchSpecs[0],
913
914
  actLaunchSpecs[1]
@@ -1658,6 +1659,7 @@ const doActs = async (report, opts = {}) => {
1658
1659
  // Replace the browser and navigate to the URL.
1659
1660
  await launch(
1660
1661
  report,
1662
+ '',
1661
1663
  'high',
1662
1664
  specs[0],
1663
1665
  specs[1]
package/tests/testaro.js CHANGED
@@ -552,6 +552,7 @@ exports.reporter = async (page, report, actIndex) => {
552
552
  // Replace the browser and the page and navigate to the target.
553
553
  await launch(
554
554
  report,
555
+ actIndex,
555
556
  headEmulation,
556
557
  browserID,
557
558
  url
@@ -663,6 +664,7 @@ exports.reporter = async (page, report, actIndex) => {
663
664
  // Replace the browser and the page in the run module and navigate to the target.
664
665
  await launch(
665
666
  report,
667
+ actIndex,
666
668
  headEmulation,
667
669
  report.browserID,
668
670
  url