@axe-core/webdriverjs 4.7.3-alpha.397 → 4.7.3

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/dist/index.js CHANGED
@@ -432,7 +432,14 @@ var AxeBuilder = class {
432
432
  if (runPartialSupported !== true || this.legacyMode) {
433
433
  return this.runLegacy(context);
434
434
  }
435
- const partials = await this.runPartialRecursive(context, true);
435
+ const { pageLoad } = await this.driver.manage().getTimeouts();
436
+ this.driver.manage().setTimeouts({ pageLoad: 1e3 });
437
+ let partials;
438
+ try {
439
+ partials = await this.runPartialRecursive(context);
440
+ } finally {
441
+ this.driver.manage().setTimeouts({ pageLoad });
442
+ }
436
443
  try {
437
444
  return await this.finishRun(partials);
438
445
  } catch (error2) {
@@ -466,8 +473,8 @@ var AxeBuilder = class {
466
473
  /**
467
474
  * Get partial results from the current context and its child frames
468
475
  */
469
- async runPartialRecursive(context, initiator = false) {
470
- if (!initiator) {
476
+ async runPartialRecursive(context, frameStack = []) {
477
+ if (frameStack.length) {
471
478
  await axeSourceInject(this.driver, this.axeSource, this.config);
472
479
  }
473
480
  const frameContexts = await axeGetFrameContext(this.driver, context);
@@ -475,16 +482,16 @@ var AxeBuilder = class {
475
482
  await axeRunPartial(this.driver, context, this.option)
476
483
  ];
477
484
  for (const { frameContext, frameSelector, frame } of frameContexts) {
478
- let switchedFrame = false;
479
485
  try {
480
486
  (0, import_assert.default)(frame, `Expect frame of "${frameSelector}" to be defined`);
481
487
  await this.driver.switchTo().frame(frame);
482
- switchedFrame = true;
483
- partials.push(...await this.runPartialRecursive(frameContext));
488
+ partials.push(...await this.runPartialRecursive(frameContext, [...frameStack, frame]));
484
489
  await this.driver.switchTo().parentFrame();
485
490
  } catch {
486
- if (switchedFrame) {
487
- await this.driver.switchTo().parentFrame();
491
+ const win = await this.driver.getWindowHandle();
492
+ await this.driver.switchTo().window(win);
493
+ for (const frameElm of frameStack) {
494
+ await this.driver.switchTo().frame(frameElm);
488
495
  }
489
496
  partials.push("null");
490
497
  }
@@ -497,6 +504,7 @@ var AxeBuilder = class {
497
504
  async finishRun(partials) {
498
505
  const { driver, axeSource, config, option } = this;
499
506
  const win = await driver.getWindowHandle();
507
+ await driver.switchTo().window(win);
500
508
  try {
501
509
  await driver.executeScript(`window.open('about:blank')`);
502
510
  const handlers = await driver.getAllWindowHandles();
package/dist/index.mjs CHANGED
@@ -397,7 +397,14 @@ var AxeBuilder = class {
397
397
  if (runPartialSupported !== true || this.legacyMode) {
398
398
  return this.runLegacy(context);
399
399
  }
400
- const partials = await this.runPartialRecursive(context, true);
400
+ const { pageLoad } = await this.driver.manage().getTimeouts();
401
+ this.driver.manage().setTimeouts({ pageLoad: 1e3 });
402
+ let partials;
403
+ try {
404
+ partials = await this.runPartialRecursive(context);
405
+ } finally {
406
+ this.driver.manage().setTimeouts({ pageLoad });
407
+ }
401
408
  try {
402
409
  return await this.finishRun(partials);
403
410
  } catch (error2) {
@@ -431,8 +438,8 @@ var AxeBuilder = class {
431
438
  /**
432
439
  * Get partial results from the current context and its child frames
433
440
  */
434
- async runPartialRecursive(context, initiator = false) {
435
- if (!initiator) {
441
+ async runPartialRecursive(context, frameStack = []) {
442
+ if (frameStack.length) {
436
443
  await axeSourceInject(this.driver, this.axeSource, this.config);
437
444
  }
438
445
  const frameContexts = await axeGetFrameContext(this.driver, context);
@@ -440,16 +447,16 @@ var AxeBuilder = class {
440
447
  await axeRunPartial(this.driver, context, this.option)
441
448
  ];
442
449
  for (const { frameContext, frameSelector, frame } of frameContexts) {
443
- let switchedFrame = false;
444
450
  try {
445
451
  assert(frame, `Expect frame of "${frameSelector}" to be defined`);
446
452
  await this.driver.switchTo().frame(frame);
447
- switchedFrame = true;
448
- partials.push(...await this.runPartialRecursive(frameContext));
453
+ partials.push(...await this.runPartialRecursive(frameContext, [...frameStack, frame]));
449
454
  await this.driver.switchTo().parentFrame();
450
455
  } catch {
451
- if (switchedFrame) {
452
- await this.driver.switchTo().parentFrame();
456
+ const win = await this.driver.getWindowHandle();
457
+ await this.driver.switchTo().window(win);
458
+ for (const frameElm of frameStack) {
459
+ await this.driver.switchTo().frame(frameElm);
453
460
  }
454
461
  partials.push("null");
455
462
  }
@@ -462,6 +469,7 @@ var AxeBuilder = class {
462
469
  async finishRun(partials) {
463
470
  const { driver, axeSource, config, option } = this;
464
471
  const win = await driver.getWindowHandle();
472
+ await driver.switchTo().window(win);
465
473
  try {
466
474
  await driver.executeScript(`window.open('about:blank')`);
467
475
  const handlers = await driver.getAllWindowHandles();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axe-core/webdriverjs",
3
- "version": "4.7.3-alpha.397+48e222e",
3
+ "version": "4.7.3",
4
4
  "description": "Provides a method to inject and analyze web pages using axe",
5
5
  "contributors": [
6
6
  {
@@ -119,5 +119,5 @@
119
119
  "functions": 85,
120
120
  "lines": 85
121
121
  },
122
- "gitHead": "48e222e87da6f5ee79a81f61ab2e4cc4cc3e6ae6"
122
+ "gitHead": "ad1c229716920cbc359553e0bcb2e0b20ac55ac9"
123
123
  }