Skip to content

Commit

Permalink
throw only in run partial
Browse files Browse the repository at this point in the history
  • Loading branch information
straker committed May 13, 2024
1 parent b57bfd0 commit 41032a0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/playwright/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export default class AxeBuilder {
* @returns Promise<void>
*/

private async inject(frames: Frame[]): Promise<void> {
private async inject(frames: Frame[], shouldThrow?: boolean): Promise<void> {
for (const iframe of frames) {
const race = new Promise((_, reject) => {
setTimeout(() => {
Expand All @@ -192,8 +192,15 @@ export default class AxeBuilder {
});
const evaluate = iframe.evaluate(this.script());

await Promise.race([evaluate, race]);
await iframe.evaluate(await this.axeConfigure());
try {
await Promise.race([evaluate, race]);
await iframe.evaluate(await this.axeConfigure());
} catch (err) {
// in legacy mode we don't want to throw the error we just want to skip injecting into the frame
if (shouldThrow) {
throw err;
}
}
}
}

Expand Down Expand Up @@ -263,7 +270,7 @@ export default class AxeBuilder {
iframeHandle.asElement() as ElementHandle<Element>;
const childFrame = await iframeElement.contentFrame();
if (childFrame) {
await this.inject([childFrame]);
await this.inject([childFrame], true);
childResults = await this.runPartialRecursive(
childFrame,
frameContext
Expand Down

0 comments on commit 41032a0

Please sign in to comment.