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

fix(meta-viewport): show attribute in message #1061

Merged
merged 2 commits into from
Aug 16, 2018
Merged

Conversation

marcysutton
Copy link
Contributor

@marcysutton marcysutton commented Aug 7, 2018

A user reported the meta-viewport check had a confusing failure message, so I changed it to pass along the failing attribute:

"Fix the following: user-scalable="no" on tag disables zooming"

Closes #1045

Reviewer checks

Required fields, to be filled out by PR reviewer(s)

  • Follows the commit message policy, appropriate for next version
  • Has documentation updated, a DU ticket, or requires no documentation change
  • Includes new tests, or was unnecessary
  • Code is reviewed for security by: Jey (@JKODU)

jeeyyy
jeeyyy previously approved these changes Aug 8, 2018
Copy link
Contributor

@jeeyyy jeeyyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm.

@jeeyyy jeeyyy dismissed their stale review August 8, 2018 10:16

See comments.

@@ -26,10 +26,12 @@ if (
}

if (!lowerBound && result['user-scalable'] === 'no') {
this.data(['user-scalable=no']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this an array? Is so should we do a join in the doT templates?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd followed another example, there can only be one result but that looked like what doT was expecting.

return false;
}

if (result['maximum-scale'] && parseFloat(result['maximum-scale']) < minimum) {
this.data(['maximum-scale']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we saying if user-scalable=no is already set on data, maximum-scale will then override the data? Should we not concat?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It returns false. There can only be one result.

@@ -8,7 +8,7 @@
"impact": "critical",
"messages": {
"pass": "<meta> tag does not disable zooming on mobile devices",
"fail": "<meta> tag disables zooming on mobile devices"
"fail": "{{~it.data:value}} {{=value}}{{~}} on <meta> tag disables zooming on mobile devices"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data seems to be an array, values should be joined here to construct the string...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to a string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to do {{=it.data}} otherwise you get this:

screenshot 2018-08-09 11 18 22

});
describe('; separator', function() {
it('should return false on user-scalable=no', function() {
fixture.innerHTML =
'<meta name="viewport" content="foo=bar, cats=dogs, user-scalable=no">';
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=no']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a test case where both user-scalable and maximum-scale are added to _data?

Copy link
Contributor

@jeeyyy jeeyyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments.

jeeyyy
jeeyyy previously approved these changes Aug 8, 2018
Copy link
Contributor

@WilcoFiers WilcoFiers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment.

@marcysutton
Copy link
Contributor Author

@WilcoFiers good catch, I've updated the PR and rebased from develop.

@dylanb
Copy link
Contributor

dylanb commented Aug 10, 2018

@marcysutton seems like we should add some tests to ensure that the appropriate data is coming through?

@marcysutton
Copy link
Contributor Author

@dylanb not a bad idea, do you know of any existing places in the codebase where we test the messages?

@WilcoFiers WilcoFiers requested a review from a team as a code owner August 16, 2018 09:42
@WilcoFiers WilcoFiers merged commit 9ff5d54 into develop Aug 16, 2018
@WilcoFiers WilcoFiers deleted the meta-viewport-msg branch August 16, 2018 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants