Skip to content

Commit

Permalink
test: remove window.PHANTOMJS checks from tests (#1966)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeyyy committed Jan 8, 2020
1 parent 8c820c5 commit 4af4a3c
Show file tree
Hide file tree
Showing 23 changed files with 414 additions and 532 deletions.
13 changes: 1 addition & 12 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,7 @@ module.exports = function(grunt) {
},
testconfig: {
test: {
src: ['test/integration/rules/**/*.json'].concat(
process.env.APPVEYOR
? [
// These tests are causing PhantomJS to timeout on Appveyor
// Warning: PhantomJS timed out, possibly due to a missing Mocha run() call. Use --force to continue.
'!test/integration/rules/td-has-header/*.json',
'!test/integration/rules/label-content-name-mismatch/*.json',
'!test/integration/rules/label/*.json',
'!test/integration/rules/th-has-data-cells/*.json'
]
: []
),
src: ['test/integration/rules/**/*.json'],
dest: 'tmp/integration-tests.js'
}
},
Expand Down
2 changes: 1 addition & 1 deletion doc/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ To build axe.js, simply run `grunt build` in the root folder of the axe-core rep

### Running Tests

To run all tests from the command line you can run `grunt test`, which will run all unit and integration tests using PhantomJS and Selenium Webdriver.
To run all tests from the command line you can run `grunt test`, which will run all unit and integration tests using headless chrome and Selenium Webdriver.

You can also load tests in any supported browser, which is helpful for debugging. Tests require a local server to run, you must first start a local server to serve files. You can use Grunt to start one by running `grunt dev`. Once your local server is running you can load the following pages in any browser to run tests:

Expand Down
2 changes: 1 addition & 1 deletion lib/core/utils/contains.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Wrapper for Node#contains; PhantomJS does not support Node#contains and erroneously reports that it does
* Wrapper for Node#contains
* @method contains
* @memberof axe.utils
* @param {VirtualNode} vNode The candidate container VirtualNode
Expand Down
16 changes: 4 additions & 12 deletions test/checks/color/color-contrast.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,8 @@ describe('color-contrast', function() {
var params = checkSetup(
'<p>Text oh heyyyy <a href="#" id="target">and here\'s <br>a link</a></p>'
);
if (window.PHANTOMJS) {
assert.ok('PhantomJS is a liar');
} else {
assert.isTrue(contrastEvaluate.apply(checkContext, params));
assert.deepEqual(checkContext._relatedNodes, []);
}
assert.isTrue(contrastEvaluate.apply(checkContext, params));
assert.deepEqual(checkContext._relatedNodes, []);
});

it('should return undefined for inline elements spanning multiple lines that are overlapped', function() {
Expand Down Expand Up @@ -228,12 +224,8 @@ describe('color-contrast', function() {
fixtureSetup('<label id="target">' + 'My text <input type="text"></label>');
var target = fixture.querySelector('#target');
var virtualNode = axe.utils.getNodeFromTree(target);
if (window.PHANTOMJS) {
assert.ok('PhantomJS is a liar');
} else {
var result = contrastEvaluate.call(checkContext, target, {}, virtualNode);
assert.isTrue(result);
}
var result = contrastEvaluate.call(checkContext, target, {}, virtualNode);
assert.isTrue(result);
});

it("should return true when a label wraps a text input but doesn't overlap", function() {
Expand Down
12 changes: 4 additions & 8 deletions test/commons/color/get-background-color.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,10 @@ describe('color.getBackgroundColor', function() {
document.getElementById('target'),
[]
);
if (window.PHANTOMJS) {
assert.ok('PhantomJS is a liar');
} else {
assert.isNotNull(actual);
assert.equal(Math.round(actual.blue), 0);
assert.equal(Math.round(actual.red), 0);
assert.equal(Math.round(actual.green), 0);
}
assert.isNotNull(actual);
assert.equal(Math.round(actual.blue), 0);
assert.equal(Math.round(actual.red), 0);
assert.equal(Math.round(actual.green), 0);
});

it('should return null if a multiline inline element does not fully cover background', function() {
Expand Down
21 changes: 5 additions & 16 deletions test/commons/color/get-own-background-color.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ describe('color.getOwnBackgroundColor', function() {
var fixture = document.getElementById('fixture');
var queryFixture = axe.testUtils.queryFixture;
var getOwnBackgroundColor = axe.commons.color.getOwnBackgroundColor;
var isPhantom = window.PHANTOMJS ? true : false;

afterEach(function() {
fixture.innerHTML = '';
Expand All @@ -21,9 +20,7 @@ describe('color.getOwnBackgroundColor', function() {
assert.equal(actual.red, 0);
assert.equal(actual.green, 0);
assert.equal(actual.blue, 0);
if (!isPhantom) {
assert.equal(actual.alpha, 0);
}
assert.equal(actual.alpha, 0);
});

it('returns color with rgba values of specified background-color value', function() {
Expand All @@ -37,9 +34,7 @@ describe('color.getOwnBackgroundColor', function() {
assert.equal(actual.red, 255);
assert.equal(actual.green, 192);
assert.equal(actual.blue, 203);
if (!isPhantom) {
assert.equal(actual.alpha, 1);
}
assert.equal(actual.alpha, 1);
});

it('returns color with rgba values and alpha', function() {
Expand All @@ -53,9 +48,7 @@ describe('color.getOwnBackgroundColor', function() {
assert.equal(actual.red, 0);
assert.equal(actual.green, 128);
assert.equal(actual.blue, 0);
if (!isPhantom) {
assert.equal(actual.alpha, 0.5);
}
assert.equal(actual.alpha, 0.5);
});

it('returns color with rgba values and opacity (for blending)', function() {
Expand All @@ -69,9 +62,7 @@ describe('color.getOwnBackgroundColor', function() {
assert.equal(actual.red, 0);
assert.equal(actual.green, 128);
assert.equal(actual.blue, 0);
if (!isPhantom) {
assert.equal(actual.alpha, 0.5);
}
assert.equal(actual.alpha, 0.5);
});

it('returns color with rgba values, alpha and opacity', function() {
Expand All @@ -85,8 +76,6 @@ describe('color.getOwnBackgroundColor', function() {
assert.equal(actual.red, 0);
assert.equal(actual.green, 128);
assert.equal(actual.blue, 0);
if (!isPhantom) {
assert.equal(actual.alpha, 0.25);
}
assert.equal(actual.alpha, 0.25);
});
});
7 changes: 1 addition & 6 deletions test/commons/dom/is-offscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ describe('dom.isOffscreen', function() {
fixture.innerHTML =
'<div id="target" style="position: absolute; height: 50px; top: -51px;">Offscreen?</div>';
var el = document.getElementById('target');

if (window.PHANTOMJS) {
assert.ok('PhantomJS is a liar');
} else {
assert.isTrue(axe.commons.dom.isOffscreen(el));
}
assert.isTrue(axe.commons.dom.isOffscreen(el));
});

it('should never detect elements positioned outside the bottom edge', function() {
Expand Down
4 changes: 2 additions & 2 deletions test/commons/dom/is-visible.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ describe('dom.isVisible', function() {

// IE11 either only supports clip paths defined by url() or not at all,
// MDN and caniuse.com give different results...
(isIE11 || window.PHANTOMJS ? it.skip : it)(
(isIE11 ? it.skip : it)(
'should detect clip-path hidden text technique',
function() {
fixture.innerHTML =
Expand All @@ -203,7 +203,7 @@ describe('dom.isVisible', function() {
}
);

(isIE11 || window.PHANTOMJS ? it.skip : it)(
(isIE11 ? it.skip : it)(
'should detect clip-path hidden text technique on parent',
function() {
fixture.innerHTML =
Expand Down
8 changes: 0 additions & 8 deletions test/commons/table/is-data-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,6 @@ describe('table.isDataTable', function() {
});

it('should be true if it has zebra rows', function() {
if (window.PHANTOMJS) {
assert.ok('PhantomJS is a liar');
return;
}
fixture.innerHTML =
'<table>' +
'<tr><td></td><td></td></tr>' +
Expand All @@ -333,10 +329,6 @@ describe('table.isDataTable', function() {
});

it('should be true if it has zebra rows - background image', function() {
if (window.PHANTOMJS) {
assert.ok('PhantomJS is a liar');
return;
}
fixture.innerHTML =
'<table>' +
'<tr><td></td><td></td></tr>' +
Expand Down
47 changes: 17 additions & 30 deletions test/commons/text/accessible-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -2881,13 +2881,11 @@ describe('text.accessibleTextVirtual', function() {

// Skip from 128 - 138 as those are name description cases

// Note: PhantomJS did not detect `style .hidden` appended via innerHTML
// hence falling back to `display: none`
it('passes test 139', function() {
fixture.innerHTML =
// '<style>' +
// ' .hidden { display: none; }' +
// '</style>' +
'<style>' +
' .hidden { display: none; }' +
'</style>' +
'<div id="test" role="link" tabindex="0">' +
' <span aria-hidden="true"><i> Hello, </i></span>' +
' <span>My</span> name is' +
Expand All @@ -2897,8 +2895,7 @@ describe('text.accessibleTextVirtual', function() {
' </span>' +
' <span>the weird.</span>' +
' (QED)' +
// ' <span class="hidden"><i><b>and don\'t you forget it.</b></i></span>' +
' <span style="display:none;"><i><b>and don\'t you forget it.</b></i></span>' +
' <span class="hidden"><i><b>and don\'t you forget it.</b></i></span>' +
' <table>' +
' <tr>' +
' <td>Where</td>' +
Expand All @@ -2920,13 +2917,11 @@ describe('text.accessibleTextVirtual', function() {
);
});

// Note: PhantomJS did not detect `style .hidden` appended via innerHTML
// hence falling back to `display: none`
it('passes test 140', function() {
fixture.innerHTML =
// '<style>' +
// ' .hidden { display: none; }' +
// '</style>' +
'<style>' +
' .hidden { display: none; }' +
'</style>' +
'<input id="test" type="text" aria-labelledby="lblId" />' +
'<div id="lblId" >' +
' <span aria-hidden="true"><i> Hello, </i></span>' +
Expand All @@ -2937,8 +2932,7 @@ describe('text.accessibleTextVirtual', function() {
' </span>' +
' <span>the weird.</span>' +
' (QED)' +
// ' <span class="hidden"><i><b>and don\'t you forget it.</b></i></span>' +
' <span style="display:none;"><i><b>and don\'t you forget it.</b></i></span>' +
' <span class="hidden"><i><b>and don\'t you forget it.</b></i></span>' +
' <table>' +
' <tr>' +
' <td>Where</td>' +
Expand Down Expand Up @@ -3119,22 +3113,18 @@ describe('text.accessibleTextVirtual', function() {
assert.equal(accessibleText(target), 'This is a test.');
});

// Note: PhantomJS did not detect `style .hidden` appended via innerHTML
// hence falling back to `display: none`
it('passes test 153', function() {
fixture.innerHTML =
// '<style>' +
// ' .hidden { display: none; }' +
// '</style>' +
'<style>' +
' .hidden { display: none; }' +
'</style>' +
'<input type="file" id="test" />' +
'<label for="test">' +
// ' <span class="hidden">1</span><span>2</span>' +
' <span style="display:none">1</span><span>2</span>' +
' <span class="hidden">1</span><span>2</span>' +
' <span style="visibility: hidden;">3</span><span>4</span>' +
' <span hidden>5</span><span>6</span>' +
' <span aria-hidden="true">7</span><span>8</span>' +
// ' <span aria-hidden="false" class="hidden">9</span><span>10</span>' +
' <span aria-hidden="false" style="display:none">9</span><span>10</span>' +
' <span aria-hidden="false" class="hidden">9</span><span>10</span>' +
'</label>';
axe.testUtils.flatTreeSetup(fixture);
var target = fixture.querySelector('#test');
Expand Down Expand Up @@ -3181,22 +3171,19 @@ describe('text.accessibleTextVirtual', function() {
assert.equal(accessibleText(target), 'Flash the screen 1 times.');
});

// Note: PhantomJS did not detect `style .hidden` appended via innerHTML
// hence falling back to `display: none`
it('passes test 156', function() {
fixture.innerHTML =
// '<style>' +
// ' .hidden { display: none; }' +
// '</style>' +
'<style>' +
' .hidden { display: none; }' +
'</style>' +
'<div id="test" role="link" tabindex="0">' +
' <span aria-hidden="true"><i> Hello, </i></span>' +
' <span>My</span> name is' +
' <div><img src="file.jpg" title="Bryan" alt="" role="presentation" /></div>' +
' <span role="presentation" aria-label="Eli"><span aria-label="Garaventa">Zambino</span></span>' +
' <span>the weird.</span>' +
' (QED)' +
// ' <span class="hidden"><i><b>and don\'t you forget it.</b></i></span>' +
' <span style="display:none"><i><b>and don\'t you forget it.</b></i></span>' +
' <span class="hidden"><i><b>and don\'t you forget it.</b></i></span>' +
'</div>';
axe.testUtils.flatTreeSetup(fixture);
var target = fixture.querySelector('#test');
Expand Down

0 comments on commit 4af4a3c

Please sign in to comment.