WebKit Bugzilla
Attachment 358655 Details for
Bug 193268
: Blob references for System Previews don't get a correct file extension
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193268-20190109115231.patch (text/plain), 13.95 KB, created by
Dean Jackson
on 2019-01-08 16:52:32 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Dean Jackson
Created:
2019-01-08 16:52:32 PST
Size:
13.95 KB
patch
obsolete
>Subversion Revision: 239689 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b6677d6a84667a8554aaceec8bd2d5204e702a1f..476ef3c524dbd11a2570bef6be015838904b2e9d 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,28 @@ >+2019-01-08 Dean Jackson <dino@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ 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. >+ > 2019-01-07 Antti Koivisto <antti@apple.com> > > UI process side scrollbars for UI side compositing on Mac >diff --git a/Source/WebCore/platform/MIMETypeRegistry.cpp b/Source/WebCore/platform/MIMETypeRegistry.cpp >index 15d3028611309031ea128aeb2cf4761e876d8a7c..fdef56fa50c6daf01530275f547a4cbfdf58d67e 100644 >--- a/Source/WebCore/platform/MIMETypeRegistry.cpp >+++ b/Source/WebCore/platform/MIMETypeRegistry.cpp >@@ -651,7 +651,6 @@ const String& defaultMIMEType() > return defaultMIMEType; > } > >-#if USE(SYSTEM_PREVIEW) > const HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::systemPreviewMIMETypes() > { > static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> systemPreviewMIMETypes = std::initializer_list<String> { >@@ -670,7 +669,6 @@ bool MIMETypeRegistry::isSystemPreviewMIMEType(const String& mimeType) > return false; > return systemPreviewMIMETypes().contains(mimeType); > } >-#endif > > #if !USE(CURL) > >diff --git a/Source/WebCore/platform/MIMETypeRegistry.h b/Source/WebCore/platform/MIMETypeRegistry.h >index 19331ba072090d74d32178d70677c51b4f125714..876c38280d433789f112ce071c9dc8eb37dfbd42 100644 >--- a/Source/WebCore/platform/MIMETypeRegistry.h >+++ b/Source/WebCore/platform/MIMETypeRegistry.h >@@ -87,9 +87,7 @@ public: > static bool isPostScriptMIMEType(const String& mimeType); > WEBCORE_EXPORT static bool isPDFOrPostScriptMIMEType(const String& mimeType); > >-#if USE(SYSTEM_PREVIEW) > WEBCORE_EXPORT static bool isSystemPreviewMIMEType(const String& mimeType); >-#endif > > // Check to see if a MIME type is suitable for being shown inside a page. > // Returns true if any of isSupportedImageMIMEType(), isSupportedNonImageMIMEType(), >@@ -114,10 +112,7 @@ public: > WEBCORE_EXPORT static const HashSet<String, ASCIICaseInsensitiveHash>& supportedMediaMIMETypes(); > WEBCORE_EXPORT static const HashSet<String, ASCIICaseInsensitiveHash>& pdfMIMETypes(); > WEBCORE_EXPORT static const HashSet<String, ASCIICaseInsensitiveHash>& unsupportedTextMIMETypes(); >- >-#if USE(SYSTEM_PREVIEW) >- WEBCORE_EXPORT const static HashSet<String, ASCIICaseInsensitiveHash>& systemPreviewMIMETypes(); >-#endif >+ WEBCORE_EXPORT static const HashSet<String, ASCIICaseInsensitiveHash>& systemPreviewMIMETypes(); > > // FIXME: WebKit coding style says we should not have the word "get" in the name of this function. > // FIXME: Unclear what the concept of a normalized MIME type is; currently it's a platform-specific notion. >diff --git a/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm b/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm >index a7306b52ffb9e8aeac98e7738f38b848e745303d..a87cf5c4e8f856df7c79001143f3c744c7ff806a 100644 >--- a/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm >+++ b/Source/WebCore/platform/cocoa/MIMETypeRegistryCocoa.mm >@@ -52,6 +52,11 @@ Vector<String> MIMETypeRegistry::getExtensionsForMIMEType(const String& type) > > String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type) > { >+ // System Previews accept some non-standard MIMETypes, so we can't rely on >+ // the file type mappings. >+ if (isSystemPreviewMIMEType(type)) >+ return "usdz"_s; >+ > return [[NSURLFileTypeMappings sharedMappings] preferredExtensionForMIMEType:(NSString *)type]; > } > >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index d5fb0a31b6994b44f76d69820541babf494cb739..5930e4addf078b3c07bbcaee6e39a2d39f869c09 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,20 @@ >+2019-01-08 Dean Jackson <dino@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ 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. >+ > 2019-01-07 Eric Carlson <eric.carlson@apple.com> > > A MediaTime timescale must never be zero >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index b6984b7e239d09934089155cecfafb7739670a03..bf4167c5badea77f7d3fca3e140db2a2c1a08ab7 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -128,6 +128,7 @@ > 2EFF06CD1D8A429A0004BB30 /* input-field-in-scrollable-document.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EFF06CC1D8A42910004BB30 /* input-field-in-scrollable-document.html */; }; > 2EFF06D41D8AEDBB0004BB30 /* TestWKWebView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EFF06D31D8AEDBB0004BB30 /* TestWKWebView.mm */; }; > 2EFF06D71D8AF34A0004BB30 /* WKWebViewCandidateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EFF06D61D8AF34A0004BB30 /* WKWebViewCandidateTests.mm */; }; >+ 313C3A0221E567C300DBA86E /* SystemPreviewBlobNaming.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 313C3A0121E5677A00DBA86E /* SystemPreviewBlobNaming.html */; }; > 315118101DB1AE4000176304 /* ExtendedColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3151180F1DB1ADD500176304 /* ExtendedColor.cpp */; }; > 315231CA1EB3B3C700A22A16 /* GPULegacyCommandQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 315231C91EB3B3C700A22A16 /* GPULegacyCommandQueue.mm */; }; > 3162AE9C1E6F2FF5000E4DBC /* GPULegacyDevice.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3162AE9B1E6F2FCE000E4DBC /* GPULegacyDevice.mm */; }; >@@ -981,8 +982,6 @@ > dstPath = TestWebKitAPI.resources; > dstSubfolderSpec = 7; > files = ( >- C9C9A91D21DED7A000FDE96E /* video-with-play-button.html in Copy Resources */, >- C9C9A91B21DED28700FDE96E /* audio-with-play-button.html in Copy Resources */, > 55A817FF2181021A0004A39A /* 100x100-red.tga in Copy Resources */, > 1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */, > 55A81800218102210004A39A /* 400x400-green.png in Copy Resources */, >@@ -1002,6 +1001,7 @@ > 37137E4B21124D01002BEEA4 /* AttrStyle.html in Copy Resources */, > CD9E292E1C90C33F000BB800 /* audio-only.html in Copy Resources */, > C944160021430E8900B1EDDA /* audio-with-controls.html in Copy Resources */, >+ C9C9A91B21DED28700FDE96E /* audio-with-play-button.html in Copy Resources */, > CD57779C211CE91F001B371E /* audio-with-web-audio.html in Copy Resources */, > 76E182DF154767E600F1FADD /* auto-submitting-form.html in Copy Resources */, > F41AB99F1EF4696B0083FA08 /* autofocus-contenteditable.html in Copy Resources */, >@@ -1242,6 +1242,7 @@ > 9BD6D3A31F7B218300BD4962 /* sunset-in-cupertino-200px.png in Copy Resources */, > 9BD6D3A41F7B218300BD4962 /* sunset-in-cupertino-400px.gif in Copy Resources */, > 9BD6D3A51F7B218300BD4962 /* sunset-in-cupertino-600px.jpg in Copy Resources */, >+ 313C3A0221E567C300DBA86E /* SystemPreviewBlobNaming.html in Copy Resources */, > CD59F53519E9110D00CF1835 /* test-mse.mp4 in Copy Resources */, > C95984F71E36BCEF002C0D45 /* test-without-audio-track.mp4 in Copy Resources */, > 524BBCA119E30C77002F1AF1 /* test.mp4 in Copy Resources */, >@@ -1258,6 +1259,7 @@ > CD321B041E3A85FA00EB21C8 /* video-with-muted-audio-and-webaudio.html in Copy Resources */, > CDB4115A1E0B00DB00EAD352 /* video-with-muted-audio.html in Copy Resources */, > CD758A6F20572EA00071834A /* video-with-paused-audio-and-playing-muted.html in Copy Resources */, >+ C9C9A91D21DED7A000FDE96E /* video-with-play-button.html in Copy Resources */, > CDC8E4961BC6F10800594FEC /* video-without-audio.html in Copy Resources */, > CDC8E4971BC6F10800594FEC /* video-without-audio.mp4 in Copy Resources */, > 2EBD9D0A2134730D002DA758 /* video.html in Copy Resources */, >@@ -1437,6 +1439,7 @@ > 2EFF06D21D8AEDBB0004BB30 /* TestWKWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestWKWebView.h; path = cocoa/TestWKWebView.h; sourceTree = "<group>"; }; > 2EFF06D31D8AEDBB0004BB30 /* TestWKWebView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestWKWebView.mm; path = cocoa/TestWKWebView.mm; sourceTree = "<group>"; }; > 2EFF06D61D8AF34A0004BB30 /* WKWebViewCandidateTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewCandidateTests.mm; sourceTree = "<group>"; }; >+ 313C3A0121E5677A00DBA86E /* SystemPreviewBlobNaming.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = SystemPreviewBlobNaming.html; sourceTree = "<group>"; }; > 3151180F1DB1ADD500176304 /* ExtendedColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtendedColor.cpp; sourceTree = "<group>"; }; > 315231C91EB3B3C700A22A16 /* GPULegacyCommandQueue.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPULegacyCommandQueue.mm; sourceTree = "<group>"; }; > 3162AE9B1E6F2FCE000E4DBC /* GPULegacyDevice.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPULegacyDevice.mm; sourceTree = "<group>"; }; >@@ -2930,6 +2933,7 @@ > 9BD6D3A01F7B202000BD4962 /* sunset-in-cupertino-200px.png */, > 9BD6D39F1F7B202000BD4962 /* sunset-in-cupertino-400px.gif */, > 9BD6D39E1F7B201E00BD4962 /* sunset-in-cupertino-600px.jpg */, >+ 313C3A0121E5677A00DBA86E /* SystemPreviewBlobNaming.html */, > 2E9896141D8F092B00739892 /* text-and-password-inputs.html */, > F4CD74C520FDACF500DE3794 /* text-with-async-script.html */, > F44C7A0420FAAE320014478C /* text-with-deferred-script.html */, >@@ -3316,8 +3320,8 @@ > C95984F61E36BCD7002C0D45 /* test-without-audio-track.mp4 */, > 524BBCA019E30C63002F1AF1 /* test.mp4 */, > 7AE9E5081AE5AE8B00CF874B /* test.pdf */, >- 07CD32F72065B72A0064A4BE /* video.html */, > C9C9A91C21DED79400FDE96E /* video-with-play-button.html */, >+ 07CD32F72065B72A0064A4BE /* video.html */, > 1C2B81841C8924A200A5529F /* webfont.html */, > ); > name = Resources; >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm >index 21b35ce1c86f774d940885fcd6cc43c8952cc194..60cc93b340dd680941c41a2a5aa0ba923b5aec64 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm >@@ -621,5 +621,38 @@ TEST(_WKDownload, DownloadCanceledWhileDecidingDestination) > [TestProtocol unregister]; > } > >+@interface BlobWithUSDZExtensionDownloadDelegate : NSObject <_WKDownloadDelegate> >+@end >+ >+@implementation BlobWithUSDZExtensionDownloadDelegate { >+ String _destinationPath; >+} >+ >+- (void)_download:(_WKDownload *)download decideDestinationWithSuggestedFilename:(NSString *)filename completionHandler:(void (^)(BOOL allowOverwrite, NSString *destination))completionHandler >+{ >+ EXPECT_TRUE([filename hasSuffix:@".usdz"]); >+ >+ WebCore::FileSystem::PlatformFileHandle fileHandle; >+ _destinationPath = WebCore::FileSystem::openTemporaryFile(filename, fileHandle); >+ EXPECT_TRUE(fileHandle != WebCore::FileSystem::invalidPlatformFileHandle); >+ WebCore::FileSystem::closeFile(fileHandle); >+ >+ completionHandler(YES, _destinationPath); >+} >+ >+- (void)_downloadDidFinish:(_WKDownload *)download >+{ >+ WebCore::FileSystem::deleteFile(_destinationPath); >+ isDone = true; >+} >+ >+@end >+ >+TEST(_WKDownload, SystemPreviewUSDZBlobNaming) >+{ >+ NSURL *originalURL = [[NSBundle mainBundle] URLForResource:@"SystemPreviewBlobNaming" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]; >+ runTest(adoptNS([[DownloadBlobURLNavigationDelegate alloc] init]).get(), adoptNS([[BlobWithUSDZExtensionDownloadDelegate alloc] init]).get(), originalURL); >+} >+ > #endif > #endif >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemPreviewBlobNaming.html b/Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemPreviewBlobNaming.html >new file mode 100644 >index 0000000000000000000000000000000000000000..f0e470e84e3ac7a3556591f39bf79bdc986ed84d >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemPreviewBlobNaming.html >@@ -0,0 +1,15 @@ >+<!DOCTYPE html> >+<html> >+<body> >+<a id="href" href="simple.html">download</a> >+<script> >+ var element = document.getElementById("href"); >+ var data = "fake data"; >+ var blob = new Blob([data], {type: "model/vnd.usdz+zip"}); >+ var url = window.URL.createObjectURL(blob); >+ >+ element.href = url; >+ element.click(); >+</script> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
thorton
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193268
: 358655