@axe-core/webdriverjs 4.3.2-alpha.210 → 4.3.3-alpha.219
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/browser.d.ts +3 -3
- package/dist/browser.js +7 -3
- package/dist/browser.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +9 -11
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/src/browser.ts +19 -10
- package/src/index.ts +16 -9
- package/src/types.ts +3 -1
- package/src/utils/index.ts +11 -13
- package/tests/axe-webdriverjs.spec.ts +100 -24
- package/tests/fixtures/context.html +4 -0
- package/tests/fixtures/iframe-one.html +14 -0
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxeResults, ContextObject, FrameContext, RunOptions, Spec
|
|
1
|
+
import { AxeResults, ContextObject, FrameContext, RunOptions, Spec } from 'axe-core';
|
|
2
2
|
import { WebDriver, WebElement } from 'selenium-webdriver';
|
|
3
3
|
declare type FrameContextWeb = FrameContext & {
|
|
4
4
|
frame: WebElement;
|
|
@@ -7,8 +7,8 @@ declare type FrameContextWeb = FrameContext & {
|
|
|
7
7
|
export declare function axeSourceInject(driver: WebDriver, axeSource: string, config: Spec | null): Promise<{
|
|
8
8
|
runPartialSupported: boolean;
|
|
9
9
|
}>;
|
|
10
|
-
export declare function axeRunPartial(driver: WebDriver, context: ContextObject, options: RunOptions): Promise<
|
|
11
|
-
export declare function axeFinishRun(driver: WebDriver, axeSource: string, config: Spec | null, partialResults: Array<
|
|
10
|
+
export declare function axeRunPartial(driver: WebDriver, context: ContextObject, options: RunOptions): Promise<string>;
|
|
11
|
+
export declare function axeFinishRun(driver: WebDriver, axeSource: string, config: Spec | null, partialResults: Array<string>, options: RunOptions): Promise<AxeResults>;
|
|
12
12
|
export declare function axeGetFrameContext(driver: WebDriver, context: ContextObject): Promise<FrameContextWeb[]>;
|
|
13
13
|
export declare function axeRunLegacy(driver: WebDriver, context: ContextObject, options: RunOptions, config: Spec | null): Promise<AxeResults>;
|
|
14
14
|
export {};
|
package/dist/browser.js
CHANGED
|
@@ -10,13 +10,15 @@ function axeSourceInject(driver, axeSource, config) {
|
|
|
10
10
|
}
|
|
11
11
|
exports.axeSourceInject = axeSourceInject;
|
|
12
12
|
function axeRunPartial(driver, context, options) {
|
|
13
|
-
return promisify(driver.executeAsyncScript("\n var callback = arguments[arguments.length - 1];\n var context = " + JSON.stringify(context) + " || document;\n var options = " + JSON.stringify(options) + " || {};\n window.axe.runPartial(context, options).then(callback);\n "));
|
|
13
|
+
return promisify(driver.executeAsyncScript("\n var callback = arguments[arguments.length - 1];\n var context = " + JSON.stringify(context) + " || document;\n var options = " + JSON.stringify(options) + " || {};\n window.axe.runPartial(context, options).then(res => JSON.stringify(res)).then(callback);\n "));
|
|
14
14
|
}
|
|
15
15
|
exports.axeRunPartial = axeRunPartial;
|
|
16
16
|
function axeFinishRun(driver, axeSource, config, partialResults, options) {
|
|
17
17
|
// Inject source and configuration a second time with a mock "this" context,
|
|
18
18
|
// to make it impossible to sniff the global window.axe for results.
|
|
19
|
-
return promisify(driver
|
|
19
|
+
return promisify(driver
|
|
20
|
+
.executeAsyncScript("\n var callback = arguments[arguments.length - 1];\n\n " + axeSource + ";\n window.axe.configure({\n branding: { application: 'webdriverjs' }\n });\n var config = " + JSON.stringify(config) + ";\n if (config) {\n window.axe.configure(config);\n }\n\n var partialResults = " + JSON.stringify(partialResults) + ";\n partialResults = partialResults.map(res => JSON.parse(res));\n var options = " + JSON.stringify(options || {}) + ";\n window.axe.finishRun(partialResults, options).then(res => JSON.stringify(res)).then(callback);\n ")
|
|
21
|
+
.then(function (res) { return JSON.parse(res); }));
|
|
20
22
|
}
|
|
21
23
|
exports.axeFinishRun = axeFinishRun;
|
|
22
24
|
function axeGetFrameContext(driver, context) {
|
|
@@ -26,7 +28,9 @@ exports.axeGetFrameContext = axeGetFrameContext;
|
|
|
26
28
|
function axeRunLegacy(driver, context, options, config) {
|
|
27
29
|
// https://github.com/vercel/pkg/issues/676
|
|
28
30
|
// we need to pass a string vs a function so we manually stringified the function
|
|
29
|
-
return promisify(driver
|
|
31
|
+
return promisify(driver
|
|
32
|
+
.executeAsyncScript("\n var callback = arguments[arguments.length - 1];\n var context = " + JSON.stringify(context) + " || document;\n var options = " + JSON.stringify(options) + " || {};\n var config = " + JSON.stringify(config) + " || null;\n if (config) {\n window.axe.configure(config);\n }\n window.axe.run(context, options).then(res => JSON.stringify(res)).then(callback);\n ")
|
|
33
|
+
.then(function (res) { return JSON.parse(res); }));
|
|
30
34
|
}
|
|
31
35
|
exports.axeRunLegacy = axeRunLegacy;
|
|
32
36
|
/**
|
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":";;;AAeA,2CAA2C;AAC3C,iFAAiF;AACjF,4EAA4E;AAC5E,2CAA2C;AAE3C,SAAgB,eAAe,CAC7B,MAAiB,EACjB,SAAiB,EACjB,MAAmB;IAEnB,OAAO,SAAS,CACd,MAAM,CAAC,aAAa,CAAmC,aACnD,SAAS,yHAII,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,yMAMtC,CAAC,CACH,CAAC;AACJ,CAAC;AAnBD,0CAmBC;AAED,SAAgB,aAAa,CAC3B,MAAiB,EACjB,OAAsB,EACtB,OAAmB;IAEnB,OAAO,SAAS,CACd,MAAM,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":";;;AAeA,2CAA2C;AAC3C,iFAAiF;AACjF,4EAA4E;AAC5E,2CAA2C;AAE3C,SAAgB,eAAe,CAC7B,MAAiB,EACjB,SAAiB,EACjB,MAAmB;IAEnB,OA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AAC,OAAO,CAAC,2CACvB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,oCACxB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,kLAKtC,CACE;SACA,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAf,CAAe,CAAC,CAChC,CAAC;AACJ,CAAC;AAxBD,oCAwBC;AAED;;GAEG;AACH,SAAS,SAAS,CAAI,QAAoB;IACxC,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QACjC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WebDriver } from 'selenium-webdriver';
|
|
2
2
|
import { RunOptions, Spec, AxeResults } from 'axe-core';
|
|
3
|
-
import { CallbackFunction, BuilderOptions } from './types';
|
|
3
|
+
import { CallbackFunction, BuilderOptions, Selector } from './types';
|
|
4
4
|
declare class AxeBuilder {
|
|
5
5
|
private driver;
|
|
6
6
|
private axeSource;
|
|
@@ -15,12 +15,12 @@ declare class AxeBuilder {
|
|
|
15
15
|
* Selector to include in analysis.
|
|
16
16
|
* This may be called any number of times.
|
|
17
17
|
*/
|
|
18
|
-
include(selector:
|
|
18
|
+
include(selector: Selector): this;
|
|
19
19
|
/**
|
|
20
20
|
* Selector to exclude in analysis.
|
|
21
21
|
* This may be called any number of times.
|
|
22
22
|
*/
|
|
23
|
-
exclude(selector:
|
|
23
|
+
exclude(selector: Selector): this;
|
|
24
24
|
/**
|
|
25
25
|
* Set options to be passed into axe-core
|
|
26
26
|
*/
|
package/dist/index.js
CHANGED
|
@@ -68,6 +68,7 @@ var AxeBuilder = /** @class */ (function () {
|
|
|
68
68
|
* This may be called any number of times.
|
|
69
69
|
*/
|
|
70
70
|
AxeBuilder.prototype.include = function (selector) {
|
|
71
|
+
selector = Array.isArray(selector) ? selector : [selector];
|
|
71
72
|
this.includes.push(selector);
|
|
72
73
|
return this;
|
|
73
74
|
};
|
|
@@ -76,6 +77,7 @@ var AxeBuilder = /** @class */ (function () {
|
|
|
76
77
|
* This may be called any number of times.
|
|
77
78
|
*/
|
|
78
79
|
AxeBuilder.prototype.exclude = function (selector) {
|
|
80
|
+
selector = Array.isArray(selector) ? selector : [selector];
|
|
79
81
|
this.excludes.push(selector);
|
|
80
82
|
return this;
|
|
81
83
|
};
|
|
@@ -288,7 +290,7 @@ var AxeBuilder = /** @class */ (function () {
|
|
|
288
290
|
_f.sent();
|
|
289
291
|
_f.label = 12;
|
|
290
292
|
case 12:
|
|
291
|
-
partials.push(null);
|
|
293
|
+
partials.push('null');
|
|
292
294
|
return [3 /*break*/, 13];
|
|
293
295
|
case 13:
|
|
294
296
|
_i++;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qCAAkC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qCAAkC;AAOlC,uCAAiD;AACjD,+CAAyC;AACzC,qCAMmB;AACnB,+BAAiC;AAEjC;IAUE,oBACE,MAAiB,EACjB,SAAyB,EACzB,cAA+B;QALzB,eAAU,GAAG,KAAK,CAAC;QAOzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,iBAAM,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QAC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AAC,GAAG,CAAC,aAAa,CAAC,EAAA;;wBAA/B,SAA+B,CAAC;;;;wBAEhC,MAAM,IAAI,KAAK,CACb,iFAA+E,OAAO,CACvF,CAAC;4BAGQ,qBAAM,IAAA,sBAAY,EAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAA;;wBAArE,GAAG,GAAG,SAA+D;wBAC3E,qBAAM,MAAM,CAAC,KAAK,EAAE,EAAA;;wBAApB,SAAoB,CAAC;wBACrB,qBAAM,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAA;;wBAAnC,SAAmC,CAAC;wBACpC,sBAAO,GAAG,EAAC;;;;KACZ;IACH,iBAAC;AAAD,CAAC,AAtPD,IAsPC;AAED,OAAO,GAAG,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC;AAEtC,kBAAe,UAAU,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WebDriver } from 'selenium-webdriver';
|
|
2
|
-
import type { Spec, AxeResults } from 'axe-core';
|
|
2
|
+
import type { Spec, AxeResults, BaseSelector } from 'axe-core';
|
|
3
3
|
import * as axe from 'axe-core';
|
|
4
4
|
export interface Options {
|
|
5
5
|
driver: WebDriver;
|
|
@@ -16,3 +16,4 @@ export interface AxeInjectorParams extends Options {
|
|
|
16
16
|
export declare type CallbackFunction = (error: string | null, results: AxeResults | null) => void;
|
|
17
17
|
export declare type InjectCallback = (err?: Error) => void;
|
|
18
18
|
export declare type PartialResults = Parameters<typeof axe.finishRun>[0];
|
|
19
|
+
export declare type Selector = BaseSelector | BaseSelector[];
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ContextObject } from 'axe-core';
|
|
2
|
+
import { Selector } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Get running context
|
|
4
5
|
*/
|
|
5
|
-
export declare const normalizeContext: (include:
|
|
6
|
+
export declare const normalizeContext: (include: Selector[], exclude: Selector[]) => ContextObject;
|
package/dist/utils/index.js
CHANGED
|
@@ -5,19 +5,17 @@ exports.normalizeContext = void 0;
|
|
|
5
5
|
* Get running context
|
|
6
6
|
*/
|
|
7
7
|
var normalizeContext = function (include, exclude) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
var _a;
|
|
9
|
+
var base = {
|
|
10
|
+
exclude: []
|
|
11
|
+
};
|
|
12
|
+
if (exclude.length && Array.isArray(base.exclude)) {
|
|
13
|
+
(_a = base.exclude).push.apply(_a, exclude);
|
|
13
14
|
}
|
|
14
|
-
if (
|
|
15
|
-
|
|
15
|
+
if (include.length) {
|
|
16
|
+
base.include = include;
|
|
16
17
|
}
|
|
17
|
-
return
|
|
18
|
-
include: include,
|
|
19
|
-
exclude: exclude
|
|
20
|
-
};
|
|
18
|
+
return base;
|
|
21
19
|
};
|
|
22
20
|
exports.normalizeContext = normalizeContext;
|
|
23
21
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACI,IAAM,gBAAgB,GAAG,UAC9B,OAAmB,EACnB,OAAmB;;IAEnB,IAAM,IAAI,GAAkB;QAC1B,OAAO,EAAE,EAAE;KACZ,CAAC;IACF,IAAI,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;QACjD,CAAA,KAAA,IAAI,CAAC,OAAO,CAAA,CAAC,IAAI,WAAI,OAAO,EAAE;KAC/B;IACD,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;KACxB;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAdW,QAAA,gBAAgB,oBAc3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axe-core/webdriverjs",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.3-alpha.219+c7c50fb",
|
|
4
4
|
"description": "Provides a method to inject and analyze web pages using axe",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"axe-test-fixtures": "github:dequelabs/axe-test-fixtures#v1",
|
|
67
67
|
"chai": "^4.3.0",
|
|
68
68
|
"chaimocha": "^1.10.0",
|
|
69
|
-
"chromedriver": "^
|
|
69
|
+
"chromedriver": "^96.0.0",
|
|
70
70
|
"delay": "^5.0.0",
|
|
71
71
|
"express": "^4.17.1",
|
|
72
72
|
"http-server": "^0.12.3",
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"functions": 85,
|
|
106
106
|
"lines": 85
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "c7c50fbe6ba91c51c3693ac1220fbd6470532a88"
|
|
109
109
|
}
|
package/src/browser.ts
CHANGED
|
@@ -43,13 +43,13 @@ export function axeRunPartial(
|
|
|
43
43
|
driver: WebDriver,
|
|
44
44
|
context: ContextObject,
|
|
45
45
|
options: RunOptions
|
|
46
|
-
): Promise<
|
|
46
|
+
): Promise<string> {
|
|
47
47
|
return promisify(
|
|
48
|
-
driver.executeAsyncScript<
|
|
48
|
+
driver.executeAsyncScript<string>(`
|
|
49
49
|
var callback = arguments[arguments.length - 1];
|
|
50
50
|
var context = ${JSON.stringify(context)} || document;
|
|
51
51
|
var options = ${JSON.stringify(options)} || {};
|
|
52
|
-
window.axe.runPartial(context, options).then(callback);
|
|
52
|
+
window.axe.runPartial(context, options).then(res => JSON.stringify(res)).then(callback);
|
|
53
53
|
`)
|
|
54
54
|
);
|
|
55
55
|
}
|
|
@@ -58,13 +58,15 @@ export function axeFinishRun(
|
|
|
58
58
|
driver: WebDriver,
|
|
59
59
|
axeSource: string,
|
|
60
60
|
config: Spec | null,
|
|
61
|
-
partialResults: Array<
|
|
61
|
+
partialResults: Array<string>,
|
|
62
62
|
options: RunOptions
|
|
63
63
|
): Promise<AxeResults> {
|
|
64
64
|
// Inject source and configuration a second time with a mock "this" context,
|
|
65
65
|
// to make it impossible to sniff the global window.axe for results.
|
|
66
66
|
return promisify(
|
|
67
|
-
driver
|
|
67
|
+
driver
|
|
68
|
+
.executeAsyncScript<string>(
|
|
69
|
+
`
|
|
68
70
|
var callback = arguments[arguments.length - 1];
|
|
69
71
|
|
|
70
72
|
${axeSource};
|
|
@@ -77,9 +79,12 @@ export function axeFinishRun(
|
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
var partialResults = ${JSON.stringify(partialResults)};
|
|
82
|
+
partialResults = partialResults.map(res => JSON.parse(res));
|
|
80
83
|
var options = ${JSON.stringify(options || {})};
|
|
81
|
-
window.axe.finishRun(partialResults, options).then(callback);
|
|
82
|
-
`
|
|
84
|
+
window.axe.finishRun(partialResults, options).then(res => JSON.stringify(res)).then(callback);
|
|
85
|
+
`
|
|
86
|
+
)
|
|
87
|
+
.then(res => JSON.parse(res))
|
|
83
88
|
);
|
|
84
89
|
}
|
|
85
90
|
|
|
@@ -110,7 +115,9 @@ export function axeRunLegacy(
|
|
|
110
115
|
// https://github.com/vercel/pkg/issues/676
|
|
111
116
|
// we need to pass a string vs a function so we manually stringified the function
|
|
112
117
|
return promisify(
|
|
113
|
-
driver
|
|
118
|
+
driver
|
|
119
|
+
.executeAsyncScript<string>(
|
|
120
|
+
`
|
|
114
121
|
var callback = arguments[arguments.length - 1];
|
|
115
122
|
var context = ${JSON.stringify(context)} || document;
|
|
116
123
|
var options = ${JSON.stringify(options)} || {};
|
|
@@ -118,8 +125,10 @@ export function axeRunLegacy(
|
|
|
118
125
|
if (config) {
|
|
119
126
|
window.axe.configure(config);
|
|
120
127
|
}
|
|
121
|
-
window.axe.run(context, options).then(callback);
|
|
122
|
-
`
|
|
128
|
+
window.axe.run(context, options).then(res => JSON.stringify(res)).then(callback);
|
|
129
|
+
`
|
|
130
|
+
)
|
|
131
|
+
.then(res => JSON.parse(res))
|
|
123
132
|
);
|
|
124
133
|
}
|
|
125
134
|
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { WebDriver } from 'selenium-webdriver';
|
|
2
2
|
import { RunOptions, Spec, AxeResults, ContextObject } from 'axe-core';
|
|
3
3
|
import { source } from 'axe-core';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
CallbackFunction,
|
|
6
|
+
BuilderOptions,
|
|
7
|
+
PartialResults,
|
|
8
|
+
Selector
|
|
9
|
+
} from './types';
|
|
5
10
|
import { normalizeContext } from './utils/index';
|
|
6
11
|
import AxeInjector from './axe-injector';
|
|
7
12
|
import {
|
|
@@ -16,8 +21,8 @@ import * as assert from 'assert';
|
|
|
16
21
|
class AxeBuilder {
|
|
17
22
|
private driver: WebDriver;
|
|
18
23
|
private axeSource: string;
|
|
19
|
-
private includes:
|
|
20
|
-
private excludes:
|
|
24
|
+
private includes: Selector[];
|
|
25
|
+
private excludes: Selector[];
|
|
21
26
|
private option: RunOptions;
|
|
22
27
|
private config: Spec | null;
|
|
23
28
|
private builderOptions: BuilderOptions;
|
|
@@ -41,7 +46,8 @@ class AxeBuilder {
|
|
|
41
46
|
* Selector to include in analysis.
|
|
42
47
|
* This may be called any number of times.
|
|
43
48
|
*/
|
|
44
|
-
public include(selector:
|
|
49
|
+
public include(selector: Selector): this {
|
|
50
|
+
selector = Array.isArray(selector) ? selector : [selector];
|
|
45
51
|
this.includes.push(selector);
|
|
46
52
|
return this;
|
|
47
53
|
}
|
|
@@ -50,7 +56,8 @@ class AxeBuilder {
|
|
|
50
56
|
* Selector to exclude in analysis.
|
|
51
57
|
* This may be called any number of times.
|
|
52
58
|
*/
|
|
53
|
-
public exclude(selector:
|
|
59
|
+
public exclude(selector: Selector): this {
|
|
60
|
+
selector = Array.isArray(selector) ? selector : [selector];
|
|
54
61
|
this.excludes.push(selector);
|
|
55
62
|
return this;
|
|
56
63
|
}
|
|
@@ -205,13 +212,13 @@ class AxeBuilder {
|
|
|
205
212
|
private async runPartialRecursive(
|
|
206
213
|
context: ContextObject,
|
|
207
214
|
initiator = false
|
|
208
|
-
): Promise<
|
|
215
|
+
): Promise<string[]> {
|
|
209
216
|
if (!initiator) {
|
|
210
217
|
await axeSourceInject(this.driver, this.axeSource, this.config);
|
|
211
218
|
}
|
|
212
219
|
// IMPORTANT: axeGetFrameContext MUST be called before axeRunPartial
|
|
213
220
|
const frameContexts = await axeGetFrameContext(this.driver, context);
|
|
214
|
-
const partials:
|
|
221
|
+
const partials: string[] = [
|
|
215
222
|
await axeRunPartial(this.driver, context, this.option)
|
|
216
223
|
];
|
|
217
224
|
|
|
@@ -227,7 +234,7 @@ class AxeBuilder {
|
|
|
227
234
|
if (switchedFrame) {
|
|
228
235
|
await this.driver.switchTo().parentFrame();
|
|
229
236
|
}
|
|
230
|
-
partials.push(null);
|
|
237
|
+
partials.push('null');
|
|
231
238
|
}
|
|
232
239
|
}
|
|
233
240
|
return partials;
|
|
@@ -236,7 +243,7 @@ class AxeBuilder {
|
|
|
236
243
|
/**
|
|
237
244
|
* Use axe.finishRun() to turn partial results into actual results
|
|
238
245
|
*/
|
|
239
|
-
private async finishRun(partials:
|
|
246
|
+
private async finishRun(partials: string[]): Promise<AxeResults> {
|
|
240
247
|
const { driver, axeSource, config, option } = this;
|
|
241
248
|
|
|
242
249
|
const win = await driver.getWindowHandle();
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WebDriver } from 'selenium-webdriver';
|
|
2
|
-
import type { Spec, AxeResults } from 'axe-core';
|
|
2
|
+
import type { Spec, AxeResults, BaseSelector } from 'axe-core';
|
|
3
3
|
import * as axe from 'axe-core';
|
|
4
4
|
|
|
5
5
|
export interface Options {
|
|
@@ -25,3 +25,5 @@ export type CallbackFunction = (
|
|
|
25
25
|
export type InjectCallback = (err?: Error) => void;
|
|
26
26
|
|
|
27
27
|
export type PartialResults = Parameters<typeof axe.finishRun>[0];
|
|
28
|
+
|
|
29
|
+
export type Selector = BaseSelector | BaseSelector[];
|
package/src/utils/index.ts
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import type { ContextObject } from 'axe-core';
|
|
2
|
+
import { Selector } from '../types';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Get running context
|
|
5
6
|
*/
|
|
6
7
|
export const normalizeContext = (
|
|
7
|
-
include:
|
|
8
|
-
exclude:
|
|
8
|
+
include: Selector[],
|
|
9
|
+
exclude: Selector[]
|
|
9
10
|
): ContextObject => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const base: ContextObject = {
|
|
12
|
+
exclude: []
|
|
13
|
+
};
|
|
14
|
+
if (exclude.length && Array.isArray(base.exclude)) {
|
|
15
|
+
base.exclude.push(...exclude);
|
|
15
16
|
}
|
|
16
|
-
if (
|
|
17
|
-
|
|
17
|
+
if (include.length) {
|
|
18
|
+
base.include = include;
|
|
18
19
|
}
|
|
19
|
-
return
|
|
20
|
-
include,
|
|
21
|
-
exclude
|
|
22
|
-
};
|
|
20
|
+
return base;
|
|
23
21
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'mocha';
|
|
2
|
-
import { Spec } from 'axe-core';
|
|
2
|
+
import { AxeResults, Spec } from 'axe-core';
|
|
3
3
|
import { WebDriver } from 'selenium-webdriver';
|
|
4
4
|
import * as express from 'express';
|
|
5
5
|
import * as chromedriver from 'chromedriver';
|
|
@@ -11,6 +11,7 @@ import * as fs from 'fs';
|
|
|
11
11
|
import { Server, createServer } from 'http';
|
|
12
12
|
import { Webdriver, connectToChromeDriver } from './test-utils';
|
|
13
13
|
import AxeBuilder from '../src';
|
|
14
|
+
import { axeRunPartial } from '../src/browser';
|
|
14
15
|
const dylangConfig = require('./fixtures/external/dylang-config.json') as Spec;
|
|
15
16
|
|
|
16
17
|
describe('@axe-core/webdriverjs', () => {
|
|
@@ -68,6 +69,16 @@ describe('@axe-core/webdriverjs', () => {
|
|
|
68
69
|
assert.isArray(results.inapplicable);
|
|
69
70
|
});
|
|
70
71
|
|
|
72
|
+
it('handles undefineds', async () => {
|
|
73
|
+
await driver.get(`${addr}/external/index.html`);
|
|
74
|
+
const results = await new AxeBuilder(driver).analyze();
|
|
75
|
+
assert.isNotNull(results);
|
|
76
|
+
assert.isArray(results.violations);
|
|
77
|
+
assert.isArray(results.incomplete);
|
|
78
|
+
assert.isArray(results.passes);
|
|
79
|
+
assert.isArray(results.inapplicable);
|
|
80
|
+
});
|
|
81
|
+
|
|
71
82
|
it('returns correct results metadata', async () => {
|
|
72
83
|
await driver.get(`${addr}/index.html`);
|
|
73
84
|
const results = await new AxeBuilder(driver).analyze();
|
|
@@ -393,48 +404,101 @@ describe('@axe-core/webdriverjs', () => {
|
|
|
393
404
|
});
|
|
394
405
|
|
|
395
406
|
describe('include/exclude', () => {
|
|
407
|
+
const flatPassesTargets = (results: AxeResults): string[] => {
|
|
408
|
+
return results.passes
|
|
409
|
+
.reduce((acc, pass) => {
|
|
410
|
+
return acc.concat(pass.nodes as any);
|
|
411
|
+
}, [])
|
|
412
|
+
.reduce((acc, node: any) => {
|
|
413
|
+
return acc.concat(node.target);
|
|
414
|
+
}, []);
|
|
415
|
+
};
|
|
396
416
|
it('with include and exclude', async () => {
|
|
397
|
-
let error: Error | null = null;
|
|
398
417
|
await driver.get(`${addr}/context.html`);
|
|
399
418
|
const builder = new AxeBuilder(driver)
|
|
400
419
|
.include('.include')
|
|
401
420
|
.exclude('.exclude');
|
|
421
|
+
const results = await builder.analyze();
|
|
402
422
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
} catch (e) {
|
|
406
|
-
error = e as Error;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
assert.strictEqual(error, null);
|
|
423
|
+
assert.isTrue(flatPassesTargets(results).includes('.include'));
|
|
424
|
+
assert.isFalse(flatPassesTargets(results).includes('.exclude'));
|
|
410
425
|
});
|
|
411
426
|
|
|
412
427
|
it('with only include', async () => {
|
|
413
|
-
let error: Error | null = null;
|
|
414
428
|
await driver.get(`${addr}/context.html`);
|
|
415
429
|
const builder = new AxeBuilder(driver).include('.include');
|
|
430
|
+
const results = await builder.analyze();
|
|
416
431
|
|
|
417
|
-
|
|
418
|
-
await builder.analyze();
|
|
419
|
-
} catch (e) {
|
|
420
|
-
error = e as Error;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
assert.strictEqual(error, null);
|
|
432
|
+
assert.isTrue(flatPassesTargets(results).includes('.include'));
|
|
424
433
|
});
|
|
425
434
|
|
|
426
435
|
it('with only exclude', async () => {
|
|
427
|
-
let error: Error | null = null;
|
|
428
436
|
await driver.get(`${addr}/context.html`);
|
|
429
437
|
const builder = new AxeBuilder(driver).exclude('.exclude');
|
|
438
|
+
const results = await builder.analyze();
|
|
430
439
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
440
|
+
assert.isFalse(flatPassesTargets(results).includes('.exclude'));
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
it('with chaining only include', async () => {
|
|
444
|
+
await driver.get(`${addr}/context.html`);
|
|
445
|
+
const builder = new AxeBuilder(driver)
|
|
446
|
+
.include('.include')
|
|
447
|
+
.include('.include2');
|
|
448
|
+
const results = await builder.analyze();
|
|
436
449
|
|
|
437
|
-
assert.
|
|
450
|
+
assert.isTrue(flatPassesTargets(results).includes('.include'));
|
|
451
|
+
assert.isTrue(flatPassesTargets(results).includes('.include2'));
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it('with chaining only exclude', async () => {
|
|
455
|
+
await driver.get(`${addr}/context.html`);
|
|
456
|
+
const builder = new AxeBuilder(driver)
|
|
457
|
+
.exclude('.exclude')
|
|
458
|
+
.exclude('.exclude2');
|
|
459
|
+
const results = await builder.analyze();
|
|
460
|
+
|
|
461
|
+
assert.isFalse(flatPassesTargets(results).includes('.exclude'));
|
|
462
|
+
assert.isFalse(flatPassesTargets(results).includes('.exclude2'));
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
it('with chaining include and exclude', async () => {
|
|
466
|
+
await driver.get(`${addr}/context.html`);
|
|
467
|
+
const builder = new AxeBuilder(driver)
|
|
468
|
+
.include('.include')
|
|
469
|
+
.include('.include2')
|
|
470
|
+
.exclude('.exclude')
|
|
471
|
+
.exclude('.exclude2');
|
|
472
|
+
const results = await builder.analyze();
|
|
473
|
+
|
|
474
|
+
assert.isTrue(flatPassesTargets(results).includes('.include'));
|
|
475
|
+
assert.isTrue(flatPassesTargets(results).includes('.include2'));
|
|
476
|
+
assert.isFalse(flatPassesTargets(results).includes('.exclude'));
|
|
477
|
+
assert.isFalse(flatPassesTargets(results).includes('.exclude2'));
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
it('with include and exclude iframe selectors with no violations', async () => {
|
|
481
|
+
await driver.get(`${addr}/context.html`);
|
|
482
|
+
const builder = new AxeBuilder(driver)
|
|
483
|
+
.include(['#ifr-one', 'html'])
|
|
484
|
+
.exclude(['#ifr-one', 'main'])
|
|
485
|
+
.exclude(['#ifr-one', 'img']);
|
|
486
|
+
|
|
487
|
+
const results = await builder.analyze();
|
|
488
|
+
|
|
489
|
+
assert.lengthOf(results.violations, 0);
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
it('with include and exclude iframe selectors with violations', async () => {
|
|
493
|
+
await driver.get(`${addr}/context.html`);
|
|
494
|
+
const builder = new AxeBuilder(driver)
|
|
495
|
+
.include(['#ifr-one', 'html'])
|
|
496
|
+
.exclude(['#ifr-one', 'main']);
|
|
497
|
+
const results = await builder.analyze();
|
|
498
|
+
|
|
499
|
+
assert.lengthOf(results.violations, 2);
|
|
500
|
+
assert.strictEqual(results.violations[0].id, 'image-alt');
|
|
501
|
+
assert.strictEqual(results.violations[1].id, 'region');
|
|
438
502
|
});
|
|
439
503
|
});
|
|
440
504
|
|
|
@@ -539,6 +603,18 @@ describe('@axe-core/webdriverjs', () => {
|
|
|
539
603
|
});
|
|
540
604
|
});
|
|
541
605
|
|
|
606
|
+
describe('browser functions', () => {
|
|
607
|
+
it('serializes results', async () => {
|
|
608
|
+
await driver.get(`${addr}/external/nested-iframes.html`);
|
|
609
|
+
await driver.executeScript(`
|
|
610
|
+
window.axe = {
|
|
611
|
+
runPartial: (c, o) => Promise.resolve({ violations: [], passes: [] })
|
|
612
|
+
};
|
|
613
|
+
`);
|
|
614
|
+
const res = await axeRunPartial(driver, null as any, null as any);
|
|
615
|
+
assert.equal(typeof res, 'string');
|
|
616
|
+
});
|
|
617
|
+
});
|
|
542
618
|
describe('for versions without axe.runPartial', () => {
|
|
543
619
|
let axe403Source: string;
|
|
544
620
|
before(() => {
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
<body>
|
|
7
7
|
<h1>Context Test</h1>
|
|
8
8
|
<div class="include">include me</div>
|
|
9
|
+
<div class="include2">include me two</div>
|
|
9
10
|
<div class="exclude">exclude me</div>
|
|
11
|
+
<div class="exclude2">exclude me two</div>
|
|
12
|
+
|
|
13
|
+
<iframe src="iframe-one.html" id="ifr-one"></iframe>
|
|
10
14
|
</body>
|
|
11
15
|
</html>
|