@axe-core/playwright 4.9.1-f38a6c8.0 → 4.9.2-6eaaa84.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/dist/index.js CHANGED
@@ -233,7 +233,7 @@ var AxeBuilder = class {
233
233
  async analyze() {
234
234
  const context = normalizeContext(this.includes, this.excludes);
235
235
  const { page } = this;
236
- page.evaluate(this.script());
236
+ await page.evaluate(this.script());
237
237
  const runPartialDefined = await page.evaluate(
238
238
  'typeof window.axe.runPartial === "function"'
239
239
  );
@@ -261,10 +261,22 @@ var AxeBuilder = class {
261
261
  * @param Page - playwright page object
262
262
  * @returns Promise<void>
263
263
  */
264
- async inject(frames) {
264
+ async inject(frames, shouldThrow) {
265
265
  for (const iframe of frames) {
266
- await iframe.evaluate(await this.script());
267
- await iframe.evaluate(await this.axeConfigure());
266
+ const race = new Promise((_, reject) => {
267
+ setTimeout(() => {
268
+ reject(new Error("Script Timeout"));
269
+ }, 1e3);
270
+ });
271
+ const evaluate = iframe.evaluate(this.script());
272
+ try {
273
+ await Promise.race([evaluate, race]);
274
+ await iframe.evaluate(await this.axeConfigure());
275
+ } catch (err) {
276
+ if (shouldThrow) {
277
+ throw err;
278
+ }
279
+ }
268
280
  }
269
281
  }
270
282
  /**
@@ -318,7 +330,7 @@ var AxeBuilder = class {
318
330
  const iframeElement = iframeHandle.asElement();
319
331
  const childFrame = await iframeElement.contentFrame();
320
332
  if (childFrame) {
321
- await this.inject([childFrame]);
333
+ await this.inject([childFrame], true);
322
334
  childResults = await this.runPartialRecursive(
323
335
  childFrame,
324
336
  frameContext
@@ -338,8 +350,8 @@ var AxeBuilder = class {
338
350
  blankPage,
339
351
  "Please make sure that you have popup blockers disabled."
340
352
  );
341
- blankPage.evaluate(this.script());
342
- blankPage.evaluate(await this.axeConfigure());
353
+ await blankPage.evaluate(this.script());
354
+ await blankPage.evaluate(await this.axeConfigure());
343
355
  const sizeLimit = 6e7;
344
356
  const partialString = JSON.stringify(partialResults);
345
357
  async function chunkResults(result) {
package/dist/index.mjs CHANGED
@@ -198,7 +198,7 @@ var AxeBuilder = class {
198
198
  async analyze() {
199
199
  const context = normalizeContext(this.includes, this.excludes);
200
200
  const { page } = this;
201
- page.evaluate(this.script());
201
+ await page.evaluate(this.script());
202
202
  const runPartialDefined = await page.evaluate(
203
203
  'typeof window.axe.runPartial === "function"'
204
204
  );
@@ -226,10 +226,22 @@ var AxeBuilder = class {
226
226
  * @param Page - playwright page object
227
227
  * @returns Promise<void>
228
228
  */
229
- async inject(frames) {
229
+ async inject(frames, shouldThrow) {
230
230
  for (const iframe of frames) {
231
- await iframe.evaluate(await this.script());
232
- await iframe.evaluate(await this.axeConfigure());
231
+ const race = new Promise((_, reject) => {
232
+ setTimeout(() => {
233
+ reject(new Error("Script Timeout"));
234
+ }, 1e3);
235
+ });
236
+ const evaluate = iframe.evaluate(this.script());
237
+ try {
238
+ await Promise.race([evaluate, race]);
239
+ await iframe.evaluate(await this.axeConfigure());
240
+ } catch (err) {
241
+ if (shouldThrow) {
242
+ throw err;
243
+ }
244
+ }
233
245
  }
234
246
  }
235
247
  /**
@@ -283,7 +295,7 @@ var AxeBuilder = class {
283
295
  const iframeElement = iframeHandle.asElement();
284
296
  const childFrame = await iframeElement.contentFrame();
285
297
  if (childFrame) {
286
- await this.inject([childFrame]);
298
+ await this.inject([childFrame], true);
287
299
  childResults = await this.runPartialRecursive(
288
300
  childFrame,
289
301
  frameContext
@@ -303,8 +315,8 @@ var AxeBuilder = class {
303
315
  blankPage,
304
316
  "Please make sure that you have popup blockers disabled."
305
317
  );
306
- blankPage.evaluate(this.script());
307
- blankPage.evaluate(await this.axeConfigure());
318
+ await blankPage.evaluate(this.script());
319
+ await blankPage.evaluate(await this.axeConfigure());
308
320
  const sizeLimit = 6e7;
309
321
  const partialString = JSON.stringify(partialResults);
310
322
  async function chunkResults(result) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axe-core/playwright",
3
- "version": "4.9.1-f38a6c8.0+f38a6c8",
3
+ "version": "4.9.2-6eaaa84.0+6eaaa84",
4
4
  "description": "Provides a method to inject and analyze web pages using axe",
5
5
  "contributors": [
6
6
  {
@@ -51,10 +51,10 @@
51
51
  "prepare": "npx playwright install && npm run build"
52
52
  },
53
53
  "dependencies": {
54
- "axe-core": "~4.9.0"
54
+ "axe-core": "~4.9.1"
55
55
  },
56
56
  "devDependencies": {
57
- "@playwright/test": "^1.34.3",
57
+ "@playwright/test": "^1.44.0",
58
58
  "@types/chai": "^4.3.3",
59
59
  "@types/express": "^4.17.14",
60
60
  "@types/mocha": "^10.0.0",
@@ -92,5 +92,5 @@
92
92
  "functions": 100,
93
93
  "lines": 95
94
94
  },
95
- "gitHead": "f38a6c82e98db673ed672d0f2e1a41810fd488c8"
95
+ "gitHead": "6eaaa84426528e2c0abd32bf03255e6f5c4e5e07"
96
96
  }