Skip to content

Commit

Permalink
fix(playwright): skip unloaded iframes
Browse files Browse the repository at this point in the history
  • Loading branch information
straker committed May 13, 2024
1 parent 8644fbd commit b57bfd0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"axe-core": "~4.9.0"
},
"devDependencies": {
"@playwright/test": "^1.34.3",
"@playwright/test": "^1.44.0",
"@types/chai": "^4.3.3",
"@types/express": "^4.17.14",
"@types/mocha": "^10.0.0",
Expand Down
9 changes: 8 additions & 1 deletion packages/playwright/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,14 @@ export default class AxeBuilder {

private async inject(frames: Frame[]): Promise<void> {
for (const iframe of frames) {
await iframe.evaluate(await this.script());
const race = new Promise((_, reject) => {
setTimeout(() => {
reject(new Error('Script Timeout'));
}, 1000);
});
const evaluate = iframe.evaluate(this.script());

await Promise.race([evaluate, race]);
await iframe.evaluate(await this.axeConfigure());
}
}
Expand Down
7 changes: 6 additions & 1 deletion packages/playwright/test/axe-playwright.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,12 @@ describe('@axe-core/playwright', () => {
.analyze();

assert.equal(res?.status(), 200);
assert.lengthOf(results.incomplete, 0);
assert.equal(results.incomplete[0].id, 'frame-tested');
assert.lengthOf(results.incomplete[0].nodes, 1);
assert.deepEqual(results.incomplete[0].nodes[0].target, [
'#ifr-lazy',
'#lazy-iframe'
]);
assert.equal(results.violations[0].id, 'label');
assert.lengthOf(results.violations[0].nodes, 1);
assert.deepEqual(results.violations[0].nodes[0].target, [
Expand Down

0 comments on commit b57bfd0

Please sign in to comment.