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(screenshots): match format of final-screenshot #8299

Merged
merged 8 commits into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions lighthouse-core/audits/screenshot-thumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class ScreenshotThumbnails extends Audit {
}
});
}

let base64Data;
const cachedThumbnail = cachedThumbnails.get(frameForTimestamp);
if (cachedThumbnail) {
Expand All @@ -128,8 +129,8 @@ class ScreenshotThumbnails extends Audit {
}
thumbnails.push({
timing: Math.round(targetTimestamp - speedline.beginning),
patrickhulce marked this conversation as resolved.
Show resolved Hide resolved
timestamp: targetTimestamp * 1000,
data: base64Data,
timestamp: targetTimestamp,
patrickhulce marked this conversation as resolved.
Show resolved Hide resolved
data: `data:image/jpeg;base64,${base64Data}`,
Copy link
Member

Choose a reason for hiding this comment

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

yeah, having the prefix makes sense so no one has to guess what type of image it is, even if it's annoying to add it here

});
}

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/report/html/renderer/details-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class DetailsRenderer {
for (const thumbnail of details.items) {
const frameEl = this._dom.createChildOf(filmstripEl, 'div', 'lh-filmstrip__frame');
this._dom.createChildOf(frameEl, 'img', 'lh-filmstrip__thumbnail', {
src: `data:image/jpeg;base64,${thumbnail.data}`,
src: thumbnail.data,
alt: `Screenshot`,
});
}
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/test/audits/screenshot-thumbnails-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ describe('Screenshot thumbnails', () => {
const framePath = path.join(__dirname,
`../fixtures/traces/screenshots/progressive-app-frame-${index}.jpg`);
const expectedData = fs.readFileSync(framePath, 'base64');
assert.equal(expectedData.length, result.data.length);
expect(result.data.length - 'data:image/jpeg;base64,'.length).toEqual(expectedData.length);
Copy link
Member

Choose a reason for hiding this comment

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

weird test :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

heh, I can slice it instead to make it a little more explicit :)

Copy link
Member

Choose a reason for hiding this comment

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

weird test :)

heh, I can slice it instead to make it a little more explicit :)

ha, I meant the original test is a weird one, but I like the change :)

});

assert.ok(results.rawValue);
assert.equal(results.details.items[0].timing, 82);
assert.equal(results.details.items[2].timing, 245);
assert.equal(results.details.items[9].timing, 818);
assert.equal(results.details.items[0].timestamp, 225414253815);
assert.equal(results.details.items[0].timestamp, 225414253.815);
});
}, 10000);

Expand Down
Loading