@axe-core/webdriverjs 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 +10 -3
- package/dist/index.js +511 -347
- package/dist/index.mjs +489 -0
- package/package.json +16 -6
- package/dist/axe-injector.d.ts +0 -36
- package/dist/axe-injector.js +0 -254
- package/dist/axe-injector.js.map +0 -1
- package/dist/browser.d.ts +0 -14
- package/dist/browser.js +0 -59
- package/dist/browser.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts +0 -19
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.js +0 -21
- package/dist/utils/index.js.map +0 -1
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import axe2 from "axe-core";
|
|
3
|
+
|
|
4
|
+
// src/utils/index.ts
|
|
5
|
+
var normalizeContext = (include, exclude) => {
|
|
6
|
+
const base = {
|
|
7
|
+
exclude: []
|
|
8
|
+
};
|
|
9
|
+
if (exclude.length && Array.isArray(base.exclude)) {
|
|
10
|
+
base.exclude.push(...exclude);
|
|
11
|
+
}
|
|
12
|
+
if (include.length) {
|
|
13
|
+
base.include = include;
|
|
14
|
+
}
|
|
15
|
+
return base;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/axe-injector.ts
|
|
19
|
+
import { error } from "selenium-webdriver";
|
|
20
|
+
import axe from "axe-core";
|
|
21
|
+
var { source } = axe;
|
|
22
|
+
var { StaleElementReferenceError } = error;
|
|
23
|
+
var AxeInjectorLegacy = class {
|
|
24
|
+
driver;
|
|
25
|
+
axeSource;
|
|
26
|
+
options;
|
|
27
|
+
config;
|
|
28
|
+
didLogError;
|
|
29
|
+
constructor({
|
|
30
|
+
driver,
|
|
31
|
+
axeSource,
|
|
32
|
+
builderOptions,
|
|
33
|
+
config
|
|
34
|
+
}) {
|
|
35
|
+
this.driver = driver;
|
|
36
|
+
this.axeSource = axeSource || source;
|
|
37
|
+
this.config = config ? JSON.stringify(config) : "";
|
|
38
|
+
this.options = builderOptions || {};
|
|
39
|
+
this.didLogError = false;
|
|
40
|
+
this.options.noSandbox = typeof this.options.noSandbox === "boolean" ? this.options.noSandbox : false;
|
|
41
|
+
this.options.logIframeErrors = typeof this.options.logIframeErrors === "boolean" ? this.options.logIframeErrors : false;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Checks to make sure that the error thrown was not a stale iframe
|
|
45
|
+
* @param {Error} error
|
|
46
|
+
* @returns {void}
|
|
47
|
+
*/
|
|
48
|
+
errorHandler(err) {
|
|
49
|
+
if (this.didLogError) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.didLogError = true;
|
|
53
|
+
let msg;
|
|
54
|
+
if (err instanceof StaleElementReferenceError) {
|
|
55
|
+
msg = "Tried to inject into a removed iframe. This will not affect the analysis of the rest of the page but you might want to ensure the page has finished updating before starting the analysis.";
|
|
56
|
+
} else {
|
|
57
|
+
msg = "Failed to inject axe-core into one of the iframes!";
|
|
58
|
+
}
|
|
59
|
+
if (this.options.logIframeErrors) {
|
|
60
|
+
console.error(msg);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
throw new Error(msg);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get axe-core source and configurations
|
|
67
|
+
* @returns {String}
|
|
68
|
+
*/
|
|
69
|
+
get script() {
|
|
70
|
+
return `
|
|
71
|
+
${this.axeSource}
|
|
72
|
+
${this.config ? `axe.configure(${this.config})` : ""}
|
|
73
|
+
axe.configure({
|
|
74
|
+
branding: { application: 'webdriverjs' }
|
|
75
|
+
})
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Removes the `sandbox` attribute from iFrames
|
|
80
|
+
* @returns {Promise<void>}
|
|
81
|
+
*/
|
|
82
|
+
async sandboxBuster() {
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
this.driver.executeAsyncScript(
|
|
85
|
+
`
|
|
86
|
+
var callback = arguments[arguments.length - 1];
|
|
87
|
+
var iframes = Array.from(
|
|
88
|
+
document.querySelectorAll('iframe[sandbox]')
|
|
89
|
+
);
|
|
90
|
+
var removeSandboxAttr = clone => attr => {
|
|
91
|
+
if (attr.name === 'sandbox') return;
|
|
92
|
+
clone.setAttribute(attr.name, attr.value);
|
|
93
|
+
};
|
|
94
|
+
var replaceSandboxedIframe = iframe => {
|
|
95
|
+
var clone = document.createElement('iframe');
|
|
96
|
+
var promise = new Promise(
|
|
97
|
+
iframeLoaded => (clone.onload = iframeLoaded)
|
|
98
|
+
);
|
|
99
|
+
Array.from(iframe.attributes).forEach(removeSandboxAttr(clone));
|
|
100
|
+
iframe.parentElement.replaceChild(clone, iframe);
|
|
101
|
+
return promise;
|
|
102
|
+
};
|
|
103
|
+
Promise.all(iframes.map(replaceSandboxedIframe)).then(callback);
|
|
104
|
+
`
|
|
105
|
+
).then(() => resolve()).catch((e) => reject(e));
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Injects into the provided `frame` and its child `frames`
|
|
110
|
+
* @param {WebElement[]} framePath
|
|
111
|
+
* @returns {Promise<void>}
|
|
112
|
+
*/
|
|
113
|
+
async handleFrame(framePath) {
|
|
114
|
+
await this.driver.switchTo().defaultContent();
|
|
115
|
+
for (const frame of framePath) {
|
|
116
|
+
await this.driver.switchTo().frame(frame);
|
|
117
|
+
}
|
|
118
|
+
if (this.options.noSandbox) {
|
|
119
|
+
await this.sandboxBuster();
|
|
120
|
+
}
|
|
121
|
+
await this.driver.executeScript(this.script);
|
|
122
|
+
const ifs = await this.driver.findElements({ tagName: "iframe" });
|
|
123
|
+
const fs = await this.driver.findElements({ tagName: "frame" });
|
|
124
|
+
const frames = ifs.concat(fs);
|
|
125
|
+
for (const childFrames of frames) {
|
|
126
|
+
framePath.push(childFrames);
|
|
127
|
+
try {
|
|
128
|
+
await this.handleFrame(framePath);
|
|
129
|
+
} catch (error2) {
|
|
130
|
+
this.errorHandler(error2);
|
|
131
|
+
} finally {
|
|
132
|
+
framePath.pop();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Injects into all frames
|
|
138
|
+
* @returns {Promise<void>}
|
|
139
|
+
*/
|
|
140
|
+
async injectIntoAllFrames() {
|
|
141
|
+
await this.driver.switchTo().defaultContent();
|
|
142
|
+
if (this.options.noSandbox) {
|
|
143
|
+
await this.sandboxBuster();
|
|
144
|
+
}
|
|
145
|
+
await this.driver.executeScript(this.script);
|
|
146
|
+
const ifs = await this.driver.findElements({ tagName: "iframe" });
|
|
147
|
+
const fs = await this.driver.findElements({ tagName: "frame" });
|
|
148
|
+
const frames = ifs.concat(fs);
|
|
149
|
+
for (const childFrame of frames) {
|
|
150
|
+
try {
|
|
151
|
+
await this.handleFrame([childFrame]);
|
|
152
|
+
} catch (err) {
|
|
153
|
+
this.errorHandler(err);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return this.driver.switchTo().defaultContent();
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// src/browser.ts
|
|
161
|
+
function axeSourceInject(driver, axeSource, config) {
|
|
162
|
+
return promisify(
|
|
163
|
+
driver.executeScript(`
|
|
164
|
+
${axeSource};
|
|
165
|
+
window.axe.configure({
|
|
166
|
+
branding: { application: 'webdriverjs' }
|
|
167
|
+
});
|
|
168
|
+
var config = ${JSON.stringify(config)};
|
|
169
|
+
if (config) {
|
|
170
|
+
window.axe.configure(config);
|
|
171
|
+
}
|
|
172
|
+
var runPartial = typeof window.axe.runPartial === 'function';
|
|
173
|
+
return { runPartialSupported: runPartial };
|
|
174
|
+
`)
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
function axeRunPartial(driver, context, options) {
|
|
178
|
+
return promisify(
|
|
179
|
+
driver.executeAsyncScript(`
|
|
180
|
+
var callback = arguments[arguments.length - 1];
|
|
181
|
+
var context = ${JSON.stringify(context)} || document;
|
|
182
|
+
var options = ${JSON.stringify(options)} || {};
|
|
183
|
+
window.axe.runPartial(context, options).then(res => JSON.stringify(res)).then(callback);
|
|
184
|
+
`)
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
function axeFinishRun(driver, axeSource, config, partialResults, options) {
|
|
188
|
+
const sizeLimit = 15e6;
|
|
189
|
+
const partialString = JSON.stringify(partialResults);
|
|
190
|
+
function chunkResults(result) {
|
|
191
|
+
const chunk = JSON.stringify(result.substring(0, sizeLimit));
|
|
192
|
+
return promisify(
|
|
193
|
+
driver.executeScript(
|
|
194
|
+
`
|
|
195
|
+
window.partialResults ??= '';
|
|
196
|
+
window.partialResults += ${chunk};
|
|
197
|
+
`
|
|
198
|
+
)
|
|
199
|
+
).then(() => {
|
|
200
|
+
if (result.length > sizeLimit) {
|
|
201
|
+
return chunkResults(result.substr(sizeLimit));
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return chunkResults(partialString).then(() => {
|
|
206
|
+
return promisify(
|
|
207
|
+
driver.executeAsyncScript(
|
|
208
|
+
`
|
|
209
|
+
var callback = arguments[arguments.length - 1];
|
|
210
|
+
|
|
211
|
+
${axeSource};
|
|
212
|
+
window.axe.configure({
|
|
213
|
+
branding: { application: 'webdriverjs' }
|
|
214
|
+
});
|
|
215
|
+
var config = ${JSON.stringify(config)};
|
|
216
|
+
if (config) {
|
|
217
|
+
window.axe.configure(config);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
var partialResults = JSON.parse(window.partialResults).map(res => JSON.parse(res));
|
|
221
|
+
var options = ${JSON.stringify(options || {})};
|
|
222
|
+
window.axe.finishRun(partialResults, options).then(res => JSON.stringify(res)).then(callback);
|
|
223
|
+
`
|
|
224
|
+
)
|
|
225
|
+
);
|
|
226
|
+
}).then((res) => JSON.parse(res));
|
|
227
|
+
}
|
|
228
|
+
function axeGetFrameContext(driver, context) {
|
|
229
|
+
return promisify(
|
|
230
|
+
driver.executeScript(`
|
|
231
|
+
var context = ${JSON.stringify(context)}
|
|
232
|
+
var frameContexts = window.axe.utils.getFrameContexts(context);
|
|
233
|
+
return frameContexts.map(function (frameContext) {
|
|
234
|
+
return Object.assign(frameContext, {
|
|
235
|
+
href: window.location.href, // For debugging
|
|
236
|
+
frame: axe.utils.shadowSelect(frameContext.frameSelector)
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
`)
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
function axeRunLegacy(driver, context, options, config) {
|
|
243
|
+
return promisify(
|
|
244
|
+
driver.executeAsyncScript(
|
|
245
|
+
`
|
|
246
|
+
var callback = arguments[arguments.length - 1];
|
|
247
|
+
var context = ${JSON.stringify(context)} || document;
|
|
248
|
+
var options = ${JSON.stringify(options)} || {};
|
|
249
|
+
var config = ${JSON.stringify(config)} || null;
|
|
250
|
+
if (config) {
|
|
251
|
+
window.axe.configure(config);
|
|
252
|
+
}
|
|
253
|
+
window.axe.run(context, options).then(res => JSON.stringify(res)).then(callback);
|
|
254
|
+
`
|
|
255
|
+
).then((res) => JSON.parse(res))
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
function promisify(thenable) {
|
|
259
|
+
return new Promise((resolve, reject) => {
|
|
260
|
+
thenable.then(resolve, reject);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// src/index.ts
|
|
265
|
+
import assert from "assert";
|
|
266
|
+
var { source: source2 } = axe2;
|
|
267
|
+
var AxeBuilder = class {
|
|
268
|
+
driver;
|
|
269
|
+
axeSource;
|
|
270
|
+
includes;
|
|
271
|
+
excludes;
|
|
272
|
+
option;
|
|
273
|
+
config;
|
|
274
|
+
builderOptions;
|
|
275
|
+
legacyMode = false;
|
|
276
|
+
errorUrl;
|
|
277
|
+
constructor(driver, axeSource, builderOptions) {
|
|
278
|
+
this.driver = driver;
|
|
279
|
+
this.axeSource = axeSource || source2;
|
|
280
|
+
this.includes = [];
|
|
281
|
+
this.excludes = [];
|
|
282
|
+
this.option = {};
|
|
283
|
+
this.config = null;
|
|
284
|
+
this.builderOptions = builderOptions || {};
|
|
285
|
+
this.errorUrl = "https://github.com/dequelabs/axe-core-npm/blob/develop/packages/webdriverjs/error-handling.md";
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Selector to include in analysis.
|
|
289
|
+
* This may be called any number of times.
|
|
290
|
+
*/
|
|
291
|
+
include(selector) {
|
|
292
|
+
this.includes.push(selector);
|
|
293
|
+
return this;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Selector to exclude in analysis.
|
|
297
|
+
* This may be called any number of times.
|
|
298
|
+
*/
|
|
299
|
+
exclude(selector) {
|
|
300
|
+
this.excludes.push(selector);
|
|
301
|
+
return this;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Set options to be passed into axe-core
|
|
305
|
+
*/
|
|
306
|
+
options(options) {
|
|
307
|
+
this.option = options;
|
|
308
|
+
return this;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Limit analysis to only the specified rules.
|
|
312
|
+
* Cannot be used with `AxeBuilder#withTags`
|
|
313
|
+
*/
|
|
314
|
+
withRules(rules) {
|
|
315
|
+
rules = Array.isArray(rules) ? rules : [rules];
|
|
316
|
+
this.option.runOnly = {
|
|
317
|
+
type: "rule",
|
|
318
|
+
values: rules
|
|
319
|
+
};
|
|
320
|
+
return this;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Limit analysis to only specified tags.
|
|
324
|
+
* Cannot be used with `AxeBuilder#withRules`
|
|
325
|
+
*/
|
|
326
|
+
withTags(tags) {
|
|
327
|
+
tags = Array.isArray(tags) ? tags : [tags];
|
|
328
|
+
this.option.runOnly = {
|
|
329
|
+
type: "tag",
|
|
330
|
+
values: tags
|
|
331
|
+
};
|
|
332
|
+
return this;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Set the list of rules to skip when running an analysis.
|
|
336
|
+
*/
|
|
337
|
+
disableRules(rules) {
|
|
338
|
+
rules = Array.isArray(rules) ? rules : [rules];
|
|
339
|
+
this.option.rules = {};
|
|
340
|
+
for (const rule of rules) {
|
|
341
|
+
this.option.rules[rule] = { enabled: false };
|
|
342
|
+
}
|
|
343
|
+
return this;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Set configuration for `axe-core`.
|
|
347
|
+
* This value is passed directly to `axe.configure()`
|
|
348
|
+
*/
|
|
349
|
+
configure(config) {
|
|
350
|
+
if (typeof config !== "object") {
|
|
351
|
+
throw new Error(
|
|
352
|
+
"AxeBuilder needs an object to configure. See axe-core configure API."
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
this.config = config;
|
|
356
|
+
return this;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Performs an analysis and retrieves results.
|
|
360
|
+
*/
|
|
361
|
+
async analyze(callback) {
|
|
362
|
+
return new Promise((resolve, reject) => {
|
|
363
|
+
return this.analyzePromise().then((results) => {
|
|
364
|
+
callback?.(null, results);
|
|
365
|
+
resolve(results);
|
|
366
|
+
}).catch((err) => {
|
|
367
|
+
if (callback) {
|
|
368
|
+
callback(err, null);
|
|
369
|
+
} else {
|
|
370
|
+
reject(err);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Use frameMessenger with <same_origin_only>
|
|
377
|
+
*
|
|
378
|
+
* This disables use of axe.runPartial() which is called in each frame, and
|
|
379
|
+
* axe.finishRun() which is called in a blank page. This uses axe.run() instead,
|
|
380
|
+
* but with the restriction that cross-origin frames will not be tested.
|
|
381
|
+
*/
|
|
382
|
+
setLegacyMode(legacyMode = true) {
|
|
383
|
+
this.legacyMode = legacyMode;
|
|
384
|
+
return this;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Analyzes the page, returning a promise
|
|
388
|
+
*/
|
|
389
|
+
async analyzePromise() {
|
|
390
|
+
const context = normalizeContext(this.includes, this.excludes);
|
|
391
|
+
await this.driver.switchTo().defaultContent();
|
|
392
|
+
const { runPartialSupported } = await axeSourceInject(
|
|
393
|
+
this.driver,
|
|
394
|
+
this.axeSource,
|
|
395
|
+
this.config
|
|
396
|
+
);
|
|
397
|
+
if (runPartialSupported !== true || this.legacyMode) {
|
|
398
|
+
return this.runLegacy(context);
|
|
399
|
+
}
|
|
400
|
+
const partials = await this.runPartialRecursive(context, true);
|
|
401
|
+
try {
|
|
402
|
+
return await this.finishRun(partials);
|
|
403
|
+
} catch (error2) {
|
|
404
|
+
throw new Error(
|
|
405
|
+
`${error2.message}
|
|
406
|
+
Please check out ${this.errorUrl}`
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Use axe.run() to get results from the page
|
|
412
|
+
*/
|
|
413
|
+
async runLegacy(context) {
|
|
414
|
+
const { driver, axeSource, builderOptions } = this;
|
|
415
|
+
let config = this.config;
|
|
416
|
+
if (!this.legacyMode) {
|
|
417
|
+
config = {
|
|
418
|
+
...config || {},
|
|
419
|
+
allowedOrigins: ["<unsafe_all_origins>"]
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
const injector = new AxeInjectorLegacy({
|
|
423
|
+
driver,
|
|
424
|
+
axeSource,
|
|
425
|
+
config,
|
|
426
|
+
builderOptions
|
|
427
|
+
});
|
|
428
|
+
await injector.injectIntoAllFrames();
|
|
429
|
+
return axeRunLegacy(this.driver, context, this.option, this.config);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Get partial results from the current context and its child frames
|
|
433
|
+
*/
|
|
434
|
+
async runPartialRecursive(context, initiator = false) {
|
|
435
|
+
if (!initiator) {
|
|
436
|
+
await axeSourceInject(this.driver, this.axeSource, this.config);
|
|
437
|
+
}
|
|
438
|
+
const frameContexts = await axeGetFrameContext(this.driver, context);
|
|
439
|
+
const partials = [
|
|
440
|
+
await axeRunPartial(this.driver, context, this.option)
|
|
441
|
+
];
|
|
442
|
+
for (const { frameContext, frameSelector, frame } of frameContexts) {
|
|
443
|
+
let switchedFrame = false;
|
|
444
|
+
try {
|
|
445
|
+
assert(frame, `Expect frame of "${frameSelector}" to be defined`);
|
|
446
|
+
await this.driver.switchTo().frame(frame);
|
|
447
|
+
switchedFrame = true;
|
|
448
|
+
partials.push(...await this.runPartialRecursive(frameContext));
|
|
449
|
+
await this.driver.switchTo().parentFrame();
|
|
450
|
+
} catch {
|
|
451
|
+
if (switchedFrame) {
|
|
452
|
+
await this.driver.switchTo().parentFrame();
|
|
453
|
+
}
|
|
454
|
+
partials.push("null");
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return partials;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Use axe.finishRun() to turn partial results into actual results
|
|
461
|
+
*/
|
|
462
|
+
async finishRun(partials) {
|
|
463
|
+
const { driver, axeSource, config, option } = this;
|
|
464
|
+
const win = await driver.getWindowHandle();
|
|
465
|
+
try {
|
|
466
|
+
await driver.executeScript(`window.open('about:blank')`);
|
|
467
|
+
const handlers = await driver.getAllWindowHandles();
|
|
468
|
+
await driver.switchTo().window(handlers[handlers.length - 1]);
|
|
469
|
+
await driver.get("about:blank");
|
|
470
|
+
} catch (error2) {
|
|
471
|
+
throw new Error(
|
|
472
|
+
`switchTo failed. Are you using updated browser drivers?
|
|
473
|
+
Driver reported:
|
|
474
|
+
${error2}`
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
const res = await axeFinishRun(driver, axeSource, config, partials, option);
|
|
478
|
+
await driver.close();
|
|
479
|
+
await driver.switchTo().window(win);
|
|
480
|
+
return res;
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
if (typeof module === "object") {
|
|
484
|
+
exports = module.exports = AxeBuilder;
|
|
485
|
+
}
|
|
486
|
+
var src_default = AxeBuilder;
|
|
487
|
+
export {
|
|
488
|
+
src_default as default
|
|
489
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axe-core/webdriverjs",
|
|
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
|
{
|
|
@@ -35,12 +35,21 @@
|
|
|
35
35
|
"url": "https://github.com/dequelabs/axe-core-npm.git"
|
|
36
36
|
},
|
|
37
37
|
"license": "MPL-2.0",
|
|
38
|
-
"main": "dist/index.js",
|
|
39
|
-
"
|
|
38
|
+
"main": "./dist/index.js",
|
|
39
|
+
"module": "./dist/index.mjs",
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"exports": {
|
|
42
|
+
".": {
|
|
43
|
+
"import": "./dist/index.mjs",
|
|
44
|
+
"require": "./dist/index.js",
|
|
45
|
+
"types": "./dist/index.d.ts"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
40
48
|
"scripts": {
|
|
41
49
|
"prebuild": "rimraf dist",
|
|
42
|
-
"build": "
|
|
50
|
+
"build": "tsup src/index.ts --dts --format esm,cjs",
|
|
43
51
|
"test": "mocha --timeout 10000 -r ts-node/register './tests/**/*.spec.ts'",
|
|
52
|
+
"test:esm": "node esmTest.mjs",
|
|
44
53
|
"coverage": "nyc npm run test",
|
|
45
54
|
"prepare": "npm run build"
|
|
46
55
|
},
|
|
@@ -69,7 +78,7 @@
|
|
|
69
78
|
"axe-test-fixtures": "github:dequelabs/axe-test-fixtures#v1",
|
|
70
79
|
"chai": "^4.3.6",
|
|
71
80
|
"chaimocha": "^1.10.0",
|
|
72
|
-
"chromedriver": "^
|
|
81
|
+
"chromedriver": "^112.0.0",
|
|
73
82
|
"delay": "^5.0.0",
|
|
74
83
|
"express": "^4.18.2",
|
|
75
84
|
"expresss": "^0.0.0",
|
|
@@ -82,6 +91,7 @@
|
|
|
82
91
|
"sinon": "^14.0.1",
|
|
83
92
|
"test-listen": "^1.1.0",
|
|
84
93
|
"ts-node": "^10.9.1",
|
|
94
|
+
"tsup": "^6.7.0",
|
|
85
95
|
"typescript": "^4.8.4"
|
|
86
96
|
},
|
|
87
97
|
"dependencies": {
|
|
@@ -109,5 +119,5 @@
|
|
|
109
119
|
"functions": 85,
|
|
110
120
|
"lines": 85
|
|
111
121
|
},
|
|
112
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "623da3a516cbf1c7a0a0461b23a8c98f094cc18d"
|
|
113
123
|
}
|
package/dist/axe-injector.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { AxeInjectorParams } from './types';
|
|
2
|
-
export default class AxeInjectorLegacy {
|
|
3
|
-
private driver;
|
|
4
|
-
private axeSource;
|
|
5
|
-
private options;
|
|
6
|
-
private config;
|
|
7
|
-
private didLogError;
|
|
8
|
-
constructor({ driver, axeSource, builderOptions, config }: AxeInjectorParams);
|
|
9
|
-
/**
|
|
10
|
-
* Checks to make sure that the error thrown was not a stale iframe
|
|
11
|
-
* @param {Error} error
|
|
12
|
-
* @returns {void}
|
|
13
|
-
*/
|
|
14
|
-
private errorHandler;
|
|
15
|
-
/**
|
|
16
|
-
* Get axe-core source and configurations
|
|
17
|
-
* @returns {String}
|
|
18
|
-
*/
|
|
19
|
-
private get script();
|
|
20
|
-
/**
|
|
21
|
-
* Removes the `sandbox` attribute from iFrames
|
|
22
|
-
* @returns {Promise<void>}
|
|
23
|
-
*/
|
|
24
|
-
private sandboxBuster;
|
|
25
|
-
/**
|
|
26
|
-
* Injects into the provided `frame` and its child `frames`
|
|
27
|
-
* @param {WebElement[]} framePath
|
|
28
|
-
* @returns {Promise<void>}
|
|
29
|
-
*/
|
|
30
|
-
private handleFrame;
|
|
31
|
-
/**
|
|
32
|
-
* Injects into all frames
|
|
33
|
-
* @returns {Promise<void>}
|
|
34
|
-
*/
|
|
35
|
-
injectIntoAllFrames(): Promise<void>;
|
|
36
|
-
}
|