Bug 156073 - Web Automation: Add Automation.takeScreenshot
Summary: Web Automation: Add Automation.takeScreenshot
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-03-31 11:16 PDT by Joseph Pecoraro
Modified: 2016-03-31 12:04 PDT (History)
7 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (19.30 KB, patch)
2016-03-31 11:32 PDT, Joseph Pecoraro
timothy: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2016-03-31 11:16:25 PDT
* SUMMARY
Add Automation.screenshot. Screenshot of the entire page, not just the visible/viewport portion.
Comment 1 Radar WebKit Bug Importer 2016-03-31 11:16:47 PDT
<rdar://problem/25468646>
Comment 2 Joseph Pecoraro 2016-03-31 11:32:48 PDT
Created attachment 275307 [details]
[PATCH] Proposed Fix
Comment 3 Timothy Hatcher 2016-03-31 11:43:01 PDT
Comment on attachment 275307 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=275307&action=review

> Source/WebKit2/UIProcess/Automation/Automation.json:313
> +            "name": "screenshot",

I think takeScreenshot would be better. See below.

> Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp:777
> +void WebAutomationSession::screenshot(ErrorString& errorString, const String& handle, Ref<ScreenshotCallback>&& callback)

WebAutomationSession::takeScreenshot would be good, we have been naming these the same as the WebAutomationSessionPoxy methods.

> Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp:476
> +    RefPtr<WebImage> image = page->scaledSnapshotWithOptions(snapshotRect, 1, SnapshotOptionsShareable);

This forces 1x? I wonder if we should make it work with 2x too.
Comment 4 Joseph Pecoraro 2016-03-31 11:44:51 PDT
(In reply to comment #3)
> Comment on attachment 275307 [details]
> [PATCH] Proposed Fix
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=275307&action=review
> 
> > Source/WebKit2/UIProcess/Automation/Automation.json:313
> > +            "name": "screenshot",
> 
> I think takeScreenshot would be better. See below.
> 
> > Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp:777
> > +void WebAutomationSession::screenshot(ErrorString& errorString, const String& handle, Ref<ScreenshotCallback>&& callback)
> 
> WebAutomationSession::takeScreenshot would be good, we have been naming
> these the same as the WebAutomationSessionPoxy methods.

I'll rename.


> > Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp:476
> > +    RefPtr<WebImage> image = page->scaledSnapshotWithOptions(snapshotRect, 1, SnapshotOptionsShareable);
> 
> This forces 1x? I wonder if we should make it work with 2x too.

Nope, this is an "additional scale". it is fine to be 1.
Comment 5 BJ Burg 2016-03-31 11:46:12 PDT
Comment on attachment 275307 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=275307&action=review

r=me!

> Source/WebKit2/ChangeLog:35
> +        Use null string where possible for efficiency.

Efficiency! :)

> Source/WebKit2/UIProcess/Automation/WebAutomationSession.h:109
> +    void screenshot(Inspector::ErrorString&, const String& handle, Ref<Inspector::AutomationBackendDispatcherHandler::ScreenshotCallback>&&) override;

I would name it takeScreenshot to match the callback.

> Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp:455
> +    ShareableBitmap::Handle handle;

Nit: move this closer to the use-site.
Comment 6 Joseph Pecoraro 2016-03-31 11:49:33 PDT
> > Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp:455
> > +    ShareableBitmap::Handle handle;
> 
> Nit: move this closer to the use-site.

This is used, even when empty, in all the DidTakeScreenshot responses, so I put it at the top.
Comment 7 Joseph Pecoraro 2016-03-31 12:04:11 PDT
<http://trac.webkit.org/changeset/198907>