Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix tests failing in IE11 #1570

Merged
merged 6 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/checks/mobile/css-orientation-lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ Object.keys(rulesGroupByDocumentFragment).forEach(key => {
// eg: screen and (max-width: 767px) and (min-width: 320px) and (orientation: landscape)
const cssText = r.cssText;
return (
/orientation:\s+landscape/i.test(cssText) ||
/orientation:\s+portrait/i.test(cssText)
/orientation:\s*landscape/i.test(cssText) ||
/orientation:\s*portrait/i.test(cssText)
);
});
if (!orientationRules || !orientationRules.length) {
Expand All @@ -87,8 +87,12 @@ Object.keys(rulesGroupByDocumentFragment).forEach(key => {
return;
}

// check if transform style exists
const transformStyleValue = cssRule.style.transform || false;
// check if transform style exists (don't forget vendor prefixes)
const transformStyleValue =
cssRule.style.transform ||
cssRule.style.webkitTransform ||
cssRule.style.msTransform ||
false;
// transformStyleValue -> is the value applied to property
// eg: "rotate(-90deg)"
if (!transformStyleValue) {
Expand Down
52 changes: 23 additions & 29 deletions test/checks/mobile/css-orientation-lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ describe('css-orientation-lock tests', function() {
var dynamicDoc = document.implementation.createHTMLDocument(
'Dynamic document for CSS Orientation Lock tests'
);
var isIE11 = axe.testUtils.isIE11;
var isPhantom = window.PHANTOMJS ? true : false;

afterEach(function() {
checks['css-orientation-lock'] = origCheck;
Expand All @@ -23,11 +21,11 @@ describe('css-orientation-lock tests', function() {
MEDIA_STYLE_ORIENTATION_WITHOUT_TRANSFORM:
'@media screen and (min-width: 1px) and (max-width: 2000px) and (orientation: portrait) { #mocha { color: red; } }',
MEDIA_STYLE_ORIENTATION_WITH_TRANSFORM_NOT_ROTATE:
'@media screen and (min-width: 1px) and (max-width: 3000px) and (orientation: landscape) { #mocha { transform: translateX(10px); } }',
'@media screen and (min-width: 1px) and (max-width: 3000px) and (orientation: landscape) { #mocha { transform: translateX(10px); -webkit-transform: translateX(10px); } }',
straker marked this conversation as resolved.
Show resolved Hide resolved
MEDIA_STYLE_ORIENTATION_WITH_TRANSFORM_ROTATE_180:
'@media screen and (min-width: 1px) and (max-width: 3000px) and (orientation: landscape) { body { transform: rotate(180deg); } }',
'@media screen and (min-width: 1px) and (max-width: 3000px) and (orientation: landscape) { body { transform: rotate(180deg); -webkit-transform: rotate(180deg); } }',
MEDIA_STYLE_ORIENTATION_WITH_TRANSFORM_ROTATE_90:
'@media screen and (min-width: 1px) and (max-width: 3000px) and (orientation: landscape) { #mocha { transform: rotate(270deg); } }'
'@media screen and (min-width: 1px) and (max-width: 3000px) and (orientation: landscape) { #mocha { transform: rotate(270deg); -webkit-transform: rotate(270deg); } }'
};

function getSheet(data) {
Expand Down Expand Up @@ -220,30 +218,26 @@ describe('css-orientation-lock tests', function() {
assert.isTrue(actual);
});

// This currently breaks in IE11
(isIE11 || isPhantom ? it.skip : it)(
'returns false if TRANSFORM style applied is ROTATE, and is divisible by 90 and not divisible by 180',
function() {
var actual = checks['css-orientation-lock'].evaluate.call(
checkContext,
document,
{},
undefined,
{
cssom: [
{
shadowId: undefined,
root: document,
sheet: getSheet(
SHEET_DATA.MEDIA_STYLE_ORIENTATION_WITH_TRANSFORM_ROTATE_90
)
}
]
}
);
assert.isFalse(actual);
}
);
it('returns false if TRANSFORM style applied is ROTATE, and is divisible by 90 and not divisible by 180', function() {
var actual = checks['css-orientation-lock'].evaluate.call(
checkContext,
document,
{},
undefined,
{
cssom: [
{
shadowId: undefined,
root: document,
sheet: getSheet(
SHEET_DATA.MEDIA_STYLE_ORIENTATION_WITH_TRANSFORM_ROTATE_90
)
}
]
}
);
assert.isFalse(actual);
});

// Note:
// external stylesheets is tested in integration tests
Expand Down
6 changes: 2 additions & 4 deletions test/core/utils/parse-crossorigin-stylesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ describe('axe.utils.parseCrossOriginStylesheet', function() {
);
done();
})
.catch(function() {
done(
new Error('Expected axe.utils.parseCrossOriginStylesheet to resolve.')
);
.catch(function(err) {
done(err);
});
});

Expand Down
23 changes: 19 additions & 4 deletions test/testutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,25 @@ testUtils.assertStylesheet = function assertStylesheet(
assert.isTrue(cssText.includes(selectorText));
} else {
assert.equal(sheet.cssRules[0].selectorText, selectorText);
assert.equal(
sheet.cssRules[0].cssText.replace(/\s/g, ''),
cssText.replace(/\s/g, '')
);

// compare the selector properties
var styleEl = document.createElement('style');
styleEl.type = 'text/css';
styleEl.innerHTML = cssText;
document.body.appendChild(styleEl);

var testSheet = document.styleSheets[document.styleSheets.length - 1];
var sheetRule = sheet.cssRules[0];
var testRule = testSheet.cssRules[0];

try {
for (var i = 0; i < testRule.style.length; i++) {
var property = testRule.style[i];
assert.equal(sheetRule.style[property], testRule.style[property]);
}
} finally {
straker marked this conversation as resolved.
Show resolved Hide resolved
styleEl.parentNode.removeChild(styleEl);
}
}
};

Expand Down