Web Automation: support uploading non-local file paths
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 22:54:25 +0000 (22:54 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 22:54:25 +0000 (22:54 +0000)
commit357efaf7d2a5c95c943de1ec98b8e0fa5694d708
tree4f0e9821d464a0b64c30bdcdeceafe23d0c9253b
parent8028f0635903ec815f637f346121cb4b882400fc
Web Automation: support uploading non-local file paths
https://bugs.webkit.org/show_bug.cgi?id=196081
<rdar://problem/45819897>

Reviewed by Devin Rousso and Joseph Pecoraro.

To support cases where supplied file paths do not exist on the session host, add support for
receiving file contents via Automation.setFilesToSelectForFileUpload.

* UIProcess/Automation/Automation.json: Add new parameter.

* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::setFilesToSelectForFileUpload):
Add support for receiving and saving file contents to a temporary directory. Rewrite the used paths so
that WebCore knows to look at the revised paths where the file contents have been saved.

(WebKit::WebAutomationSession::platformGenerateLocalFilePathForRemoteFile):
Since WebKit does not have usable FileSystem implementations for all ports, shell out the actual
saving of base64-encoded file data. Provide a Cocoa implementation, since that's what I can test.

* UIProcess/Automation/cocoa/WebAutomationSessionCocoa.mm:
(WebKit::WebAutomationSession::platformGenerateLocalFilePathForRemoteFile):
Use WTF::FileSystem to create a temporary directory, and use Cocoa methods to actually write the file.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Automation/Automation.json
Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
Source/WebKit/UIProcess/Automation/WebAutomationSession.h
Source/WebKit/UIProcess/Automation/cocoa/WebAutomationSessionCocoa.mm