Skip to content

Commit

Permalink
fix: Ensure all tests pass in Chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoFiers authored and dylanb committed Jun 24, 2017
1 parent 34137e5 commit 0b0240f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
13 changes: 5 additions & 8 deletions build/tasks/test-webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ module.exports = function (grunt) {
/**
* Test each URL
*/
function runTestUrls(driver, urls) {
function runTestUrls(driver, urls, errors) {
var url = urls.shift();
var errors = [];
errors = errors || [];

// Give each page enough time
driver.manage().timeouts().setScriptTimeout(600);
driver.manage().timeouts().setScriptTimeout(60000);

return driver.get(url)
// Get results
Expand Down Expand Up @@ -69,8 +69,9 @@ module.exports = function (grunt) {
}).then(function () {
// Start the next job, if any
if (urls.length > 0) {
return runTestUrls(driver, urls);
return runTestUrls(driver, urls, errors);
} else {
driver.quit();
return Promise.resolve(errors);
}
});
Expand Down Expand Up @@ -168,10 +169,6 @@ module.exports = function (grunt) {
}).catch(function (err) {
grunt.log.error(err);
done(false);

// Lastly, always close the browser
}).then(function () {
return driver.quit();
});

});
Expand Down
1 change: 1 addition & 0 deletions test/commons/color/get-background-color.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ describe('color.getBackgroundColor', function () {
afterEach(function () {
document.getElementById('fixture').innerHTML = '';
axe.commons.color.incompleteData.clear();
document.body.scrollTop = 0;
});

it('should return the blended color if it has no background set', function () {
Expand Down
2 changes: 2 additions & 0 deletions test/commons/color/get-foreground-color.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ describe('color.getForegroundColor', function () {

afterEach(function () {
document.getElementById('fixture').innerHTML = '';
axe.commons.color.incompleteData.clear();
document.body.scrollTop = 0;
});

it('should return the blended color if it has alpha set', function () {
Expand Down
40 changes: 20 additions & 20 deletions test/integration/full/options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,73 @@ describe('Options', function() {

before(function (done) {
var frame = document.getElementById('myframe');
if (frame.contentWindow.document.readyState === 'complete') {
done();
} else {
frame.addEventListener('load', function () {
var interval = setInterval(function () {
var win = frame.contentWindow;
axe.utils.respondable(win, 'axe.ping', null, undefined, function() {
clearInterval(interval);
done();
});
}
}, 100);
});

function $id(id) {
return document.getElementById(id);
}

describe('iframes', function() {
it('should include iframes by default', function(done) {
var config = {};
it('should include iframes if `iframes` is true', function(done) {
var config = { iframes: true };
axe.a11yCheck(document, config, function(results) {
try {
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 1, 'passes');
assert.lengthOf(results.passes[0].nodes, 2, 'results from main and iframe');
assert.isTrue(results.passes[0].nodes.some(function(node) {
if (node.target.length !== 2) {
return false;
}
return node.target[0] === '#myframe';
}), 'couldn\'t find iframe result');
assert.lengthOf(results.passes[0].nodes, 2, 'results from main and iframe');
done();
} catch (e) {
done(e);
}
});
});

it('should include iframes if `iframes` is true', function(done) {
var config = { iframes: true };
it('should exclude iframes if `iframes` is false', function(done) {
var config = { iframes: false };
axe.a11yCheck(document, config, function(results) {
try {
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 1, 'passes');
assert.lengthOf(results.passes[0].nodes, 2, 'results from main and iframe');
assert.isTrue(results.passes[0].nodes.some(function(node) {
assert.isFalse(results.passes[0].nodes.some(function(node) {
if (node.target.length !== 2) {
return false;
}
}
return node.target[0] === '#myframe';
}), 'couldn\'t find iframe result');
}), 'unexpectedly found iframe result');
assert.lengthOf(results.passes[0].nodes, 1, 'results from main frame only');
done();
} catch (e) {
done(e);
}
});
});

it('should exclude iframes if `iframes` is false', function(done) {
var config = { iframes: false };
it('should include iframes by default', function(done) {
var config = {};
axe.a11yCheck(document, config, function(results) {
try {
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 1, 'passes');
assert.lengthOf(results.passes[0].nodes, 1, 'results from main frame only');
assert.isFalse(results.passes[0].nodes.some(function(node) {
assert.isTrue(results.passes[0].nodes.some(function(node) {
if (node.target.length !== 2) {
return false;
}
}
return node.target[0] === '#myframe';
}), 'unexpectedly found iframe result');
}), 'couldn\'t find iframe result');
assert.lengthOf(results.passes[0].nodes, 2, 'results from main and iframe');
done();
} catch (e) {
done(e);
Expand Down

0 comments on commit 0b0240f

Please sign in to comment.