@axe-core/playwright
Advanced tools
Comparing version 4.2.3-alpha.172 to 4.2.3-alpha.173
@@ -69,3 +69,9 @@ import type { RunOptions, AxeResults } from 'axe-core'; | ||
* Inject `axe-core` into each frame and run `axe.runPartial`. | ||
* Because we need to inject axe into all frames all at once (to avoid any potential problems with the DOM becoming out-of-sync) but also need to not process results for any child frames if the parent frame throws an error (requirements of the data structure for `axe.finishRun`), we have to return a deeply nested array of Promises and then flatten the array once all Promises have finished, throwing out any nested Promises if the parent Promise is not fulfilled. | ||
* Because we need to inject axe into all frames all at once | ||
* (to avoid any potential problems with the DOM becoming out-of-sync) | ||
* but also need to not process results for any child frames if the parent | ||
* frame throws an error (requirements of the data structure for `axe.finishRun`), | ||
* we have to return a deeply nested array of Promises and then flatten | ||
* the array once all Promises have finished, throwing out any nested Promises | ||
* if the parent Promise is not fulfilled. | ||
* @param frame - playwright frame object | ||
@@ -76,2 +82,3 @@ * @param context - axe-core context object | ||
private runPartialRecursive; | ||
private finishRun; | ||
} |
@@ -158,9 +158,3 @@ "use strict"; | ||
partials = _b.sent(); | ||
return [4 /*yield*/, page.evaluate(browser_1.axeFinishRun, { | ||
partialResults: partials, | ||
options: options | ||
})]; | ||
case 6: | ||
results = _b.sent(); | ||
return [2 /*return*/, results]; | ||
return [2 /*return*/, this.finishRun(partials)]; | ||
} | ||
@@ -231,3 +225,9 @@ }); | ||
* Inject `axe-core` into each frame and run `axe.runPartial`. | ||
* Because we need to inject axe into all frames all at once (to avoid any potential problems with the DOM becoming out-of-sync) but also need to not process results for any child frames if the parent frame throws an error (requirements of the data structure for `axe.finishRun`), we have to return a deeply nested array of Promises and then flatten the array once all Promises have finished, throwing out any nested Promises if the parent Promise is not fulfilled. | ||
* Because we need to inject axe into all frames all at once | ||
* (to avoid any potential problems with the DOM becoming out-of-sync) | ||
* but also need to not process results for any child frames if the parent | ||
* frame throws an error (requirements of the data structure for `axe.finishRun`), | ||
* we have to return a deeply nested array of Promises and then flatten | ||
* the array once all Promises have finished, throwing out any nested Promises | ||
* if the parent Promise is not fulfilled. | ||
* @param frame - playwright frame object | ||
@@ -294,2 +294,27 @@ * @param context - axe-core context object | ||
}; | ||
AxeBuilder.prototype.finishRun = function (partialResults) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, page, options, context, blankPage; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a = this, page = _a.page, options = _a.option; | ||
context = page.context(); | ||
return [4 /*yield*/, context.newPage()]; | ||
case 1: | ||
blankPage = _b.sent(); | ||
blankPage.evaluate(this.script()); | ||
return [4 /*yield*/, blankPage | ||
.evaluate(browser_1.axeFinishRun, { | ||
partialResults: partialResults, | ||
options: options | ||
}) | ||
.finally(function () { | ||
blankPage.close(); | ||
})]; | ||
case 2: return [2 /*return*/, _b.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return AxeBuilder; | ||
@@ -296,0 +321,0 @@ }()); |
{ | ||
"name": "@axe-core/playwright", | ||
"version": "4.2.3-alpha.172+2135347", | ||
"version": "4.2.3-alpha.173+691bd2c", | ||
"description": "Provides a method to inject and analyze web pages using axe", | ||
@@ -34,3 +34,3 @@ "contributors": [ | ||
"build": "tsc", | ||
"test": "mocha --timeout 60000 -r ts-node/register 'src/test.ts'", | ||
"test": "mocha --timeout 60000 -r ts-node/register 'tests/**.spec.ts'", | ||
"coverage": "nyc npm run test", | ||
@@ -40,3 +40,3 @@ "prepare": "npm run build" | ||
"dependencies": { | ||
"axe-core": "^4.3.2", | ||
"axe-core": "^4.3.3", | ||
"playwright": "^1.13.1" | ||
@@ -82,3 +82,3 @@ }, | ||
}, | ||
"gitHead": "21353478bb4fb75688ffcfcd3a8a0e7198a8f0d3" | ||
"gitHead": "691bd2c2c9b1b98bb1ca326af0b95c562e688eb4" | ||
} |
import * as fs from 'fs'; | ||
import type { Page, Frame, ElementHandle } from 'playwright'; | ||
import type { RunOptions, AxeResults, ContextObject } from 'axe-core'; | ||
import type { | ||
RunOptions, | ||
AxeResults, | ||
ContextObject, | ||
PartialResults | ||
} from 'axe-core'; | ||
import { normalizeContext, analyzePage } from './utils'; | ||
@@ -145,8 +150,3 @@ import type { AxePlaywrightParams } from './types'; | ||
const partials = await partialResults.getPartials(); | ||
results = await page.evaluate(axeFinishRun, { | ||
partialResults: partials, | ||
options | ||
}); | ||
return results; | ||
return this.finishRun(partials); | ||
} | ||
@@ -201,3 +201,9 @@ | ||
* Inject `axe-core` into each frame and run `axe.runPartial`. | ||
* Because we need to inject axe into all frames all at once (to avoid any potential problems with the DOM becoming out-of-sync) but also need to not process results for any child frames if the parent frame throws an error (requirements of the data structure for `axe.finishRun`), we have to return a deeply nested array of Promises and then flatten the array once all Promises have finished, throwing out any nested Promises if the parent Promise is not fulfilled. | ||
* Because we need to inject axe into all frames all at once | ||
* (to avoid any potential problems with the DOM becoming out-of-sync) | ||
* but also need to not process results for any child frames if the parent | ||
* frame throws an error (requirements of the data structure for `axe.finishRun`), | ||
* we have to return a deeply nested array of Promises and then flatten | ||
* the array once all Promises have finished, throwing out any nested Promises | ||
* if the parent Promise is not fulfilled. | ||
* @param frame - playwright frame object | ||
@@ -247,2 +253,17 @@ * @param context - axe-core context object | ||
} | ||
private async finishRun(partialResults: PartialResults): Promise<AxeResults> { | ||
const { page, option: options } = this; | ||
const context = page.context(); | ||
const blankPage = await context.newPage(); | ||
blankPage.evaluate(this.script()); | ||
return await blankPage | ||
.evaluate(axeFinishRun, { | ||
partialResults, | ||
options | ||
}) | ||
.finally(() => { | ||
blankPage.close(); | ||
}); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
1
1
87108
28
1514
Updatedaxe-core@^4.3.3