@axe-core/playwright 4.6.2-alpha.379 → 4.7.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.d.ts +11 -3
- package/dist/index.js +361 -394
- package/dist/index.mjs +338 -0
- package/package.json +15 -5
- package/dist/AxePartialRunner.d.ts +0 -22
- package/dist/AxePartialRunner.js +0 -96
- package/dist/AxePartialRunner.js.map +0 -1
- package/dist/browser.d.ts +0 -14
- package/dist/browser.js +0 -30
- package/dist/browser.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts +0 -28
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -15
- package/dist/utils.js +0 -45
- package/dist/utils.js.map +0 -1
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import assert from "assert";
|
|
3
|
+
import axe from "axe-core";
|
|
4
|
+
|
|
5
|
+
// src/utils.ts
|
|
6
|
+
var normalizeContext = (includes, excludes) => {
|
|
7
|
+
const base = {
|
|
8
|
+
exclude: [],
|
|
9
|
+
include: []
|
|
10
|
+
};
|
|
11
|
+
if (excludes.length && Array.isArray(base.exclude)) {
|
|
12
|
+
base.exclude.push(...excludes);
|
|
13
|
+
}
|
|
14
|
+
if (includes.length) {
|
|
15
|
+
base.include = includes;
|
|
16
|
+
}
|
|
17
|
+
return base;
|
|
18
|
+
};
|
|
19
|
+
var analyzePage = ({
|
|
20
|
+
context,
|
|
21
|
+
options
|
|
22
|
+
}) => {
|
|
23
|
+
const axeCore = window.axe;
|
|
24
|
+
return axeCore.run(context || document, options || {}).then((results) => {
|
|
25
|
+
return { error: null, results };
|
|
26
|
+
}).catch((err) => {
|
|
27
|
+
return { error: err.message, results: null };
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// src/browser.ts
|
|
32
|
+
var axeGetFrameContexts = ({
|
|
33
|
+
context
|
|
34
|
+
}) => {
|
|
35
|
+
return window.axe.utils.getFrameContexts(context);
|
|
36
|
+
};
|
|
37
|
+
var axeShadowSelect = ({
|
|
38
|
+
frameSelector
|
|
39
|
+
}) => {
|
|
40
|
+
return window.axe.utils.shadowSelect(frameSelector);
|
|
41
|
+
};
|
|
42
|
+
var axeRunPartial = ({
|
|
43
|
+
context,
|
|
44
|
+
options
|
|
45
|
+
}) => {
|
|
46
|
+
return window.axe.runPartial(context, options);
|
|
47
|
+
};
|
|
48
|
+
var axeFinishRun = ({
|
|
49
|
+
options
|
|
50
|
+
}) => {
|
|
51
|
+
return window.axe.finishRun(JSON.parse(window.partialResults), options);
|
|
52
|
+
};
|
|
53
|
+
function chunkResultString(chunk) {
|
|
54
|
+
if (!window.partialResults) {
|
|
55
|
+
window.partialResults = "";
|
|
56
|
+
}
|
|
57
|
+
window.partialResults += chunk;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/AxePartialRunner.ts
|
|
61
|
+
var AxePartialRunner = class {
|
|
62
|
+
constructor(partialPromise, initiator = false) {
|
|
63
|
+
this.initiator = initiator;
|
|
64
|
+
this.partialPromise = caught(partialPromise);
|
|
65
|
+
}
|
|
66
|
+
partialPromise;
|
|
67
|
+
childRunners = [];
|
|
68
|
+
addChildResults(childResultRunner) {
|
|
69
|
+
this.childRunners.push(childResultRunner);
|
|
70
|
+
}
|
|
71
|
+
async getPartials() {
|
|
72
|
+
try {
|
|
73
|
+
const parentPartial = await this.partialPromise;
|
|
74
|
+
const childPromises = this.childRunners.map((childRunner) => {
|
|
75
|
+
return childRunner ? caught(childRunner.getPartials()) : [null];
|
|
76
|
+
});
|
|
77
|
+
const childPartials = (await Promise.all(childPromises)).flat(1);
|
|
78
|
+
return [parentPartial, ...childPartials];
|
|
79
|
+
} catch (e) {
|
|
80
|
+
if (this.initiator) {
|
|
81
|
+
throw e;
|
|
82
|
+
}
|
|
83
|
+
return [null];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var caught = ((f) => {
|
|
88
|
+
return (p) => (p.catch(f), p);
|
|
89
|
+
})(() => {
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// src/index.ts
|
|
93
|
+
var { source } = axe;
|
|
94
|
+
var AxeBuilder = class {
|
|
95
|
+
page;
|
|
96
|
+
includes;
|
|
97
|
+
excludes;
|
|
98
|
+
option;
|
|
99
|
+
source;
|
|
100
|
+
legacyMode = false;
|
|
101
|
+
errorUrl;
|
|
102
|
+
constructor({ page, axeSource }) {
|
|
103
|
+
this.page = page;
|
|
104
|
+
this.includes = [];
|
|
105
|
+
this.excludes = [];
|
|
106
|
+
this.option = {};
|
|
107
|
+
this.source = axeSource || source;
|
|
108
|
+
this.errorUrl = "https://github.com/dequelabs/axe-core-npm/blob/develop/packages/playwright/error-handling.md";
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Selector to include in analysis.
|
|
112
|
+
* This may be called any number of times.
|
|
113
|
+
* @param String selector
|
|
114
|
+
* @returns this
|
|
115
|
+
*/
|
|
116
|
+
include(selector) {
|
|
117
|
+
this.includes.push(selector);
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Selector to exclude in analysis.
|
|
122
|
+
* This may be called any number of times.
|
|
123
|
+
* @param String selector
|
|
124
|
+
* @returns this
|
|
125
|
+
*/
|
|
126
|
+
exclude(selector) {
|
|
127
|
+
this.excludes.push(selector);
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Set options to be passed into axe-core
|
|
132
|
+
* @param RunOptions options
|
|
133
|
+
* @returns AxeBuilder
|
|
134
|
+
*/
|
|
135
|
+
options(options) {
|
|
136
|
+
this.option = options;
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Limit analysis to only the specified rules.
|
|
141
|
+
* Cannot be used with `AxeBuilder#withTags`
|
|
142
|
+
* @param String|Array rules
|
|
143
|
+
* @returns this
|
|
144
|
+
*/
|
|
145
|
+
withRules(rules) {
|
|
146
|
+
rules = Array.isArray(rules) ? rules : [rules];
|
|
147
|
+
this.option = this.option || {};
|
|
148
|
+
this.option.runOnly = {
|
|
149
|
+
type: "rule",
|
|
150
|
+
values: rules
|
|
151
|
+
};
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Limit analysis to only specified tags.
|
|
156
|
+
* Cannot be used with `AxeBuilder#withRules`
|
|
157
|
+
* @param String|Array tags
|
|
158
|
+
* @returns this
|
|
159
|
+
*/
|
|
160
|
+
withTags(tags) {
|
|
161
|
+
tags = Array.isArray(tags) ? tags : [tags];
|
|
162
|
+
this.option = this.option || {};
|
|
163
|
+
this.option.runOnly = {
|
|
164
|
+
type: "tag",
|
|
165
|
+
values: tags
|
|
166
|
+
};
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Set the list of rules to skip when running an analysis.
|
|
171
|
+
* @param String|Array rules
|
|
172
|
+
* @returns this
|
|
173
|
+
*/
|
|
174
|
+
disableRules(rules) {
|
|
175
|
+
rules = Array.isArray(rules) ? rules : [rules];
|
|
176
|
+
this.option = this.option || {};
|
|
177
|
+
this.option.rules = {};
|
|
178
|
+
for (const rule of rules) {
|
|
179
|
+
this.option.rules[rule] = { enabled: false };
|
|
180
|
+
}
|
|
181
|
+
return this;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Use frameMessenger with <same_origin_only>
|
|
185
|
+
*
|
|
186
|
+
* This disables use of axe.runPartial() which is called in each frame, and
|
|
187
|
+
* axe.finishRun() which is called in a blank page. This uses axe.run() instead,
|
|
188
|
+
* but with the restriction that cross-origin frames will not be tested.
|
|
189
|
+
*/
|
|
190
|
+
setLegacyMode(legacyMode = true) {
|
|
191
|
+
this.legacyMode = legacyMode;
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Perform analysis and retrieve results. *Does not chain.*
|
|
196
|
+
* @return Promise<Result | Error>
|
|
197
|
+
*/
|
|
198
|
+
async analyze() {
|
|
199
|
+
const context = normalizeContext(this.includes, this.excludes);
|
|
200
|
+
const { page, option: options } = this;
|
|
201
|
+
page.evaluate(this.script());
|
|
202
|
+
const runPartialDefined = await page.evaluate(
|
|
203
|
+
'typeof window.axe.runPartial === "function"'
|
|
204
|
+
);
|
|
205
|
+
let results;
|
|
206
|
+
if (!runPartialDefined || this.legacyMode) {
|
|
207
|
+
results = await this.runLegacy(context);
|
|
208
|
+
return results;
|
|
209
|
+
}
|
|
210
|
+
const partialResults = await this.runPartialRecursive(
|
|
211
|
+
page.mainFrame(),
|
|
212
|
+
context
|
|
213
|
+
);
|
|
214
|
+
const partials = await partialResults.getPartials();
|
|
215
|
+
try {
|
|
216
|
+
return await this.finishRun(partials);
|
|
217
|
+
} catch (error) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`${error.message}
|
|
220
|
+
Please check out ${this.errorUrl}`
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Injects `axe-core` into all frames.
|
|
226
|
+
* @param Page - playwright page object
|
|
227
|
+
* @returns Promise<void>
|
|
228
|
+
*/
|
|
229
|
+
async inject(frames) {
|
|
230
|
+
for (const iframe of frames) {
|
|
231
|
+
await iframe.evaluate(await this.script());
|
|
232
|
+
await iframe.evaluate(await this.axeConfigure());
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Get axe-core source and configurations
|
|
237
|
+
* @returns String
|
|
238
|
+
*/
|
|
239
|
+
script() {
|
|
240
|
+
return this.source;
|
|
241
|
+
}
|
|
242
|
+
async runLegacy(context) {
|
|
243
|
+
const frames = this.page.frames();
|
|
244
|
+
await this.inject(frames);
|
|
245
|
+
const axeResults = await this.page.evaluate(analyzePage, {
|
|
246
|
+
context,
|
|
247
|
+
options: this.option
|
|
248
|
+
});
|
|
249
|
+
if (axeResults.error) {
|
|
250
|
+
throw new Error(axeResults.error);
|
|
251
|
+
}
|
|
252
|
+
return axeResults.results;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Inject `axe-core` into each frame and run `axe.runPartial`.
|
|
256
|
+
* Because we need to inject axe into all frames all at once
|
|
257
|
+
* (to avoid any potential problems with the DOM becoming out-of-sync)
|
|
258
|
+
* but also need to not process results for any child frames if the parent
|
|
259
|
+
* frame throws an error (requirements of the data structure for `axe.finishRun`),
|
|
260
|
+
* we have to return a deeply nested array of Promises and then flatten
|
|
261
|
+
* the array once all Promises have finished, throwing out any nested Promises
|
|
262
|
+
* if the parent Promise is not fulfilled.
|
|
263
|
+
* @param frame - playwright frame object
|
|
264
|
+
* @param context - axe-core context object
|
|
265
|
+
* @returns Promise<AxePartialRunner>
|
|
266
|
+
*/
|
|
267
|
+
async runPartialRecursive(frame, context) {
|
|
268
|
+
const frameContexts = await frame.evaluate(axeGetFrameContexts, {
|
|
269
|
+
context
|
|
270
|
+
});
|
|
271
|
+
const partialPromise = frame.evaluate(axeRunPartial, {
|
|
272
|
+
context,
|
|
273
|
+
options: this.option
|
|
274
|
+
});
|
|
275
|
+
const initiator = frame === this.page.mainFrame();
|
|
276
|
+
const axePartialRunner = new AxePartialRunner(partialPromise, initiator);
|
|
277
|
+
for (const { frameSelector, frameContext } of frameContexts) {
|
|
278
|
+
let childResults = null;
|
|
279
|
+
try {
|
|
280
|
+
const iframeHandle = await frame.evaluateHandle(axeShadowSelect, {
|
|
281
|
+
frameSelector
|
|
282
|
+
});
|
|
283
|
+
const iframeElement = iframeHandle.asElement();
|
|
284
|
+
const childFrame = await iframeElement.contentFrame();
|
|
285
|
+
if (childFrame) {
|
|
286
|
+
await this.inject([childFrame]);
|
|
287
|
+
childResults = await this.runPartialRecursive(
|
|
288
|
+
childFrame,
|
|
289
|
+
frameContext
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
} catch {
|
|
293
|
+
}
|
|
294
|
+
axePartialRunner.addChildResults(childResults);
|
|
295
|
+
}
|
|
296
|
+
return axePartialRunner;
|
|
297
|
+
}
|
|
298
|
+
async finishRun(partialResults) {
|
|
299
|
+
const { page, option: options } = this;
|
|
300
|
+
const context = page.context();
|
|
301
|
+
const blankPage = await context.newPage();
|
|
302
|
+
assert(
|
|
303
|
+
blankPage,
|
|
304
|
+
"Please make sure that you have popup blockers disabled."
|
|
305
|
+
);
|
|
306
|
+
blankPage.evaluate(this.script());
|
|
307
|
+
blankPage.evaluate(await this.axeConfigure());
|
|
308
|
+
const sizeLimit = 6e7;
|
|
309
|
+
const partialString = JSON.stringify(partialResults);
|
|
310
|
+
async function chunkResults(result) {
|
|
311
|
+
const chunk = result.substring(0, sizeLimit);
|
|
312
|
+
await blankPage.evaluate(chunkResultString, chunk);
|
|
313
|
+
if (result.length > sizeLimit) {
|
|
314
|
+
return await chunkResults(result.substr(sizeLimit));
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
await chunkResults(partialString);
|
|
318
|
+
return await blankPage.evaluate(axeFinishRun, {
|
|
319
|
+
options
|
|
320
|
+
}).finally(async () => {
|
|
321
|
+
await blankPage.close();
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
async axeConfigure() {
|
|
325
|
+
const hasRunPartial = await this.page.evaluate(
|
|
326
|
+
'typeof window.axe?.runPartial === "function"'
|
|
327
|
+
);
|
|
328
|
+
return `
|
|
329
|
+
;axe.configure({
|
|
330
|
+
${!this.legacyMode && !hasRunPartial ? 'allowedOrigins: ["<unsafe_all_origins>"],' : 'allowedOrigins: ["<same_origin>"],'}
|
|
331
|
+
branding: { application: 'playwright' }
|
|
332
|
+
})
|
|
333
|
+
`;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
export {
|
|
337
|
+
AxeBuilder as default
|
|
338
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axe-core/playwright",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Provides a method to inject and analyze web pages using axe",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
@@ -26,15 +26,24 @@
|
|
|
26
26
|
"url": "https://github.com/dequelabs/axe-core-npm.git"
|
|
27
27
|
},
|
|
28
28
|
"license": "MPL-2.0",
|
|
29
|
-
"main": "dist/index.js",
|
|
30
|
-
"
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"module": "./dist/index.mjs",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"import": "./dist/index.mjs",
|
|
35
|
+
"require": "./dist/index.js",
|
|
36
|
+
"types": "./dist/index.d.ts"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
31
39
|
"publishConfig": {
|
|
32
40
|
"access": "public"
|
|
33
41
|
},
|
|
34
42
|
"scripts": {
|
|
35
43
|
"prebuild": "rimraf dist",
|
|
36
|
-
"build": "
|
|
44
|
+
"build": "tsup src/index.ts --dts --format esm,cjs",
|
|
37
45
|
"test": "mocha --timeout 60000 -r ts-node/register 'tests/**.spec.ts'",
|
|
46
|
+
"test:esm": "node esmTest.mjs",
|
|
38
47
|
"coverage": "nyc npm run test",
|
|
39
48
|
"prepare": "npm run build"
|
|
40
49
|
},
|
|
@@ -57,6 +66,7 @@
|
|
|
57
66
|
"rimraf": "^3.0.2",
|
|
58
67
|
"test-listen": "^1.1.0",
|
|
59
68
|
"ts-node": "^10.9.1",
|
|
69
|
+
"tsup": "^6.7.0",
|
|
60
70
|
"typescript": "^4.8.4"
|
|
61
71
|
},
|
|
62
72
|
"peerDependencies": {
|
|
@@ -81,5 +91,5 @@
|
|
|
81
91
|
"functions": 100,
|
|
82
92
|
"lines": 95
|
|
83
93
|
},
|
|
84
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "623da3a516cbf1c7a0a0461b23a8c98f094cc18d"
|
|
85
95
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import axe from 'axe-core';
|
|
2
|
-
/**
|
|
3
|
-
* This class parallelizes the async calls to axe.runPartial.
|
|
4
|
-
*
|
|
5
|
-
* In this project, most async calls needs to block execution, such as
|
|
6
|
-
* the axeGetFrameContext() and getChildFrame() and calls.
|
|
7
|
-
*
|
|
8
|
-
* Unlike those calls, axe.runPartial() calls must run in parallel, so that
|
|
9
|
-
* frame tests don't wait for each other. This is necessary to minimize the time
|
|
10
|
-
* between when axe-core finds a frame, and when it is tested.
|
|
11
|
-
*/
|
|
12
|
-
declare type GetPartialResultsResponse = Parameters<typeof axe.finishRun>[0];
|
|
13
|
-
export default class AxePartialRunner {
|
|
14
|
-
private initiator;
|
|
15
|
-
private partialPromise;
|
|
16
|
-
private childRunners;
|
|
17
|
-
constructor(partialPromise: Promise<axe.PartialResult>, initiator?: boolean);
|
|
18
|
-
addChildResults(childResultRunner: AxePartialRunner | null): void;
|
|
19
|
-
getPartials(): Promise<GetPartialResultsResponse>;
|
|
20
|
-
}
|
|
21
|
-
export declare const caught: <T>(p: Promise<T>) => Promise<T>;
|
|
22
|
-
export {};
|
package/dist/AxePartialRunner.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
-
if (ar || !(i in from)) {
|
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
-
ar[i] = from[i];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.caught = void 0;
|
|
49
|
-
var AxePartialRunner = /** @class */ (function () {
|
|
50
|
-
function AxePartialRunner(partialPromise, initiator) {
|
|
51
|
-
if (initiator === void 0) { initiator = false; }
|
|
52
|
-
this.initiator = initiator;
|
|
53
|
-
this.childRunners = [];
|
|
54
|
-
this.partialPromise = (0, exports.caught)(partialPromise);
|
|
55
|
-
}
|
|
56
|
-
AxePartialRunner.prototype.addChildResults = function (childResultRunner) {
|
|
57
|
-
this.childRunners.push(childResultRunner);
|
|
58
|
-
};
|
|
59
|
-
AxePartialRunner.prototype.getPartials = function () {
|
|
60
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
-
var parentPartial, childPromises, childPartials, e_1;
|
|
62
|
-
return __generator(this, function (_a) {
|
|
63
|
-
switch (_a.label) {
|
|
64
|
-
case 0:
|
|
65
|
-
_a.trys.push([0, 3, , 4]);
|
|
66
|
-
return [4 /*yield*/, this.partialPromise];
|
|
67
|
-
case 1:
|
|
68
|
-
parentPartial = _a.sent();
|
|
69
|
-
childPromises = this.childRunners.map(function (childRunner) {
|
|
70
|
-
return childRunner ? (0, exports.caught)(childRunner.getPartials()) : [null];
|
|
71
|
-
});
|
|
72
|
-
return [4 /*yield*/, Promise.all(childPromises)];
|
|
73
|
-
case 2:
|
|
74
|
-
childPartials = (_a.sent()).flat(1);
|
|
75
|
-
return [2 /*return*/, __spreadArray([parentPartial], childPartials, true)];
|
|
76
|
-
case 3:
|
|
77
|
-
e_1 = _a.sent();
|
|
78
|
-
if (this.initiator) {
|
|
79
|
-
throw e_1;
|
|
80
|
-
}
|
|
81
|
-
return [2 /*return*/, [null]];
|
|
82
|
-
case 4: return [2 /*return*/];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
return AxePartialRunner;
|
|
88
|
-
}());
|
|
89
|
-
exports.default = AxePartialRunner;
|
|
90
|
-
// Utility to tell NodeJS not to worry about catching promise errors async.
|
|
91
|
-
// See: https://stackoverflow.com/questions/40920179/should-i-refrain-from-handling-promise-rejection-asynchronously
|
|
92
|
-
exports.caught = (function (f) {
|
|
93
|
-
return function (p) { return (p.catch(f), p); };
|
|
94
|
-
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
95
|
-
})(function () { });
|
|
96
|
-
//# sourceMappingURL=AxePartialRunner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AxePartialRunner.js","sourceRoot":"","sources":["../src/AxePartialRunner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;IAIE,0BACE,cAA0C,EAClC,SAA0B;QAA1B,0BAAA,EAAA,iBAA0B;QAA1B,cAAS,GAAT,SAAS,CAAiB;QAJ5B,iBAAY,GAAmC,EAAE,CAAC;QAMxD,IAAI,CAAC,cAAc,GAAG,IAAA,cAAM,EAAC,cAAc,CAAC,CAAC;IAC/C,CAAC;IAEM,0CAAe,GAAtB,UAAuB,iBAA0C;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC5C,CAAC;IAEY,sCAAW,GAAxB;;;;;;;wBAE0B,qBAAM,IAAI,CAAC,cAAc,EAAA;;wBAAzC,aAAa,GAAG,SAAyB;wBACzC,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAA,WAAW;4BACrD,OAAO,WAAW,CAAC,CAAC,CAAC,IAAA,cAAM,EAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;wBAClE,CAAC,CAAC,CAAC;wBACoB,qBAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAA;;wBAAjD,aAAa,GAAG,CAAC,SAAgC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;wBAChE,qCAAQ,aAAa,GAAK,aAAa,SAAE;;;wBAEzC,IAAI,IAAI,CAAC,SAAS,EAAE;4BAClB,MAAM,GAAC,CAAC;yBACT;wBACD,sBAAO,CAAC,IAAI,CAAC,EAAC;;;;;KAEjB;IACH,uBAAC;AAAD,CAAC,AA9BD,IA8BC;;AAED,2EAA2E;AAC3E,oHAAoH;AACvG,QAAA,MAAM,GAAG,CAAC,UAAC,CAAa;IACnC,OAAO,UAAI,CAAa,IAAiB,OAAA,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAf,CAAe,CAAC;IACzD,yDAAyD;AAC3D,CAAC,CAAC,CAAC,cAAO,CAAC,CAAC,CAAC"}
|
package/dist/browser.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { GetFrameContextsParams, RunPartialParams, FinishRunParams, ShadowSelectParams } from './types';
|
|
2
|
-
import { FrameContext, AxeResults, PartialResult } from 'axe-core';
|
|
3
|
-
import axeCore from 'axe-core';
|
|
4
|
-
declare global {
|
|
5
|
-
interface Window {
|
|
6
|
-
axe: typeof axeCore;
|
|
7
|
-
partialResults: string;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export declare const axeGetFrameContexts: ({ context }: GetFrameContextsParams) => FrameContext[];
|
|
11
|
-
export declare const axeShadowSelect: ({ frameSelector }: ShadowSelectParams) => Element | null;
|
|
12
|
-
export declare const axeRunPartial: ({ context, options }: RunPartialParams) => Promise<PartialResult>;
|
|
13
|
-
export declare const axeFinishRun: ({ options }: FinishRunParams) => Promise<AxeResults>;
|
|
14
|
-
export declare function chunkResultString(chunk: string): void;
|
package/dist/browser.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.chunkResultString = exports.axeFinishRun = exports.axeRunPartial = exports.axeShadowSelect = exports.axeGetFrameContexts = void 0;
|
|
4
|
-
var axeGetFrameContexts = function (_a) {
|
|
5
|
-
var context = _a.context;
|
|
6
|
-
return window.axe.utils.getFrameContexts(context);
|
|
7
|
-
};
|
|
8
|
-
exports.axeGetFrameContexts = axeGetFrameContexts;
|
|
9
|
-
var axeShadowSelect = function (_a) {
|
|
10
|
-
var frameSelector = _a.frameSelector;
|
|
11
|
-
return window.axe.utils.shadowSelect(frameSelector);
|
|
12
|
-
};
|
|
13
|
-
exports.axeShadowSelect = axeShadowSelect;
|
|
14
|
-
var axeRunPartial = function (_a) {
|
|
15
|
-
var context = _a.context, options = _a.options;
|
|
16
|
-
return window.axe.runPartial(context, options);
|
|
17
|
-
};
|
|
18
|
-
exports.axeRunPartial = axeRunPartial;
|
|
19
|
-
var axeFinishRun = function (_a) {
|
|
20
|
-
var options = _a.options;
|
|
21
|
-
return window.axe.finishRun(JSON.parse(window.partialResults), options);
|
|
22
|
-
};
|
|
23
|
-
exports.axeFinishRun = axeFinishRun;
|
|
24
|
-
function chunkResultString(chunk) {
|
|
25
|
-
var _a;
|
|
26
|
-
(_a = window.partialResults) !== null && _a !== void 0 ? _a : (window.partialResults = '');
|
|
27
|
-
window.partialResults += chunk;
|
|
28
|
-
}
|
|
29
|
-
exports.chunkResultString = chunkResultString;
|
|
30
|
-
//# sourceMappingURL=browser.js.map
|
package/dist/browser.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":";;;AAmBO,IAAM,mBAAmB,GAAG,UAAC,EAEX;QADvB,OAAO,aAAA;IAE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,QAAQ,CAAA;wBAAC,qBAAM,IAAI,CAAC,YAAY,EAAE,EAAA;;wBAA5C,cAAmB,SAAyB,EAAC,CAAC;wBAIxC,SAAS,GAAG,QAAU,CAAC;wBACvB,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;wBAWrD,qBAAM,YAAY,CAAC,aAAa,CAAC,EAAA;;wBAAjC,SAAiC,CAAC;wBAC3B,qBAAM,SAAS;iCACnB,QAAQ,CAAC,sBAAY,EAAE;gCACtB,OAAO,SAAA;6BACR,CAAC;iCACD,OAAO,CAAC;;;gDACP,qBAAM,SAAS,CAAC,KAAK,EAAE,EAAA;;4CAAvB,SAAuB,CAAC;;;;iCACzB,CAAC,EAAA;4BANJ,sBAAO,SAMH,EAAC;;;;KACN;IAEa,iCAAY,GAA1B;;;;;4BACwB,qBAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAC5C,8CAA8C,CAC/C,EAAA;;wBAFK,aAAa,GAAG,SAErB;wBAED,sBAAO,wCAGH,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,aAAa;gCAChC,CAAC,CAAC,2CAA2C;gCAC7C,CAAC,CAAC,oCAAoC,kEAI3C,EAAC;;;;KACH;IACH,iBAAC;AAAD,CAAC,AA/SD,IA+SC"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Page } from 'playwright-core';
|
|
2
|
-
import type { RunOptions, AxeResults, ContextObject, CrossTreeSelector, PartialResult, SerialContextObject } from 'axe-core';
|
|
3
|
-
export declare type PartialResults = PartialResult | null;
|
|
4
|
-
export interface AnalyzePageParams {
|
|
5
|
-
context: SerialContextObject;
|
|
6
|
-
options: RunOptions;
|
|
7
|
-
}
|
|
8
|
-
export interface AxePlaywrightParams {
|
|
9
|
-
page: Page;
|
|
10
|
-
axeSource?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface AnalyzePageResponse {
|
|
13
|
-
results: AxeResults;
|
|
14
|
-
error: string | null;
|
|
15
|
-
}
|
|
16
|
-
export interface GetFrameContextsParams {
|
|
17
|
-
context: ContextObject;
|
|
18
|
-
}
|
|
19
|
-
export interface ShadowSelectParams {
|
|
20
|
-
frameSelector: CrossTreeSelector;
|
|
21
|
-
}
|
|
22
|
-
export interface RunPartialParams {
|
|
23
|
-
context: ContextObject;
|
|
24
|
-
options: RunOptions;
|
|
25
|
-
}
|
|
26
|
-
export interface FinishRunParams {
|
|
27
|
-
options: RunOptions;
|
|
28
|
-
}
|
package/dist/types.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/utils.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { SerialContextObject, SerialSelectorList } from 'axe-core';
|
|
2
|
-
import type { AnalyzePageParams, AnalyzePageResponse } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Get running context
|
|
5
|
-
* @param Array include
|
|
6
|
-
* @param Array exclude
|
|
7
|
-
* @returns SerialContextObject
|
|
8
|
-
*/
|
|
9
|
-
export declare const normalizeContext: (includes: SerialSelectorList, excludes: SerialSelectorList) => SerialContextObject;
|
|
10
|
-
/**
|
|
11
|
-
* Analyze the page.
|
|
12
|
-
* @param AnalyzePageParams analyzeContext
|
|
13
|
-
* @returns Promise<AnalyzePageResponse>
|
|
14
|
-
*/
|
|
15
|
-
export declare const analyzePage: ({ context, options }: AnalyzePageParams) => Promise<AnalyzePageResponse>;
|
package/dist/utils.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.analyzePage = exports.normalizeContext = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Get running context
|
|
6
|
-
* @param Array include
|
|
7
|
-
* @param Array exclude
|
|
8
|
-
* @returns SerialContextObject
|
|
9
|
-
*/
|
|
10
|
-
var normalizeContext = function (includes, excludes) {
|
|
11
|
-
var _a;
|
|
12
|
-
var base = {
|
|
13
|
-
exclude: [],
|
|
14
|
-
include: []
|
|
15
|
-
};
|
|
16
|
-
if (excludes.length && Array.isArray(base.exclude)) {
|
|
17
|
-
(_a = base.exclude).push.apply(_a, excludes);
|
|
18
|
-
}
|
|
19
|
-
if (includes.length) {
|
|
20
|
-
base.include = includes;
|
|
21
|
-
}
|
|
22
|
-
return base;
|
|
23
|
-
};
|
|
24
|
-
exports.normalizeContext = normalizeContext;
|
|
25
|
-
/**
|
|
26
|
-
* Analyze the page.
|
|
27
|
-
* @param AnalyzePageParams analyzeContext
|
|
28
|
-
* @returns Promise<AnalyzePageResponse>
|
|
29
|
-
*/
|
|
30
|
-
var analyzePage = function (_a) {
|
|
31
|
-
var context = _a.context, options = _a.options;
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
-
var axeCore = window.axe;
|
|
34
|
-
// Run axe-core
|
|
35
|
-
return axeCore
|
|
36
|
-
.run(context || document, options || {})
|
|
37
|
-
.then(function (results) {
|
|
38
|
-
return { error: null, results: results };
|
|
39
|
-
})
|
|
40
|
-
.catch(function (err) {
|
|
41
|
-
return { error: err.message, results: null };
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
exports.analyzePage = analyzePage;
|
|
45
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAOA;;;;;GAKG;AAEI,IAAM,gBAAgB,GAAG,UAC9B,QAA4B,EAC5B,QAA4B;;IAE5B,IAAM,IAAI,GAAwB;QAChC,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE;KACZ,CAAC;IACF,IAAI,QAAQ,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;QAClD,CAAA,KAAA,IAAI,CAAC,OAAO,CAAA,CAAC,IAAI,WAAI,QAAQ,EAAE;KAChC;IAED,IAAI,QAAQ,CAAC,MAAM,EAAE;QACnB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;KACzB;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAhBW,QAAA,gBAAgB,oBAgB3B;AAEF;;;;GAIG;AAEI,IAAM,WAAW,GAAG,UAAC,EAGR;QAFlB,OAAO,aAAA,EACP,OAAO,aAAA;IAEP,8DAA8D;IAC9D,IAAM,OAAO,GAAI,MAAc,CAAC,GAAG,CAAC;IAEpC,eAAe;IACf,OAAO,OAAO;SACX,GAAG,CAAC,OAAO,IAAI,QAAQ,EAAE,OAAO,IAAI,EAAE,CAAC;SACvC,IAAI,CAAC,UAAC,OAAmB;QACxB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,SAAA,EAAE,CAAC;IAClC,CAAC,CAAC;SACD,KAAK,CAAC,UAAC,GAAU;QAChB,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAhBW,QAAA,WAAW,eAgBtB"}
|