Skip to content

Commit

Permalink
fix(tests): Chrome and ChromeHeadless parity (colour contrast fixed) …
Browse files Browse the repository at this point in the history
…with WebDriver Chromium v130
  • Loading branch information
danielweck committed Oct 23, 2024
1 parent c187ab4 commit 1a5b4a8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@
"integration": "node test/integration/full/test-webdriver.js",
"integration:apg": "mocha --fail-zero test/aria-practices/*.spec.js",
"integration:chrome": "npm run integration -- browser=Chrome",
"integration:chromeheadless": "echo CHROME_HEADLESS_WEBDRIVER_NOT_SUPPORTED || npm run integration -- browser=ChromeHeadless",
"integration:chromeheadless": "npm run integration -- browser=ChromeHeadless",
"integration:firefox": "npm run integration -- browser=Firefox",
"test:integration": "npm run test:integration:chrome",
"test:integration:chromeheadless": "echo CHROME_HEADLESS_WEBDRIVER_NOT_SUPPORTED || start-server-and-test 9876 integration:chromeheadless",
"test:integration:chromeheadless": "start-server-and-test 9876 integration:chromeheadless",
"test:integration:chrome": "start-server-and-test 9876 integration:chrome",
"test:integration:firefox": "start-server-and-test 9876 integration:firefox",
"test:examples": "node ./doc/examples/test-examples",
Expand Down
15 changes: 7 additions & 8 deletions test/checks/color/color-contrast.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,13 @@ describe('color-contrast', function () {
//"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
// console.log(JSON.stringify(navigator.userAgent, null, 4), JSON.stringify(Object.keys(window.mocha), null, 4), JSON.stringify(window.mocha.context, null, 4), JSON.stringify(window.mocha.options, null, 4), JSON.stringify(window.chai, null, 4)) &&
// navigator.userAgent.includes('HeadlessChrome') &&
false &&
it('should return true for inline elements with sufficient contrast spanning multiple lines', function () {
var params = checkSetup(
'<p>Text oh heyyyy <a href="#" id="target">and here\'s <br>a link</a></p>'
);
assert.isTrue(contrastEvaluate.apply(checkContext, params));
assert.deepEqual(checkContext._relatedNodes, []);
});
it('should return true for inline elements with sufficient contrast spanning multiple lines', function () {
var params = checkSetup(
'<p style="color: black; background-color: white;">Text oh heyyyy <a href="#" id="target">and here\'s <br>a link</a></p>'
);
assert.isTrue(contrastEvaluate.apply(checkContext, params));
assert.deepEqual(checkContext._relatedNodes, []);
});

it('should return undefined for inline elements spanning multiple lines that are overlapped', function () {
var params = checkSetup(
Expand Down
2 changes: 1 addition & 1 deletion test/integration/full/test-webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function buildWebDriver(browser) {
// host of other problems with starting Chrome). the only thing that seems to
// allow Chrome to start without problems consistently is using ChromeHeadless
// @see https://stackoverflow.com/questions/50642308/webdriverexception-unknown-error-devtoolsactiveport-file-doesnt-exist-while-t
if (browser === 'chrome') {
if (browser === 'chrome' || browser === 'chromeheadless') {
const service = new chrome.ServiceBuilder(chromedriver.path).build();

const options = new chrome.Options().addArguments([
Expand Down
24 changes: 12 additions & 12 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,18 @@ console.log(isHeadless, JSON.stringify(args, null, 4));
if (isHeadless) {
console.log('HEADLESS...');
for (let i = 0; i < testPaths.length; i++) {
testPaths[i] = testPaths[i].replace(
'link-in-text-block.json',
'link-in-text-block-HEADLESS.json'
);
testPaths[i] = testPaths[i].replace(
'color-contrast.json',
'color-contrast-HEADLESS.json'
);
testPaths[i] = testPaths[i].replace(
'color-contrast-enhanced.json',
'color-contrast-enhanced-HEADLESS.json'
);
// testPaths[i] = testPaths[i].replace(
// 'link-in-text-block.json',
// 'link-in-text-block-HEADLESS.json'
// );
// testPaths[i] = testPaths[i].replace(
// 'color-contrast.json',
// 'color-contrast-HEADLESS.json'
// );
// testPaths[i] = testPaths[i].replace(
// 'color-contrast-enhanced.json',
// 'color-contrast-enhanced-HEADLESS.json'
// );
}
}
console.log(JSON.stringify(testPaths, null, 4));
Expand Down

0 comments on commit 1a5b4a8

Please sign in to comment.