diff --git a/lib/checks/mobile/meta-viewport-scale.js b/lib/checks/mobile/meta-viewport-scale.js index c9a444ea66..ca8e65ae68 100644 --- a/lib/checks/mobile/meta-viewport-scale.js +++ b/lib/checks/mobile/meta-viewport-scale.js @@ -26,10 +26,12 @@ if ( } if (!lowerBound && result['user-scalable'] === 'no') { + this.data(['user-scalable=no']); return false; } if (result['maximum-scale'] && parseFloat(result['maximum-scale']) < minimum) { + this.data(['maximum-scale']); return false; } diff --git a/lib/checks/mobile/meta-viewport.json b/lib/checks/mobile/meta-viewport.json index 162bb016dd..4b5613aff7 100644 --- a/lib/checks/mobile/meta-viewport.json +++ b/lib/checks/mobile/meta-viewport.json @@ -8,7 +8,7 @@ "impact": "critical", "messages": { "pass": " tag does not disable zooming on mobile devices", - "fail": " tag disables zooming on mobile devices" + "fail": "{{~it.data:value}} {{=value}}{{~}} on tag disables zooming on mobile devices" } } } diff --git a/test/checks/mobile/meta-viewport-scale.js b/test/checks/mobile/meta-viewport-scale.js index 130dab70f5..c28a427a96 100644 --- a/test/checks/mobile/meta-viewport-scale.js +++ b/test/checks/mobile/meta-viewport-scale.js @@ -2,9 +2,11 @@ describe('meta-viewport', function() { 'use strict'; var fixture = document.getElementById('fixture'); + var checkContext = axe.testUtils.MockCheckContext(); afterEach(function() { fixture.innerHTML = ''; + checkContext.reset(); }); describe('; separator', function() { it('should return false on user-scalable=no', function() { @@ -12,7 +14,8 @@ describe('meta-viewport', function() { ''; var node = fixture.querySelector('meta'); - assert.isFalse(checks['meta-viewport'].evaluate(node)); + assert.isFalse(checks['meta-viewport'].evaluate.call(checkContext, node)); + assert.deepEqual(checkContext._data, ['user-scalable']); }); it('should return false on user-scalable=no', function() { @@ -20,7 +23,7 @@ describe('meta-viewport', function() { ''; var node = fixture.querySelector('meta'); - assert.isFalse(checks['meta-viewport'].evaluate(node)); + assert.isFalse(checks['meta-viewport'].evaluate.call(checkContext, node)); }); it('should return true on user-scalable=yes', function() { @@ -37,14 +40,16 @@ describe('meta-viewport', function() { var node = fixture.querySelector('meta'); assert.isTrue( - checks['meta-viewport'].evaluate(node, { scaleMinimum: 2 }) + checks['meta-viewport'].evaluate.call(checkContext, node, { + scaleMinimum: 2 + }) ); fixture.innerHTML = ''; node = fixture.querySelector('meta'); - assert.isTrue(checks['meta-viewport'].evaluate(node)); + assert.isTrue(checks['meta-viewport'].evaluate.call(checkContext, node)); }); it('should return false on maximum-scale < options.scaleMinimum', function() { @@ -53,15 +58,18 @@ describe('meta-viewport', function() { var node = fixture.querySelector('meta'); assert.isFalse( - checks['meta-viewport'].evaluate(node, { scaleMinimum: 2 }) + checks['meta-viewport'].evaluate.call(checkContext, node, { + scaleMinimum: 2 + }) ); + assert.deepEqual(checkContext._data, ['maximum-scale']); }); it('should return true if neither user-scalable or maximum-scale are set', function() { fixture.innerHTML = ''; var node = fixture.querySelector('meta'); - assert.isTrue(checks['meta-viewport'].evaluate(node)); + assert.isTrue(checks['meta-viewport'].evaluate.call(checkContext, node)); }); }); @@ -71,7 +79,8 @@ describe('meta-viewport', function() { ''; var node = fixture.querySelector('meta'); - assert.isFalse(checks['meta-viewport'].evaluate(node)); + assert.isFalse(checks['meta-viewport'].evaluate.call(checkContext, node)); + assert.deepEqual(checkContext._data, ['user-scalable']); }); it('should return false on user-scalable=no', function() { @@ -79,7 +88,8 @@ describe('meta-viewport', function() { ''; var node = fixture.querySelector('meta'); - assert.isFalse(checks['meta-viewport'].evaluate(node)); + assert.isFalse(checks['meta-viewport'].evaluate.call(checkContext, node)); + assert.deepEqual(checkContext._data, ['user-scalable']); }); it('should return true on user-scalable=yes', function() { @@ -87,7 +97,7 @@ describe('meta-viewport', function() { ''; var node = fixture.querySelector('meta'); - assert.isTrue(checks['meta-viewport'].evaluate(node)); + assert.isTrue(checks['meta-viewport'].evaluate.call(checkContext, node)); }); it('should return true if maximum-scale >= options.scaleMinimum', function() { @@ -95,14 +105,16 @@ describe('meta-viewport', function() { ''; var node = fixture.querySelector('meta'); - assert.isTrue(checks['meta-viewport'].evaluate(node)); + assert.isTrue(checks['meta-viewport'].evaluate.call(checkContext, node)); fixture.innerHTML = ''; node = fixture.querySelector('meta'); assert.isTrue( - checks['meta-viewport'].evaluate(node, { scaleMinimum: 2 }) + checks['meta-viewport'].evaluate.call(checkContext, node, { + scaleMinimum: 2 + }) ); }); @@ -112,7 +124,9 @@ describe('meta-viewport', function() { var node = fixture.querySelector('meta'); assert.isFalse( - checks['meta-viewport'].evaluate(node, { scaleMinimum: 2 }) + checks['meta-viewport'].evaluate.call(checkContext, node, { + scaleMinimum: 2 + }) ); }); @@ -120,7 +134,7 @@ describe('meta-viewport', function() { fixture.innerHTML = ''; var node = fixture.querySelector('meta'); - assert.isTrue(checks['meta-viewport'].evaluate(node)); + assert.isTrue(checks['meta-viewport'].evaluate.call(checkContext, node)); }); }); });