Blob references for System Previews don't get a correct file extension
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Jan 2019 01:17:41 +0000 (01:17 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Jan 2019 01:17:41 +0000 (01:17 +0000)
commit9189c8b7859e26ef250c69fc30224b1193a94803
tree836d71c23e3781763c46fd2908f059e4b53cf77e
parent0151a470e65d63b6ae3b01ede5628c38c3b69678
Blob references for System Previews don't get a correct file extension
https://bugs.webkit.org/show_bug.cgi?id=193268
<rdar://problem/47133037>

Reviewed by Tim Horton.

Source/WebCore:

Apple platforms don't yet have a mapping from the USD MIME type to
file extensions (and we support some non-standard MIME types), which
means that downloads from Blob references don't get correctly named.

Fix this by adding an explicit mapping between System Preview types
and ".usdz".

WebKit API test: _WKDownload.SystemPreviewUSDZBlobNaming

* platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::isSystemPreviewMIMEType): Remove USE(SYSTEM_PREVIEW) since
this applies to macOS and iOS now.
* platform/MIMETypeRegistry.h:
* platform/cocoa/MIMETypeRegistryCocoa.mm:
(WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType): Add a mapping
for USDZ.

Tools:

New test that a Blob download of a USDZ file gets named correctly.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
(-[BlobWithUSDZExtensionDownloadDelegate _download:decideDestinationWithSuggestedFilename:completionHandler:]):
(-[BlobWithUSDZExtensionDownloadDelegate _downloadDidFinish:]):
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/SystemPreviewBlobNaming.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239758 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/MIMETypeRegistry.cpp
Source/WebCore/platform/MIMETypeRegistry.h
Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemPreviewBlobNaming.html [new file with mode: 0644]