This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
/
frames.js
97 lines (87 loc) · 2.47 KB
/
frames.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
var runWebdriver = require('../run-webdriver');
var assert = require('chai').assert;
var host = 'localhost';
var AxeBuilder = require('../../lib');
var path = require('path');
var { createServer } = require('http-server');
if (process.env.REMOTE_TESTSERVER_HOST) {
host = process.env.REMOTE_TESTSERVER_HOST;
}
describe('outer-frame.html', function() {
this.timeout(10000);
var driver;
var server;
before(function(done) {
driver = runWebdriver();
driver
.manage()
.timeouts()
.setScriptTimeout(500);
server = createServer({
root: path.resolve(__dirname, '../..'),
cache: -1
});
server.listen(9876, err => {
if (err) {
return done(err);
}
driver
.get('http://' + host + ':9876/test/fixtures/outer-frame.html')
.then(function() {
done();
});
});
});
after(function() {
server.close();
driver.quit();
});
it('should find violations', function(done) {
AxeBuilder(driver)
.withRules('html-lang-valid')
.analyze()
.then(function(results) {
assert.lengthOf(results.violations, 1, 'violations');
assert.equal(results.violations[0].id, 'html-lang-valid');
assert.lengthOf(
results.violations[0].nodes[0].target,
2,
'finds the iframe <html> element'
);
assert.lengthOf(results.passes, 1);
assert.equal(results.passes[0].id, 'html-lang-valid');
assert.lengthOf(
results.passes[0].nodes[0].target,
1,
'main page <html> element'
);
done();
});
});
it('should accept options', function(done) {
AxeBuilder(driver)
.include('body')
.options({ checks: { 'valid-lang': { options: ['bobbert'] } } })
.withRules('html-lang-valid')
.analyze()
.then(function(results) {
assert.lengthOf(results.violations, 0);
assert.lengthOf(results.passes, 1);
done();
});
});
it('should not find violations when the rule is disabled', function(done) {
AxeBuilder(driver)
.options({ rules: { 'html-lang-valid': { enabled: false } } })
.analyze()
.then(function(results) {
results.violations.forEach(function(violation) {
assert.notEqual(violation.id, 'html-lang-valid');
});
results.passes.forEach(function(violation) {
assert.notEqual(violation.id, 'html-lang-valid');
});
done();
});
});
});