Skip to content

Commit e847d38

Browse files
authored
fix: respect preload set to false (#1298)
1 parent f93c0c9 commit e847d38

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

lib/checks/mobile/css-orientation-lock.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"impact": "serious",
66
"messages": {
77
"pass": "Display is operable, and orientation lock does not exist",
8-
"fail": "CSS Orientation lock is applied, and makes display inoperable"
8+
"fail": "CSS Orientation lock is applied, and makes display inoperable",
9+
"incomplete": "CSS Orientation lock cannot be determined"
910
}
1011
}
1112
}

lib/core/utils/preload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function isValidPreloadObject(preload) {
1414
* @return {boolean} defaults to true
1515
*/
1616
axe.utils.shouldPreload = function shouldPreload(options) {
17-
if (!options || !options.preload) {
17+
if (!options || options.preload === undefined || options.preload === null) {
1818
return true; // by default `preload` requested assets eg: ['cssom']
1919
}
2020
if (typeof options.preload === 'boolean') {

test/core/utils/preload.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ describe('axe.utils.preload', function() {
3838
});
3939
});
4040

41+
it('should return empty array as result', function(done) {
42+
var options = {
43+
preload: false
44+
};
45+
var actual = axe.utils.preload(options);
46+
actual
47+
.then(function(results) {
48+
assert.isDefined(results);
49+
assert.isArray(results);
50+
assert.lengthOf(results, 0);
51+
done();
52+
})
53+
.catch(function(error) {
54+
done(error);
55+
});
56+
});
57+
4158
it('should return an object with property cssom and verify result is same output from preloadCssom', function(done) {
4259
var options = {
4360
preload: {
@@ -63,6 +80,29 @@ describe('axe.utils.preload', function() {
6380

6481
describe('axe.utils.shouldPreload', function() {
6582
it('should return true if preload configuration is valid', function() {
83+
var actual = axe.utils.shouldPreload({
84+
preload: {
85+
assets: ['cssom']
86+
}
87+
});
88+
assert.isTrue(actual);
89+
});
90+
91+
it('should return true if preload is undefined', function() {
92+
var actual = axe.utils.shouldPreload({
93+
preload: undefined
94+
});
95+
assert.isTrue(actual);
96+
});
97+
98+
it('should return true if preload is null', function() {
99+
var actual = axe.utils.shouldPreload({
100+
preload: null
101+
});
102+
assert.isTrue(actual);
103+
});
104+
105+
it('should return true if preload is not set', function() {
66106
var actual = axe.utils.shouldPreload({});
67107
assert.isTrue(actual);
68108
});

0 commit comments

Comments
 (0)