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(screenshot): don't show viewport size overlay #6824

Closed
wants to merge 10 commits into from

Conversation

sadym-chromium
Copy link
Collaborator

@sadym-chromium sadym-chromium commented Feb 5, 2021

@google-cla google-cla bot added the cla: yes label Feb 5, 2021
Copy link
Member

@mathiasbynens mathiasbynens left a comment

Choose a reason for hiding this comment

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

This is still marked as draft, yet you requested review already — which is it? Happy to take a look :)

test/headful.spec.ts Outdated Show resolved Hide resolved
@@ -1675,6 +1675,11 @@ export class Page extends EventEmitter {
});
let clip = options.clip ? processClip(options.clip) : undefined;

// Not hiding the size overlay will cause unwilling artefacts on the screenshot.
await this._client.send('Overlay.setShowViewportSizeOnResize', {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably we need to set it back to the original value afterwards? Btw, have you found why the viewport is being resized when you take a screenshot?

Copy link
Member

Choose a reason for hiding this comment

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

Probably we need to set it back to the original value afterwards?

I initially thought this too, but then couldn't immediately think of any reason a Puppeteer script would need the overlays to render. Are you thinking of headful scenarios where the Puppeteer scripts does some set up on the page and then hands it over to the user for some manual interaction?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, I am not sure. What is the use case for running puppeteer with devtools: true? can you manipulate DevTools window as well? A hypothetical scenario of a test: resizing a window & evaluating that viewport overlay is rendered. Also, for DevTools it'd be probably helpful to capture screenshots with overlays in e2e tests at some point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DevTools doesn't set it back, and there is no method to get the initial value.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. So do you know why the page is resized when taking a screenshot?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, I am not sure. What is the use case for running puppeteer with devtools: true?

We've build a complete test runner around puppeteer over at https://github.com/boxine/pentf/ . To make test inspection as easy as possible for our developers we have a -d, --debug flag that opens up the browser in headful mode with devtools already opened, with persistent logging enabled and a bunch of other stuff. They love it because it saves them quite a few clicks. This file (especially the newPage function) with the puppeteer enhancements might be worth a look: https://github.com/boxine/pentf/blob/master/src/browser_utils.js

I'm using the same runner to test the devtools extensions for Preact (frontend framework) https://github.com/preactjs/preact-devtools/ . Currently I'm faking the extension inside an iframe, but the long term goal is to test the extension pages inside the devtools panel directly. This would properly test it like the user would experience it and would allow me to verify things like "is my extension tab showing up?", syncing extension settings, etc.

@mathiasbynens
Copy link
Member

Please try optimizing test/golden-chromium/headful-screenshot-grid-fullpage.png if you haven't already

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
@sadym-chromium
Copy link
Collaborator Author

This is still marked as draft, yet you requested review already — which is it? Happy to take a look :)

It's not ready yet. I added reviewers too early, sorry.

@sadym-chromium
Copy link
Collaborator Author

Please try optimizing test/golden-chromium/headful-screenshot-grid-fullpage.png if you haven't already

It was optimised, but at the end there is no need in the file at all.

@jschfflr
Copy link
Contributor

@sadym-chromium just a gentle ping to see if this is still relevant. If not, feel free to close this. Otherwise, let's get this landed :)

@sadym-chromium
Copy link
Collaborator Author

As described in the comment, the suggested solution wouldn't work. Closing.

@jrandolf jrandolf deleted the viewportSizeOverlay branch May 3, 2022 13:03
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.

None yet

5 participants