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

core(viewport): include meta viewport string in debugDetails #15727

Merged
merged 2 commits into from
Jan 4, 2024

Conversation

brendankenny
Copy link
Member

@brendankenny brendankenny commented Jan 4, 2024

I've dipped my toes into #15627 a bit and discovered that reality is even more nuanced than the proposed changes listed there. However, any analysis after the fact is difficult because we don't include the page's actual meta viewport content anywhere in the LHR, just whether or not it passed the audit's current mobile viewport checks.

This PR just includes the full viewport string in the audit's debugData.

@brendankenny brendankenny requested a review from a team as a code owner January 4, 2024 21:18
@brendankenny brendankenny requested review from adamraine and removed request for a team January 4, 2024 21:18
Comment on lines +52 to +54
// Set a mobile-friendly viewport only on load.
const metaViewport = document.querySelector('meta[name="viewport"]');
metaViewport.content = 'width=device-width, initial-scale=1, minimum-scale=1';
Copy link
Member Author

Choose a reason for hiding this comment

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

It's really important that we take the viewport content from the element (not parsed from the tag in the html) because site can and do change it.

We already do this, but we don't currently have any test coverage for that fact :)

It probably makes sense for the terrible dbw page to have a weird viewport instead of a nice one, but doing so changes test expectations for way too many assertions, so it isn't worth the effort.

}));
});

it('recognizes interactive-widget property', async () => {
const viewport = 'width=device-width, interactive-widget=resizes-content';
const {parserWarnings} = await ViewportMeta.compute_(makeMetaElements(viewport));
assert.equal(parserWarnings[0], undefined);
Copy link
Member Author

@brendankenny brendankenny Jan 4, 2024

Choose a reason for hiding this comment

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

driveby change of assert.equal(parserWarnings[0], undefined) to assert.equal(parserWarnings.length, 0) because the first one seems like it's asserting that there is at least one warning, but its value is undefined. Not sure if this was important at the time, but the length check seems correct now, at least (happened in #14664 @connorjclark, maybe it had to do with the metaviewport-parser release workaround or something?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I probably just copied it from the place you changed below 🤷

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants