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(fix): fix incorrect aspect ratio bug if the image is 1x1 pixel #6305

Merged
merged 2 commits into from
Oct 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lighthouse-core/audits/image-aspect-ratio.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class ImageAspectRatio extends Audit {
// - filter all svgs as they have no natural dimensions to audit
return image.networkRecord &&
image.networkRecord.mimeType !== 'image/svg+xml' &&
image.naturalHeight > 5 &&
image.naturalWidth > 5 &&
image.width &&
image.height &&
!image.usesObjectFit;
Expand Down
7 changes: 3 additions & 4 deletions lighthouse-core/test/audits/image-aspect-ratio-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,10 @@ describe('Images: aspect-ratio audit', () => {
},
});

testImage('has invalid natural sizing information', {
testImage('is placeholder image', {
rawValue: true,
warning: 'Invalid image sizing information https://google.com/logo.png',
clientSize: [100, 100],
naturalSize: [0, 0],
clientSize: [300, 220],
naturalSize: [1, 1],
props: {
isCss: false,
usesObjectFit: false,
Expand Down