Skip to content

Commit

Permalink
fix: respect preload set to false (#1298)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeyyy authored Jan 7, 2019
1 parent f93c0c9 commit e847d38
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/checks/mobile/css-orientation-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"impact": "serious",
"messages": {
"pass": "Display is operable, and orientation lock does not exist",
"fail": "CSS Orientation lock is applied, and makes display inoperable"
"fail": "CSS Orientation lock is applied, and makes display inoperable",
"incomplete": "CSS Orientation lock cannot be determined"
}
}
}
2 changes: 1 addition & 1 deletion lib/core/utils/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function isValidPreloadObject(preload) {
* @return {boolean} defaults to true
*/
axe.utils.shouldPreload = function shouldPreload(options) {
if (!options || !options.preload) {
if (!options || options.preload === undefined || options.preload === null) {
return true; // by default `preload` requested assets eg: ['cssom']
}
if (typeof options.preload === 'boolean') {
Expand Down
40 changes: 40 additions & 0 deletions test/core/utils/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ describe('axe.utils.preload', function() {
});
});

it('should return empty array as result', function(done) {
var options = {
preload: false
};
var actual = axe.utils.preload(options);
actual
.then(function(results) {
assert.isDefined(results);
assert.isArray(results);
assert.lengthOf(results, 0);
done();
})
.catch(function(error) {
done(error);
});
});

it('should return an object with property cssom and verify result is same output from preloadCssom', function(done) {
var options = {
preload: {
Expand All @@ -63,6 +80,29 @@ describe('axe.utils.preload', function() {

describe('axe.utils.shouldPreload', function() {
it('should return true if preload configuration is valid', function() {
var actual = axe.utils.shouldPreload({
preload: {
assets: ['cssom']
}
});
assert.isTrue(actual);
});

it('should return true if preload is undefined', function() {
var actual = axe.utils.shouldPreload({
preload: undefined
});
assert.isTrue(actual);
});

it('should return true if preload is null', function() {
var actual = axe.utils.shouldPreload({
preload: null
});
assert.isTrue(actual);
});

it('should return true if preload is not set', function() {
var actual = axe.utils.shouldPreload({});
assert.isTrue(actual);
});
Expand Down

0 comments on commit e847d38

Please sign in to comment.