@axe-core/webdriverjs 4.3.2 → 4.3.3-alpha.221
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/axe-injector.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -7
- 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 +9 -9
- package/src/axe-injector.ts +2 -2
- package/src/index.ts +15 -6
- package/src/types.ts +3 -1
- package/src/utils/index.ts +11 -13
- package/tests/axe-webdriverjs.spec.ts +79 -26
- package/tests/fixtures/context.html +4 -0
- package/tests/fixtures/iframe-one.html +14 -0
package/dist/axe-injector.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axe-injector.js","sourceRoot":"","sources":["../src/axe-injector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yDAA2C;AAC3C,qCAAkC;AAE1B,IAAA,0BAA0B,GAAK,0BAAK,2BAAV,CAAW;AAE7C;IAME,2BAAY,EAKQ;YAJlB,MAAM,YAAA,EACN,SAAS,eAAA,EACT,cAAc,oBAAA,EACd,MAAM,YAAA;QAEN,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,iBAAM,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,OAAO,GAAG,cAAc,IAAI,EAAE,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAEzB,IAAI,CAAC,OAAO,CAAC,SAAS;YACpB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS;gBAC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,uCAAuC;oBACvC,qFAAqF;oBACrF,qBAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAAA;;wBAF5C,uCAAuC;wBACvC,qFAAqF;wBACrF,SAA4C,CAAC;wBAGjC,qBAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAA;;wBAA3D,GAAG,GAAG,SAAqD;wBACtD,qBAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAA;;wBAAzD,EAAE,GAAG,SAAoD;wBACzD,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;8BAGC,EAAN,iBAAM;;;6BAAN,CAAA,oBAAM,CAAA;wBAApB,UAAU;;;;wBAEjB,qBAAM,IAAI,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC,CAAC,EAAA;;wBAApC,SAAoC,CAAC;;;;wBAErC,IAAI,CAAC,YAAY,CAAC,KAAY,CAAC,CAAC;;;wBAJX,IAAM,CAAA;;;oBAQ/B,kCAAkC;oBAClC,sBAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,cAAc,EAAE,EAAC;;;;KAChD;IACH,wBAAC;AAAD,CAAC,AAxLD,IAwLC"}
|
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
|
};
|
|
@@ -180,11 +182,11 @@ var AxeBuilder = /** @class */ (function () {
|
|
|
180
182
|
return __generator(this, function (_a) {
|
|
181
183
|
switch (_a.label) {
|
|
182
184
|
case 0:
|
|
183
|
-
context = index_1.normalizeContext(this.includes, this.excludes);
|
|
185
|
+
context = (0, index_1.normalizeContext)(this.includes, this.excludes);
|
|
184
186
|
return [4 /*yield*/, this.driver.switchTo().defaultContent()];
|
|
185
187
|
case 1:
|
|
186
188
|
_a.sent();
|
|
187
|
-
return [4 /*yield*/, browser_1.axeSourceInject(this.driver, this.axeSource, this.config)];
|
|
189
|
+
return [4 /*yield*/, (0, browser_1.axeSourceInject)(this.driver, this.axeSource, this.config)];
|
|
188
190
|
case 2:
|
|
189
191
|
runPartialSupported = (_a.sent()).runPartialSupported;
|
|
190
192
|
if (runPartialSupported !== true || this.legacyMode) {
|
|
@@ -229,7 +231,7 @@ var AxeBuilder = /** @class */ (function () {
|
|
|
229
231
|
return [4 /*yield*/, injector.injectIntoAllFrames()];
|
|
230
232
|
case 1:
|
|
231
233
|
_b.sent();
|
|
232
|
-
return [2 /*return*/, browser_1.axeRunLegacy(this.driver, context, this.option, this.config)];
|
|
234
|
+
return [2 /*return*/, (0, browser_1.axeRunLegacy)(this.driver, context, this.option, this.config)];
|
|
233
235
|
}
|
|
234
236
|
});
|
|
235
237
|
});
|
|
@@ -245,14 +247,14 @@ var AxeBuilder = /** @class */ (function () {
|
|
|
245
247
|
switch (_f.label) {
|
|
246
248
|
case 0:
|
|
247
249
|
if (!!initiator) return [3 /*break*/, 2];
|
|
248
|
-
return [4 /*yield*/, browser_1.axeSourceInject(this.driver, this.axeSource, this.config)];
|
|
250
|
+
return [4 /*yield*/, (0, browser_1.axeSourceInject)(this.driver, this.axeSource, this.config)];
|
|
249
251
|
case 1:
|
|
250
252
|
_f.sent();
|
|
251
253
|
_f.label = 2;
|
|
252
|
-
case 2: return [4 /*yield*/, browser_1.axeGetFrameContext(this.driver, context)];
|
|
254
|
+
case 2: return [4 /*yield*/, (0, browser_1.axeGetFrameContext)(this.driver, context)];
|
|
253
255
|
case 3:
|
|
254
256
|
frameContexts = _f.sent();
|
|
255
|
-
return [4 /*yield*/, browser_1.axeRunPartial(this.driver, context, this.option)];
|
|
257
|
+
return [4 /*yield*/, (0, browser_1.axeRunPartial)(this.driver, context, this.option)];
|
|
256
258
|
case 4:
|
|
257
259
|
partials = [
|
|
258
260
|
_f.sent()
|
|
@@ -330,7 +332,7 @@ var AxeBuilder = /** @class */ (function () {
|
|
|
330
332
|
case 7:
|
|
331
333
|
error_2 = _b.sent();
|
|
332
334
|
throw new Error("switchTo failed. Are you using updated browser drivers? \nDriver reported:\n" + error_2);
|
|
333
|
-
case 8: return [4 /*yield*/, browser_1.axeFinishRun(driver, axeSource, config, partials, option)];
|
|
335
|
+
case 8: return [4 /*yield*/, (0, browser_1.axeFinishRun)(driver, axeSource, config, partials, option)];
|
|
334
336
|
case 9:
|
|
335
337
|
res = _b.sent();
|
|
336
338
|
return [4 /*yield*/, driver.close()];
|
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;QACjB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,cAAc,GAAG,cAAc,IAAI,EAAE,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACI,4BAAO,GAAd,UAAe,QAAkB;QAC/B,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QAC3D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,4BAAO,GAAd,UAAe,QAAk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C,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.221+23b848c",
|
|
4
4
|
"description": "Provides a method to inject and analyze web pages using axe",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
@@ -54,13 +54,13 @@
|
|
|
54
54
|
"webdriverjs"
|
|
55
55
|
],
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@types/chai": "^4.2.
|
|
57
|
+
"@types/chai": "^4.2.22",
|
|
58
58
|
"@types/chromedriver": "^81.0.0",
|
|
59
59
|
"@types/express": "^4.17.13",
|
|
60
60
|
"@types/http-server": "^0.10.1",
|
|
61
61
|
"@types/mocha": "^8.2.3",
|
|
62
|
-
"@types/node": "^14.17.
|
|
63
|
-
"@types/selenium-webdriver": "^4.0.
|
|
62
|
+
"@types/node": "^14.17.32",
|
|
63
|
+
"@types/selenium-webdriver": "^4.0.16",
|
|
64
64
|
"@types/sinon": "^9.0.10",
|
|
65
65
|
"@types/test-listen": "^1.1.0",
|
|
66
66
|
"axe-test-fixtures": "github:dequelabs/axe-test-fixtures#v1",
|
|
@@ -70,18 +70,18 @@
|
|
|
70
70
|
"delay": "^5.0.0",
|
|
71
71
|
"express": "^4.17.1",
|
|
72
72
|
"http-server": "^0.12.3",
|
|
73
|
-
"is-ci": "^3.0.
|
|
73
|
+
"is-ci": "^3.0.1",
|
|
74
74
|
"mocha": "^8.4.0",
|
|
75
75
|
"nyc": "^15.1.0",
|
|
76
76
|
"rimraf": "^3.0.2",
|
|
77
|
-
"selenium-webdriver": "^4.0.0
|
|
77
|
+
"selenium-webdriver": "^4.0.0",
|
|
78
78
|
"sinon": "^9.2.4",
|
|
79
79
|
"test-listen": "^1.1.0",
|
|
80
80
|
"ts-node": "^9.1.1",
|
|
81
|
-
"typescript": "^4.
|
|
81
|
+
"typescript": "^4.4.4"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"axe-core": "^4.3.
|
|
84
|
+
"axe-core": "^4.3.5"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"selenium-webdriver": ">3.0.0-beta || >=2.53.1 || >4.0.0-alpha"
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"functions": 85,
|
|
106
106
|
"lines": 85
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "23b848c8959046014d9620a46f18088d5cfa8f3b"
|
|
109
109
|
}
|
package/src/axe-injector.ts
CHANGED
|
@@ -146,7 +146,7 @@ export default class AxeInjectorLegacy {
|
|
|
146
146
|
try {
|
|
147
147
|
await this.handleFrame(framePath);
|
|
148
148
|
} catch (error) {
|
|
149
|
-
this.errorHandler(error);
|
|
149
|
+
this.errorHandler(error as Error);
|
|
150
150
|
} finally {
|
|
151
151
|
framePath.pop();
|
|
152
152
|
}
|
|
@@ -181,7 +181,7 @@ export default class AxeInjectorLegacy {
|
|
|
181
181
|
try {
|
|
182
182
|
await this.handleFrame([childFrame]);
|
|
183
183
|
} catch (err) {
|
|
184
|
-
this.errorHandler(err);
|
|
184
|
+
this.errorHandler(err as Error);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
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
|
}
|
|
@@ -170,7 +177,9 @@ class AxeBuilder {
|
|
|
170
177
|
return await this.finishRun(partials);
|
|
171
178
|
} catch (error) {
|
|
172
179
|
throw new Error(
|
|
173
|
-
`${
|
|
180
|
+
`${
|
|
181
|
+
(error as Error).message
|
|
182
|
+
}\n Please check out https://github.com/dequelabs/axe-core-npm/blob/develop/packages/webdriverjs/error-handling.md`
|
|
174
183
|
);
|
|
175
184
|
}
|
|
176
185
|
}
|
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';
|
|
@@ -404,48 +404,101 @@ describe('@axe-core/webdriverjs', () => {
|
|
|
404
404
|
});
|
|
405
405
|
|
|
406
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
|
+
};
|
|
407
416
|
it('with include and exclude', async () => {
|
|
408
|
-
let error: Error | null = null;
|
|
409
417
|
await driver.get(`${addr}/context.html`);
|
|
410
418
|
const builder = new AxeBuilder(driver)
|
|
411
419
|
.include('.include')
|
|
412
420
|
.exclude('.exclude');
|
|
421
|
+
const results = await builder.analyze();
|
|
413
422
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
} catch (e) {
|
|
417
|
-
error = e;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
assert.strictEqual(error, null);
|
|
423
|
+
assert.isTrue(flatPassesTargets(results).includes('.include'));
|
|
424
|
+
assert.isFalse(flatPassesTargets(results).includes('.exclude'));
|
|
421
425
|
});
|
|
422
426
|
|
|
423
427
|
it('with only include', async () => {
|
|
424
|
-
let error: Error | null = null;
|
|
425
428
|
await driver.get(`${addr}/context.html`);
|
|
426
429
|
const builder = new AxeBuilder(driver).include('.include');
|
|
430
|
+
const results = await builder.analyze();
|
|
427
431
|
|
|
428
|
-
|
|
429
|
-
await builder.analyze();
|
|
430
|
-
} catch (e) {
|
|
431
|
-
error = e;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
assert.strictEqual(error, null);
|
|
432
|
+
assert.isTrue(flatPassesTargets(results).includes('.include'));
|
|
435
433
|
});
|
|
436
434
|
|
|
437
435
|
it('with only exclude', async () => {
|
|
438
|
-
let error: Error | null = null;
|
|
439
436
|
await driver.get(`${addr}/context.html`);
|
|
440
437
|
const builder = new AxeBuilder(driver).exclude('.exclude');
|
|
438
|
+
const results = await builder.analyze();
|
|
441
439
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}
|
|
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();
|
|
449
|
+
|
|
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();
|
|
447
498
|
|
|
448
|
-
assert.
|
|
499
|
+
assert.lengthOf(results.violations, 2);
|
|
500
|
+
assert.strictEqual(results.violations[0].id, 'image-alt');
|
|
501
|
+
assert.strictEqual(results.violations[1].id, 'region');
|
|
449
502
|
});
|
|
450
503
|
});
|
|
451
504
|
|
|
@@ -495,7 +548,7 @@ describe('@axe-core/webdriverjs', () => {
|
|
|
495
548
|
await new AxeBuilder(driver, source).analyze();
|
|
496
549
|
assert.fail('Should have thrown');
|
|
497
550
|
} catch (err) {
|
|
498
|
-
assert.match(err.message, /switchTo failed./);
|
|
551
|
+
assert.match((err as Error).message, /switchTo failed./);
|
|
499
552
|
}
|
|
500
553
|
});
|
|
501
554
|
|
|
@@ -507,7 +560,7 @@ describe('@axe-core/webdriverjs', () => {
|
|
|
507
560
|
await new AxeBuilder(driver, source).analyze();
|
|
508
561
|
assert.fail('Should have thrown');
|
|
509
562
|
} catch (err) {
|
|
510
|
-
assert.match(err.message, /Please check out/);
|
|
563
|
+
assert.match((err as Error).message, /Please check out/);
|
|
511
564
|
}
|
|
512
565
|
});
|
|
513
566
|
});
|
|
@@ -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>
|