Skip to content

Commit 0b0240f

Browse files
WilcoFiersdylanb
authored andcommitted
fix: Ensure all tests pass in Chrome
1 parent 34137e5 commit 0b0240f

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

build/tasks/test-webdriver.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ module.exports = function (grunt) {
3535
/**
3636
* Test each URL
3737
*/
38-
function runTestUrls(driver, urls) {
38+
function runTestUrls(driver, urls, errors) {
3939
var url = urls.shift();
40-
var errors = [];
40+
errors = errors || [];
4141

4242
// Give each page enough time
43-
driver.manage().timeouts().setScriptTimeout(600);
43+
driver.manage().timeouts().setScriptTimeout(60000);
4444

4545
return driver.get(url)
4646
// Get results
@@ -69,8 +69,9 @@ module.exports = function (grunt) {
6969
}).then(function () {
7070
// Start the next job, if any
7171
if (urls.length > 0) {
72-
return runTestUrls(driver, urls);
72+
return runTestUrls(driver, urls, errors);
7373
} else {
74+
driver.quit();
7475
return Promise.resolve(errors);
7576
}
7677
});
@@ -168,10 +169,6 @@ module.exports = function (grunt) {
168169
}).catch(function (err) {
169170
grunt.log.error(err);
170171
done(false);
171-
172-
// Lastly, always close the browser
173-
}).then(function () {
174-
return driver.quit();
175172
});
176173

177174
});

test/commons/color/get-background-color.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ describe('color.getBackgroundColor', function () {
66
afterEach(function () {
77
document.getElementById('fixture').innerHTML = '';
88
axe.commons.color.incompleteData.clear();
9+
document.body.scrollTop = 0;
910
});
1011

1112
it('should return the blended color if it has no background set', function () {

test/commons/color/get-foreground-color.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ describe('color.getForegroundColor', function () {
55

66
afterEach(function () {
77
document.getElementById('fixture').innerHTML = '';
8+
axe.commons.color.incompleteData.clear();
9+
document.body.scrollTop = 0;
810
});
911

1012
it('should return the blended color if it has alpha set', function () {

test/integration/full/options/options.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,73 @@ describe('Options', function() {
33

44
before(function (done) {
55
var frame = document.getElementById('myframe');
6-
if (frame.contentWindow.document.readyState === 'complete') {
7-
done();
8-
} else {
9-
frame.addEventListener('load', function () {
6+
var interval = setInterval(function () {
7+
var win = frame.contentWindow;
8+
axe.utils.respondable(win, 'axe.ping', null, undefined, function() {
9+
clearInterval(interval);
1010
done();
1111
});
12-
}
12+
}, 100);
1313
});
1414

1515
function $id(id) {
1616
return document.getElementById(id);
1717
}
1818

1919
describe('iframes', function() {
20-
it('should include iframes by default', function(done) {
21-
var config = {};
20+
it('should include iframes if `iframes` is true', function(done) {
21+
var config = { iframes: true };
2222
axe.a11yCheck(document, config, function(results) {
2323
try {
2424
assert.lengthOf(results.violations, 0, 'violations');
2525
assert.lengthOf(results.passes, 1, 'passes');
26-
assert.lengthOf(results.passes[0].nodes, 2, 'results from main and iframe');
2726
assert.isTrue(results.passes[0].nodes.some(function(node) {
2827
if (node.target.length !== 2) {
2928
return false;
3029
}
3130
return node.target[0] === '#myframe';
3231
}), 'couldn\'t find iframe result');
32+
assert.lengthOf(results.passes[0].nodes, 2, 'results from main and iframe');
3333
done();
3434
} catch (e) {
3535
done(e);
3636
}
3737
});
3838
});
3939

40-
it('should include iframes if `iframes` is true', function(done) {
41-
var config = { iframes: true };
40+
it('should exclude iframes if `iframes` is false', function(done) {
41+
var config = { iframes: false };
4242
axe.a11yCheck(document, config, function(results) {
4343
try {
4444
assert.lengthOf(results.violations, 0, 'violations');
4545
assert.lengthOf(results.passes, 1, 'passes');
46-
assert.lengthOf(results.passes[0].nodes, 2, 'results from main and iframe');
47-
assert.isTrue(results.passes[0].nodes.some(function(node) {
46+
assert.isFalse(results.passes[0].nodes.some(function(node) {
4847
if (node.target.length !== 2) {
4948
return false;
50-
}
49+
}
5150
return node.target[0] === '#myframe';
52-
}), 'couldn\'t find iframe result');
51+
}), 'unexpectedly found iframe result');
52+
assert.lengthOf(results.passes[0].nodes, 1, 'results from main frame only');
5353
done();
5454
} catch (e) {
5555
done(e);
5656
}
5757
});
5858
});
5959

60-
it('should exclude iframes if `iframes` is false', function(done) {
61-
var config = { iframes: false };
60+
it('should include iframes by default', function(done) {
61+
var config = {};
6262
axe.a11yCheck(document, config, function(results) {
6363
try {
6464
assert.lengthOf(results.violations, 0, 'violations');
6565
assert.lengthOf(results.passes, 1, 'passes');
66-
assert.lengthOf(results.passes[0].nodes, 1, 'results from main frame only');
67-
assert.isFalse(results.passes[0].nodes.some(function(node) {
66+
assert.isTrue(results.passes[0].nodes.some(function(node) {
6867
if (node.target.length !== 2) {
6968
return false;
70-
}
69+
}
7170
return node.target[0] === '#myframe';
72-
}), 'unexpectedly found iframe result');
71+
}), 'couldn\'t find iframe result');
72+
assert.lengthOf(results.passes[0].nodes, 2, 'results from main and iframe');
7373
done();
7474
} catch (e) {
7575
done(e);

0 commit comments

Comments
 (0)