WebKit Bugzilla
Attachment 348155 Details for
Bug 188903
: [Cocoa] Exception (fileType 'dyn.agq8u' is not a valid UTI) raised when dragging an attachment whose file wrapper is a directory
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Rebase on trunk
bug-188903-20180827095626.patch (text/plain), 108.07 KB, created by
Wenson Hsieh
on 2018-08-27 09:56:27 PDT
(
hide
)
Description:
Rebase on trunk
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2018-08-27 09:56:27 PDT
Size:
108.07 KB
patch
obsolete
>Subversion Revision: 235375 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index dfa2cf211ff14fc4247239141cbc915a7761e887..ddd59544be22cfe140743d00002e9934253a817e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,45 @@ >+2018-08-27 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [Cocoa] Exception (fileType 'dyn.agq8u' is not a valid UTI) raised when dragging an attachment whose file wrapper is a directory >+ https://bugs.webkit.org/show_bug.cgi?id=188903 >+ <rdar://problem/43702993> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Fixes the exception for attachments that are created when dropping files with extensions that don't map to any >+ known UTIs, and when dropping folders. See below for more detail. >+ >+ Tests: WKAttachmentTests.InsertFolderAndFileWithUnknownExtension >+ WKAttachmentTests.DropFolderAsAttachmentAndMoveByDragging >+ WKAttachmentTests.ChangeAttachmentDataAndFileInformation >+ >+ * editing/Editor.cpp: >+ (WebCore::Editor::insertAttachment): >+ * editing/Editor.h: >+ * editing/cocoa/WebContentReaderCocoa.mm: >+ (WebCore::WebContentReader::readFilePaths): >+ >+ When creating an attachment by dropping or pasting a file backed by a file path, handle the cases where⦠>+ (1) the dropped path is a directory, by setting the UTI to "public.directory". This allows us to show a >+ folder icon for the dropped attachment element on macOS. >+ (2) the dropped path is a file whose UTI is unknown, by defaulting to "public.data". >+ >+ By ensuring that the UTI of a dropped file-backed attachment is set to a concrete type in any case, we avoid an >+ exception when dragging the attachment on macOS, and on iOS, avoid silently failing to drag an attachment. >+ >+ * html/HTMLAttachmentElement.cpp: >+ (WebCore::HTMLAttachmentElement::updateAttributes): >+ >+ Change this method to take an optional file size (the subtitle attribute will only be set if the file size is >+ not `std::nullopt`). Furthermore, allow callers of this method to clear attributes on the attachment element by >+ passing in `std::nullopt` for any of the three arguments. This allows us to handle the case where an >+ attachment's file wrapper is changed from a regular file to a folder whose total size is currently unknown. >+ Instead of showing "0 bytes", we'll simply refrain from showing a subtitle at all (in the future, this should >+ be improved by implementing a way to estimate the size of the files in the folder, or perhaps show the number of >+ items in the folder as the subtitle). >+ >+ * html/HTMLAttachmentElement.h: >+ > 2018-08-27 Wenson Hsieh <wenson_hsieh@apple.com> > > [Attachment Support] [WK2] Images copied from Mail message view paste with the wrong file name in compose >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 663761812267375d98d524083bfe19da0aaadc48..9e527f935bf3ca4ddc9eb929663c95fc084f7424 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,71 @@ >+2018-08-27 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [Cocoa] Exception (fileType 'dyn.agq8u' is not a valid UTI) raised when dragging an attachment whose file wrapper is a directory >+ https://bugs.webkit.org/show_bug.cgi?id=188903 >+ <rdar://problem/43702993> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Fixes the bug by supporting NSFileWrappers of type directory, as well as NSFileWrappers with file that do not >+ map to concrete type identifiers. Among other things, this patch ensures that: >+ - Inserting a directory file wrapper (or using -setFileWrapper:â¦: to change an existing _WKAttachment's >+ file wrapper to a directory) does not cause the attachment element to show "0 bytes" as the subtitle. >+ - In the above scenario, we also won't end up with a missing "type" attribute for the attachment element, >+ as well as a corresponding API::Attachment::contentType() that's an empty string. >+ - Dropping or pasting attachments backed by paths on disk also doesn't trigger these problems, if the path >+ is a directory or of unknown file type. >+ >+ Changes are verified by 2 new API tests. >+ >+ * UIProcess/API/APIAttachment.cpp: >+ (API::Attachment::updateAttributes): >+ (API::Attachment::fileSizeForDisplay const): >+ * UIProcess/API/APIAttachment.h: >+ * UIProcess/API/Cocoa/APIAttachmentCocoa.mm: >+ (API::Attachment::setFileWrapperAndUpdateContentType): >+ >+ Add a helper that sets the file wrapper to the given NSFileWrapper, and either sets the content type to the >+ given content type if it's specified, or infers it from the file extension of the new NSFileWrapper. Invoked >+ whenever an NSFileWrapper and content type combination is set on an API attachment via WebKit SPI. >+ >+ (API::Attachment::fileSizeForDisplay const): >+ >+ Returns a file size to be displayed in the attachment element's subtitle. This returns an optional file size, >+ where `std::nullopt` indicates that there should not be a file size shown. For now, this returns `std::nullopt` >+ for directory file wrappers, though in the future, this should be done only in cases where we don't immediately >+ have a size estimate for the file wrapper. >+ >+ * UIProcess/API/Cocoa/WKWebView.mm: >+ (-[WKWebView _insertAttachmentWithFileWrapper:contentType:options:completion:]): >+ >+ Use API::Attachment::setFileWrapperAndUpdateContentType() instead of trying to come up with a fallback UTI. >+ >+ * UIProcess/API/Cocoa/_WKAttachment.mm: >+ (-[_WKAttachment setFileWrapper:contentType:completion:]): >+ >+ Use API::Attachment::setFileWrapperAndUpdateContentType() instead of trying to come up with a fallback UTI. >+ >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::insertAttachment): >+ >+ Remove the separate arguments for file size, content type, and file name, and instead get them from the given >+ API Attachment object. >+ >+ (WebKit::WebPageProxy::updateAttachmentAttributes): >+ >+ Remove separate arguments for file size, content type and file name and just take an API::Attachment instead. >+ These separate pieces of information can simply be asked from the Attachment itself. >+ >+ * UIProcess/WebPageProxy.h: >+ * WebProcess/WebPage/WebPage.cpp: >+ (WebKit::WebPage::insertAttachment): >+ (WebKit::WebPage::updateAttachmentAttributes): >+ >+ Adjust some interfaces here to allow the displayed file size to be optional. >+ >+ * WebProcess/WebPage/WebPage.h: >+ * WebProcess/WebPage/WebPage.messages.in: >+ > 2018-08-27 Sihui Liu <sihui_liu@apple.com> > > Don't launch network process in WebCookieManagerProxy::setHTTPCookieAcceptPolicy >diff --git a/Source/WebCore/editing/Editor.cpp b/Source/WebCore/editing/Editor.cpp >index 176a4a0528bc59facba2f113b5e6426d8f3d6b31..4eca9150d6a7990dec2741ca36d4c68a9f57567a 100644 >--- a/Source/WebCore/editing/Editor.cpp >+++ b/Source/WebCore/editing/Editor.cpp >@@ -3876,11 +3876,11 @@ void Editor::notifyClientOfAttachmentUpdates() > } > } > >-void Editor::insertAttachment(const String& identifier, const AttachmentDisplayOptions&, uint64_t fileSize, const String& fileName, std::optional<String>&& explicitContentType) >+void Editor::insertAttachment(const String& identifier, const AttachmentDisplayOptions&, std::optional<uint64_t>&& fileSize, const String& fileName, const String& contentType) > { > auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document()); > attachment->setUniqueIdentifier(identifier); >- attachment->updateAttributes(fileSize, WTFMove(explicitContentType), fileName); >+ attachment->updateAttributes(WTFMove(fileSize), contentType, fileName); > > auto fragmentToInsert = document().createDocumentFragment(); > fragmentToInsert->appendChild(attachment.get()); >diff --git a/Source/WebCore/editing/Editor.h b/Source/WebCore/editing/Editor.h >index 1ec120bef33da8ecab5e894ab55efaab95128cac..6f5abbac2da99699e7a52e500bded4bfe46d1280 100644 >--- a/Source/WebCore/editing/Editor.h >+++ b/Source/WebCore/editing/Editor.h >@@ -503,7 +503,7 @@ public: > bool isGettingDictionaryPopupInfo() const { return m_isGettingDictionaryPopupInfo; } > > #if ENABLE(ATTACHMENT_ELEMENT) >- WEBCORE_EXPORT void insertAttachment(const String& identifier, const AttachmentDisplayOptions&, uint64_t fileSize, const String& fileName, std::optional<String>&& explicitContentType = std::nullopt); >+ WEBCORE_EXPORT void insertAttachment(const String& identifier, const AttachmentDisplayOptions&, std::optional<uint64_t>&& fileSize, const String& fileName, const String& contentType); > void registerAttachmentIdentifier(const String&, const String& /* contentType */, const String& /* preferredFileName */, Ref<SharedBuffer>&&); > void registerAttachmentIdentifier(const String&, const String& /* contentType */, const String& /* filePath */); > void cloneAttachmentData(const String& fromIdentifier, const String& toIdentifier); >diff --git a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm b/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm >index 6109c3815a075f3f913800808e380d2fcc8de1e1..e8850843019b176890da6065fa5f00434c46785d 100644 >--- a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm >+++ b/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm >@@ -703,9 +703,18 @@ bool WebContentReader::readFilePaths(const Vector<String>& paths) > for (auto& path : paths) { > auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document); > if (supportsClientSideAttachmentData(frame)) { >- long long fileSize { 0 }; >- FileSystem::getFileSize(path, fileSize); >- auto contentType = File::contentTypeForFile(path); >+ String contentType; >+ std::optional<uint64_t> fileSizeForDisplay; >+ if (FileSystem::fileIsDirectory(path, FileSystem::ShouldFollowSymbolicLinks::Yes)) >+ contentType = kUTTypeDirectory; >+ else { >+ long long fileSize; >+ FileSystem::getFileSize(path, fileSize); >+ fileSizeForDisplay = fileSize; >+ contentType = File::contentTypeForFile(path); >+ if (contentType.isEmpty()) >+ contentType = kUTTypeData; >+ } > frame.editor().registerAttachmentIdentifier(attachment->ensureUniqueIdentifier(), contentType, path); > if (contentTypeIsSuitableForInlineImageRepresentation(contentType)) { > auto image = HTMLImageElement::create(document); >@@ -713,7 +722,7 @@ bool WebContentReader::readFilePaths(const Vector<String>& paths) > image->setAttachmentElement(WTFMove(attachment)); > fragment->appendChild(image); > } else { >- attachment->updateAttributes(fileSize, contentType, FileSystem::pathGetFileName(path)); >+ attachment->updateAttributes(WTFMove(fileSizeForDisplay), contentType, FileSystem::pathGetFileName(path)); > fragment->appendChild(attachment); > } > } else { >diff --git a/Source/WebCore/html/HTMLAttachmentElement.cpp b/Source/WebCore/html/HTMLAttachmentElement.cpp >index 405cb3eb9e217be39265733bec7c5b6082a9eda1..3edbc51dad889ef6f8304b021a1d5254ca7cd866 100644 >--- a/Source/WebCore/html/HTMLAttachmentElement.cpp >+++ b/Source/WebCore/html/HTMLAttachmentElement.cpp >@@ -144,15 +144,23 @@ String HTMLAttachmentElement::attachmentPath() const > return attributeWithoutSynchronization(webkitattachmentpathAttr); > } > >-void HTMLAttachmentElement::updateAttributes(uint64_t fileSize, std::optional<String>&& newContentType, std::optional<String>&& newFilename) >+void HTMLAttachmentElement::updateAttributes(std::optional<uint64_t>&& newFileSize, std::optional<String>&& newContentType, std::optional<String>&& newFilename) > { > if (newFilename) > setAttributeWithoutSynchronization(HTMLNames::titleAttr, *newFilename); >+ else >+ removeAttribute(HTMLNames::titleAttr); > > if (newContentType) > setAttributeWithoutSynchronization(HTMLNames::typeAttr, *newContentType); >+ else >+ removeAttribute(HTMLNames::typeAttr); >+ >+ if (newFileSize) >+ setAttributeWithoutSynchronization(HTMLNames::subtitleAttr, fileSizeDescription(*newFileSize)); >+ else >+ removeAttribute(HTMLNames::subtitleAttr); > >- setAttributeWithoutSynchronization(HTMLNames::subtitleAttr, fileSizeDescription(fileSize)); > if (auto* renderer = this->renderer()) > renderer->invalidate(); > } >diff --git a/Source/WebCore/html/HTMLAttachmentElement.h b/Source/WebCore/html/HTMLAttachmentElement.h >index 5b64192bc56f94a36ec3d10a88257375e83f3b85..61ea15a928f0baa452e9dffe179acf4eed32762d 100644 >--- a/Source/WebCore/html/HTMLAttachmentElement.h >+++ b/Source/WebCore/html/HTMLAttachmentElement.h >@@ -49,7 +49,7 @@ public: > const String& uniqueIdentifier() const { return m_uniqueIdentifier; } > void setUniqueIdentifier(const String& uniqueIdentifier) { m_uniqueIdentifier = uniqueIdentifier; } > >- WEBCORE_EXPORT void updateAttributes(uint64_t fileSize, std::optional<String>&& newContentType = std::nullopt, std::optional<String>&& newFilename = std::nullopt); >+ WEBCORE_EXPORT void updateAttributes(std::optional<uint64_t>&& newFileSize = std::nullopt, std::optional<String>&& newContentType = std::nullopt, std::optional<String>&& newFilename = std::nullopt); > > InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final; > void removedFromAncestor(RemovalType, ContainerNode&) final; >diff --git a/Source/WebKit/UIProcess/API/APIAttachment.cpp b/Source/WebKit/UIProcess/API/APIAttachment.cpp >index b6150483de5f66adee7cc6f4abfd0e0365b6a432..073a44ce4486cafd62e25cbde8e9fbc93bcc7f46 100644 >--- a/Source/WebKit/UIProcess/API/APIAttachment.cpp >+++ b/Source/WebKit/UIProcess/API/APIAttachment.cpp >@@ -57,17 +57,14 @@ void Attachment::setDisplayOptions(WebCore::AttachmentDisplayOptions options, Fu > callback(WebKit::CallbackBase::Error::OwnerWasInvalidated); > } > >-void Attachment::updateAttributes(uint64_t fileSize, const WTF::String& newContentType, const WTF::String& newFilename, Function<void(WebKit::CallbackBase::Error)>&& callback) >+void Attachment::updateAttributes(Function<void(WebKit::CallbackBase::Error)>&& callback) > { >- setContentType(newContentType); >- setFilePath({ }); >- >- auto optionalNewContentType = newContentType.isNull() ? std::nullopt : std::optional<WTF::String> { newContentType }; >- auto optionalNewFilename = newFilename.isNull() ? std::nullopt : std::optional<WTF::String> { newFilename }; >- if (m_webPage) >- m_webPage->updateAttachmentAttributes(m_identifier, fileSize, WTFMove(optionalNewContentType), WTFMove(optionalNewFilename), WTFMove(callback)); >- else >+ if (!m_webPage) { > callback(WebKit::CallbackBase::Error::OwnerWasInvalidated); >+ return; >+ } >+ >+ m_webPage->updateAttachmentAttributes(*this, WTFMove(callback)); > } > > void Attachment::invalidate() >@@ -93,6 +90,11 @@ WTF::String Attachment::fileName() const > return { }; > } > >+std::optional<uint64_t> Attachment::fileSizeForDisplay() const >+{ >+ return std::nullopt; >+} >+ > #endif // !PLATFORM(COCOA) > > } >diff --git a/Source/WebKit/UIProcess/API/APIAttachment.h b/Source/WebKit/UIProcess/API/APIAttachment.h >index 71741ff4134dfa45e2add77248d789971f546384..8443f430bc9363b93b08a37a343210f0bcc2dfc4 100644 >--- a/Source/WebKit/UIProcess/API/APIAttachment.h >+++ b/Source/WebKit/UIProcess/API/APIAttachment.h >@@ -56,7 +56,7 @@ public: > > const WTF::String& identifier() const { return m_identifier; } > void setDisplayOptions(WebCore::AttachmentDisplayOptions, Function<void(WebKit::CallbackBase::Error)>&&); >- void updateAttributes(uint64_t fileSize, const WTF::String& newContentType, const WTF::String& newFilename, Function<void(WebKit::CallbackBase::Error)>&&); >+ void updateAttributes(Function<void(WebKit::CallbackBase::Error)>&&); > > void invalidate(); > bool isValid() const { return !!m_webPage; } >@@ -64,6 +64,7 @@ public: > #if PLATFORM(COCOA) > NSFileWrapper *fileWrapper() const { return m_fileWrapper.get(); } > void setFileWrapper(NSFileWrapper *fileWrapper) { m_fileWrapper = fileWrapper; } >+ void setFileWrapperAndUpdateContentType(NSFileWrapper *, NSString *contentType); > WTF::String utiType() const; > #endif > WTF::String mimeType() const; >@@ -78,6 +79,8 @@ public: > InsertionState insertionState() const { return m_insertionState; } > void setInsertionState(InsertionState state) { m_insertionState = state; } > >+ std::optional<uint64_t> fileSizeForDisplay() const; >+ > private: > explicit Attachment(const WTF::String& identifier, WebKit::WebPageProxy&); > >diff --git a/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm b/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm >index 9e8b588fed2aaed0049c0d50e31ac4c41a05d520..51740d7e22ffadc2467640215cfc80c971b5e958 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm >@@ -74,4 +74,34 @@ WTF::String Attachment::fileName() const > return [m_fileWrapper preferredFilename]; > } > >+void Attachment::setFileWrapperAndUpdateContentType(NSFileWrapper *fileWrapper, NSString *contentType) >+{ >+ if (!contentType.length) { >+ if (fileWrapper.directory) >+ contentType = (NSString *)kUTTypeDirectory; >+ else if (fileWrapper.regularFile) { >+ if (NSString *pathExtension = (fileWrapper.filename.length ? fileWrapper.filename : fileWrapper.preferredFilename).pathExtension) >+ contentType = WebCore::MIMETypeRegistry::getMIMETypeForExtension(pathExtension); >+ if (!contentType.length) >+ contentType = (NSString *)kUTTypeData; >+ } >+ } >+ >+ setContentType(contentType); >+ setFileWrapper(fileWrapper); >+} >+ >+std::optional<uint64_t> Attachment::fileSizeForDisplay() const >+{ >+ if (![m_fileWrapper isRegularFile]) { >+ // FIXME: We should display a size estimate for directory-type file wrappers. >+ return std::nullopt; >+ } >+ >+ if (auto fileSize = [[m_fileWrapper fileAttributes][NSFileSize] unsignedLongLongValue]) >+ return fileSize; >+ >+ return [m_fileWrapper regularFileContents].length; >+} >+ > } // namespace API >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >index 7b6ccbe2d0d5c17d4fe5206a636c56e52a69e65d..2fa783ffea2a531a952b1c346455be12910212da 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >@@ -4454,18 +4454,8 @@ WEBCORE_COMMAND(yankAndSelect) > auto identifier = createCanonicalUUIDString(); > auto coreOptions = options ? options.coreDisplayOptions : WebCore::AttachmentDisplayOptions { }; > auto attachment = API::Attachment::create(identifier, *_page); >- attachment->setFileWrapper(fileWrapper); >- >- if (!contentType.length) { >- if (NSString *pathExtension = (fileWrapper.filename.length ? fileWrapper.filename : fileWrapper.preferredFilename).pathExtension) >- contentType = WebCore::MIMETypeRegistry::getMIMETypeForExtension(pathExtension); >- } >- >- auto fileSize = [[[fileWrapper fileAttributes] objectForKey:NSFileSize] unsignedLongLongValue]; >- if (!fileSize && fileWrapper.regularFile) >- fileSize = fileWrapper.regularFileContents.length; >- >- _page->insertAttachment(attachment.copyRef(), coreOptions, fileSize, [fileWrapper preferredFilename], contentType.length ? std::optional<String> { contentType } : std::nullopt, [capturedHandler = makeBlockPtr(completionHandler)] (WebKit::CallbackBase::Error error) { >+ attachment->setFileWrapperAndUpdateContentType(fileWrapper, contentType); >+ _page->insertAttachment(attachment.copyRef(), coreOptions, [capturedHandler = makeBlockPtr(completionHandler)] (WebKit::CallbackBase::Error error) { > if (capturedHandler) > capturedHandler(error == WebKit::CallbackBase::Error::None); > }); >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm >index 7df48b2955dad9ecdc7e2ede662a51af0bf4fd3e..0ca3d539386155c4aa40a49dc389457360b62e4b 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm >@@ -157,17 +157,11 @@ static const NSInteger InvalidAttachmentErrorCode = 2; > return; > } > >- auto fileSize = [fileWrapper.fileAttributes[NSFileSize] unsignedLongLongValue]; >- if (!fileSize && fileWrapper.regularFile) >- fileSize = fileWrapper.regularFileContents.length; >- >- if (!contentType.length) { >- if (NSString *pathExtension = (fileWrapper.filename.length ? fileWrapper.filename : fileWrapper.preferredFilename).pathExtension) >- contentType = WebCore::MIMETypeRegistry::getMIMETypeForExtension(pathExtension); >- } >- >- _attachment->setFileWrapper(fileWrapper); >- _attachment->updateAttributes(fileSize, contentType, fileWrapper.preferredFilename, [capturedBlock = makeBlockPtr(completionHandler)] (auto error) { >+ // This file path member is only populated when the attachment is generated upon dropping files. When data is specified via NSFileWrapper >+ // from the SPI client, the corresponding file path of the data is unknown, if it even exists at all. >+ _attachment->setFilePath({ }); >+ _attachment->setFileWrapperAndUpdateContentType(fileWrapper, contentType); >+ _attachment->updateAttributes([capturedBlock = makeBlockPtr(completionHandler)] (auto error) { > if (!capturedBlock) > return; > >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index bf6cf0fdf51b7c26d30c947a0d0147b75dbc617b..fa8124c63675a8ac2ef8568b703f66ba3c34d598 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -7751,21 +7751,17 @@ RefPtr<API::Attachment> WebPageProxy::attachmentForIdentifier(const String& iden > return m_attachmentIdentifierToAttachmentMap.get(identifier); > } > >-void WebPageProxy::insertAttachment(Ref<API::Attachment>&& attachment, const AttachmentDisplayOptions& options, uint64_t fileSize, const String& filename, std::optional<String> contentType, Function<void(CallbackBase::Error)>&& callback) >+void WebPageProxy::insertAttachment(Ref<API::Attachment>&& attachment, const AttachmentDisplayOptions& options, Function<void(CallbackBase::Error)>&& callback) > { > if (!isValid()) { > callback(CallbackBase::Error::OwnerWasInvalidated); > return; > } > >- if (contentType) >- attachment->setContentType(*contentType); >- > auto attachmentIdentifier = attachment->identifier(); >- m_attachmentIdentifierToAttachmentMap.set(attachmentIdentifier, WTFMove(attachment)); >- > auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivityToken()); >- m_process->send(Messages::WebPage::InsertAttachment(attachmentIdentifier, options, fileSize, filename, contentType, callbackID), m_pageID); >+ m_process->send(Messages::WebPage::InsertAttachment(attachmentIdentifier, options, attachment->fileSizeForDisplay(), attachment->fileName(), attachment->contentType(), callbackID), m_pageID); >+ m_attachmentIdentifierToAttachmentMap.set(attachmentIdentifier, WTFMove(attachment)); > } > > void WebPageProxy::setAttachmentDisplayOptions(const String& identifier, AttachmentDisplayOptions options, Function<void(CallbackBase::Error)>&& callback) >@@ -7779,7 +7775,7 @@ void WebPageProxy::setAttachmentDisplayOptions(const String& identifier, Attachm > m_process->send(Messages::WebPage::SetAttachmentDisplayOptions(identifier, options, callbackID), m_pageID); > } > >-void WebPageProxy::updateAttachmentAttributes(const String& identifier, uint64_t fileSize, std::optional<String>&& newContentType, std::optional<String>&& newFilename, Function<void(CallbackBase::Error)>&& callback) >+void WebPageProxy::updateAttachmentAttributes(const API::Attachment& attachment, Function<void(CallbackBase::Error)>&& callback) > { > if (!isValid()) { > callback(CallbackBase::Error::OwnerWasInvalidated); >@@ -7787,7 +7783,9 @@ void WebPageProxy::updateAttachmentAttributes(const String& identifier, uint64_t > } > > auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivityToken()); >- m_process->send(Messages::WebPage::UpdateAttachmentAttributes(identifier, fileSize, WTFMove(newContentType), WTFMove(newFilename), callbackID), m_pageID); >+ auto name = attachment.fileName(); >+ auto optionalName = name.isNull() ? std::nullopt : std::optional<WTF::String> { name }; >+ m_process->send(Messages::WebPage::UpdateAttachmentAttributes(attachment.identifier(), attachment.fileSizeForDisplay(), attachment.contentType(), WTFMove(optionalName), callbackID), m_pageID); > } > > void WebPageProxy::registerAttachmentIdentifierFromData(const String& identifier, const String& contentType, const String& preferredFileName, const IPC::DataReference& data) >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 77bd8d775618e08e362cb1614b3d65d7ce96016c..8c55d2558f8b6decd00a4c587219a400f1b0e9a1 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -1319,9 +1319,9 @@ public: > > #if ENABLE(ATTACHMENT_ELEMENT) > RefPtr<API::Attachment> attachmentForIdentifier(const String& identifier) const; >- void insertAttachment(Ref<API::Attachment>&&, const WebCore::AttachmentDisplayOptions&, uint64_t fileSize, const String& fileName, std::optional<String> contentType, Function<void(CallbackBase::Error)>&&); >+ void insertAttachment(Ref<API::Attachment>&&, const WebCore::AttachmentDisplayOptions&, Function<void(CallbackBase::Error)>&&); > void setAttachmentDisplayOptions(const String& identifier, WebCore::AttachmentDisplayOptions, Function<void(CallbackBase::Error)>&&); >- void updateAttachmentAttributes(const String& identifier, uint64_t fileSize, std::optional<String>&& newContentType, std::optional<String>&& newFilename, Function<void(CallbackBase::Error)>&&); >+ void updateAttachmentAttributes(const API::Attachment&, Function<void(CallbackBase::Error)>&&); > #endif > > #if ENABLE(APPLICATION_MANIFEST) >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index b5b711a6c658c6da12b7f4f6f5a8d8feae4f8d6f..4b5f5ab8690efe69adcd1360e7c1988adf050ff5 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -6066,10 +6066,10 @@ void WebPage::storageAccessResponse(bool wasGranted, uint64_t contextId) > > #if ENABLE(ATTACHMENT_ELEMENT) > >-void WebPage::insertAttachment(const String& identifier, const AttachmentDisplayOptions& options, uint64_t fileSize, const String& fileName, std::optional<String> contentType, CallbackID callbackID) >+void WebPage::insertAttachment(const String& identifier, const AttachmentDisplayOptions& options, std::optional<uint64_t>&& fileSize, const String& fileName, const String& contentType, CallbackID callbackID) > { > auto& frame = m_page->focusController().focusedOrMainFrame(); >- frame.editor().insertAttachment(identifier, options, fileSize, fileName, WTFMove(contentType)); >+ frame.editor().insertAttachment(identifier, options, WTFMove(fileSize), fileName, contentType); > send(Messages::WebPageProxy::VoidCallback(callbackID)); > } > >@@ -6078,11 +6078,11 @@ void WebPage::setAttachmentDisplayOptions(const String&, const AttachmentDisplay > send(Messages::WebPageProxy::VoidCallback(callbackID)); > } > >-void WebPage::updateAttachmentAttributes(const String& identifier, uint64_t fileSize, std::optional<String> newContentType, std::optional<String> newFilename, CallbackID callbackID) >+void WebPage::updateAttachmentAttributes(const String& identifier, std::optional<uint64_t>&& fileSize, const String& contentType, std::optional<String>&& newFilename, CallbackID callbackID) > { > if (auto attachment = attachmentElementWithIdentifier(identifier)) { > attachment->document().updateLayout(); >- attachment->updateAttributes(fileSize, WTFMove(newContentType), WTFMove(newFilename)); >+ attachment->updateAttributes(WTFMove(fileSize), contentType, WTFMove(newFilename)); > } > send(Messages::WebPageProxy::VoidCallback(callbackID)); > } >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index 6be1cbfc76c336976fb1f21d4091ad7616ed8f02..4d4ae851b265ecb39e0f5eea40ae01069d440081 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -1075,9 +1075,9 @@ public: > #endif > > #if ENABLE(ATTACHMENT_ELEMENT) >- void insertAttachment(const String& identifier, const WebCore::AttachmentDisplayOptions&, uint64_t fileSize, const String& fileName, std::optional<String> contentType, CallbackID); >+ void insertAttachment(const String& identifier, const WebCore::AttachmentDisplayOptions&, std::optional<uint64_t>&& fileSize, const String& fileName, const String& contentType, CallbackID); > void setAttachmentDisplayOptions(const String& identifier, const WebCore::AttachmentDisplayOptions&, CallbackID); >- void updateAttachmentAttributes(const String& identifier, uint64_t fileSize, std::optional<String> newContentType, std::optional<String> newFilename, CallbackID); >+ void updateAttachmentAttributes(const String& identifier, std::optional<uint64_t>&& fileSize, const String& contentType, std::optional<String>&& newFilename, CallbackID); > #endif > > #if ENABLE(APPLICATION_MANIFEST) >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >index 96e487ee62f5a146dada87ed9a8e19af4eddbf1a..289abda87f053b4bac25bead05524647d974659f 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >@@ -510,9 +510,9 @@ messages -> WebPage LegacyReceiver { > #endif > > #if ENABLE(ATTACHMENT_ELEMENT) >- InsertAttachment(String identifier, struct WebCore::AttachmentDisplayOptions options, uint64_t fileSize, String fileName, std::optional<String> contentType, WebKit::CallbackID callbackID) >+ InsertAttachment(String identifier, struct WebCore::AttachmentDisplayOptions options, std::optional<uint64_t> fileSize, String fileName, String contentType, WebKit::CallbackID callbackID) > SetAttachmentDisplayOptions(String identifier, struct WebCore::AttachmentDisplayOptions options, WebKit::CallbackID callbackID) >- UpdateAttachmentAttributes(String identifier, uint64_t fileSize, std::optional<String> newContentType, std::optional<String> newFilename, WebKit::CallbackID callbackID) >+ UpdateAttachmentAttributes(String identifier, std::optional<uint64_t> fileSize, String newContentType, std::optional<String> newFilename, WebKit::CallbackID callbackID) > #endif > > #if ENABLE(APPLICATION_MANIFEST) >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index d5bd385717b23dbf94bb4a6528c3fdaf63f3b125..b20cabf4683917a35134ae75a38d644828a27d15 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,55 @@ >+2018-08-27 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [Cocoa] Exception (fileType 'dyn.agq8u' is not a valid UTI) raised when dragging an attachment whose file wrapper is a directory >+ https://bugs.webkit.org/show_bug.cgi?id=188903 >+ <rdar://problem/43702993> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add two API tests and adjust existing WKAttachment API tests. The new tests exercise the following scenarios, in >+ both iOS and macOS: >+ ⢠Dropping a folder as an attachment element, and then moving that attachment element in the document by >+ dragging and dropping. >+ ⢠Using WKWebView SPI to insert a folder and a file with an unknown extension, and then using more >+ _WKAttachment SPI to swap the attachments' backing file wrappers. >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm: >+ (webViewForTestingAttachments): >+ (-[TestWKWebView synchronouslyInsertAttachmentWithFilename:contentType:data:]): >+ (-[_WKAttachment synchronouslySetData:newContentType:newFilename:error:]): >+ (runTestWithTemporaryFolder): >+ >+ Add a helper function to run a test with a new folder path, created in the temporary directory and populated >+ with some sample content. This folder is deleted after running the test. >+ >+ (simulateFolderDragWithURL): >+ >+ Add a helper function to prepare a given DragAndDropSimulator for simulating a dragged folder from a source >+ external to the web view. >+ >+ (-[NSItemProvider registerData:type:]): >+ (platformCopyRichTextWithMultipleAttachments): >+ (platformCopyRichTextWithImage): >+ (platformCopyPNG): >+ (TestWebKitAPI::TEST): >+ >+ Add new API tests, and adjust existing tests to reflect new -setFileWrapper:â¦: behavior. Specifically, >+ ChangeAttachmentDataAndFileInformation previously required that changing a _WKAttachment's NSFileWrapper would >+ preserve the previous NSFileWrapper's preferred name if the new file wrapper does not have a preferred name, but >+ this quirk is no longer supported. >+ >+ Also add a few bridging casts for the eventual transition of TestWebKitAPI to ARC. >+ >+ * TestWebKitAPI/cocoa/DragAndDropSimulator.h: >+ >+ Add a new hook to clear any external drag information on an existing DragAndDropSimulator. This is convenient >+ when using the same DragAndDropSimulator to perform multiple drags in a single test. >+ >+ * TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm: >+ (-[DragAndDropSimulator clearExternalDragInformation]): >+ * TestWebKitAPI/mac/DragAndDropSimulatorMac.mm: >+ (-[DragAndDropSimulator clearExternalDragInformation]): >+ > 2018-08-27 Wenson Hsieh <wenson_hsieh@apple.com> > > [Attachment Support] [WK2] Images copied from Mail message view paste with the wrong file name in compose >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm >index 3f1e7e6842e734134b8e40eb68b472db383ebf85..2658cfc8b96eb8794622c0efbea6bee21d863be6 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm >@@ -155,7 +155,7 @@ static RetainPtr<TestWKWebView> webViewForTestingAttachments(CGSize webViewSize, > configuration._attachmentElementEnabled = YES; > WKPreferencesSetCustomPasteboardDataEnabled((WKPreferencesRef)[configuration preferences], YES); > >- auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, webViewSize.width, webViewSize.height) configuration:configuration]); >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, webViewSize.width, webViewSize.height) configuration:(__bridge WKWebViewConfiguration *)configuration]); > [webView synchronouslyLoadHTMLString:attachmentEditingTestMarkup]; > > return webView; >@@ -164,7 +164,7 @@ static RetainPtr<TestWKWebView> webViewForTestingAttachments(CGSize webViewSize, > static RetainPtr<TestWKWebView> webViewForTestingAttachments(CGSize webViewSize) > { > auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >- return webViewForTestingAttachments(webViewSize, configuration.get()); >+ return webViewForTestingAttachments(webViewSize, (__bridge WKWebViewConfiguration *)configuration.get()); > } > > static RetainPtr<TestWKWebView> webViewForTestingAttachments() >@@ -274,7 +274,7 @@ static NSData *testPDFData() > auto fileWrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:data]); > if (filename) > [fileWrapper setPreferredFilename:filename]; >- RetainPtr<_WKAttachment> attachment = [self _insertAttachmentWithFileWrapper:fileWrapper.get() contentType:contentType options:nil completion:^(BOOL) { >+ RetainPtr<_WKAttachment> attachment = [self _insertAttachmentWithFileWrapper:(__bridge NSFileWrapper *)fileWrapper.get() contentType:contentType options:nil completion:^(BOOL) { > done = true; > }]; > TestWebKitAPI::Util::run(&done); >@@ -382,7 +382,7 @@ static NSData *testPDFData() > if (newFilename) > [fileWrapper setPreferredFilename:newFilename]; > >- [self setFileWrapper:fileWrapper.get() contentType:newContentType completion:^(NSError *error) { >+ [self setFileWrapper:(__bridge NSFileWrapper *)fileWrapper.get() contentType:newContentType completion:^(NSError *error) { > resultError = error; > done = true; > }]; >@@ -408,6 +408,37 @@ static NSData *testPDFData() > > @end > >+static void runTestWithTemporaryFolder(void(^runTest)(NSURL *folderURL)) >+{ >+ NSFileManager *defaultManager = [NSFileManager defaultManager]; >+ auto temporaryFolder = retainPtr([NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"folder-%@", NSUUID.UUID]] isDirectory:YES]); >+ [defaultManager removeItemAtURL:(__bridge NSURL *)temporaryFolder.get() error:nil]; >+ [defaultManager createDirectoryAtURL:(__bridge NSURL *)temporaryFolder.get() withIntermediateDirectories:NO attributes:nil error:nil]; >+ [testImageData() writeToURL:[(__bridge NSURL *)temporaryFolder.get() URLByAppendingPathComponent:@"image.png" isDirectory:NO] atomically:YES]; >+ [testZIPData() writeToURL:[(__bridge NSURL *)temporaryFolder.get() URLByAppendingPathComponent:@"archive.zip" isDirectory:NO] atomically:YES]; >+ @try { >+ runTest((__bridge NSURL *)temporaryFolder.get()); >+ } @finally { >+ [[NSFileManager defaultManager] removeItemAtURL:(__bridge NSURL *)temporaryFolder.get() error:nil]; >+ } >+} >+ >+static void simulateFolderDragWithURL(DragAndDropSimulator *simulator, NSURL *folderURL) >+{ >+#if PLATFORM(MAC) >+ [simulator writePromisedFiles:@[ folderURL ]]; >+#else >+ auto folderProvider = adoptNS([[NSItemProvider alloc] init]); >+ [folderProvider setSuggestedName:folderURL.lastPathComponent]; >+ [folderProvider setPreferredPresentationStyle:UIPreferredPresentationStyleAttachment]; >+ [folderProvider registerFileRepresentationForTypeIdentifier:(__bridge NSString *)kUTTypeFolder fileOptions:0 visibility:NSItemProviderRepresentationVisibilityAll loadHandler:[&] (void(^completion)(NSURL *, BOOL, NSError *)) -> NSProgress * { >+ completion(folderURL, NO, nil); >+ return nil; >+ }]; >+ simulator.externalItemProviders = @[ (__bridge NSItemProvider *)folderProvider.get() ]; >+#endif >+} >+ > #pragma mark - Platform testing helper functions > > #if PLATFORM(MAC) >@@ -435,7 +466,7 @@ typedef void(^ItemProviderDataLoadHandler)(NSData *, NSError *); > - (void)registerData:(NSData *)data type:(NSString *)type > { > [self registerDataRepresentationForTypeIdentifier:type visibility:NSItemProviderRepresentationVisibilityAll loadHandler:[protectedData = retainPtr(data)] (ItemProviderDataLoadHandler completionHandler) -> NSProgress * { >- completionHandler(protectedData.get(), nil); >+ completionHandler((__bridge NSData *)protectedData.get(), nil); > return nil; > }]; > } >@@ -468,43 +499,43 @@ typedef void(^ItemProviderDataLoadHandler)(NSData *, NSError *); > > void platformCopyRichTextWithMultipleAttachments() > { >- auto image = adoptNS([[NSTextAttachment alloc] initWithData:testImageData() ofType:(NSString *)kUTTypePNG]); >- auto pdf = adoptNS([[NSTextAttachment alloc] initWithData:testPDFData() ofType:(NSString *)kUTTypePDF]); >- auto zip = adoptNS([[NSTextAttachment alloc] initWithData:testZIPData() ofType:(NSString *)kUTTypeZipArchive]); >+ auto image = adoptNS([[NSTextAttachment alloc] initWithData:testImageData() ofType:(__bridge NSString *)kUTTypePNG]); >+ auto pdf = adoptNS([[NSTextAttachment alloc] initWithData:testPDFData() ofType:(__bridge NSString *)kUTTypePDF]); >+ auto zip = adoptNS([[NSTextAttachment alloc] initWithData:testZIPData() ofType:(__bridge NSString *)kUTTypeZipArchive]); > > auto richText = adoptNS([[NSMutableAttributedString alloc] init]); >- [richText appendAttributedString:[NSAttributedString attributedStringWithAttachment:image.get()]]; >- [richText appendAttributedString:[NSAttributedString attributedStringWithAttachment:pdf.get()]]; >- [richText appendAttributedString:[NSAttributedString attributedStringWithAttachment:zip.get()]]; >+ [richText appendAttributedString:[NSAttributedString attributedStringWithAttachment:(__bridge NSTextAttachment *)image.get()]]; >+ [richText appendAttributedString:[NSAttributedString attributedStringWithAttachment:(__bridge NSTextAttachment *)pdf.get()]]; >+ [richText appendAttributedString:[NSAttributedString attributedStringWithAttachment:(__bridge NSTextAttachment *)zip.get()]]; > > #if PLATFORM(MAC) > NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; > [pasteboard clearContents]; >- [pasteboard writeObjects:@[ richText.get() ]]; >+ [pasteboard writeObjects:@[ (__bridge NSMutableAttributedString *)richText.get() ]]; > #elif PLATFORM(IOS) > auto item = adoptNS([[NSItemProvider alloc] init]); >- [item registerObject:richText.get() visibility:NSItemProviderRepresentationVisibilityAll]; >- [UIPasteboard generalPasteboard].itemProviders = @[ item.get() ]; >+ [item registerObject:(__bridge NSMutableAttributedString *)richText.get() visibility:NSItemProviderRepresentationVisibilityAll]; >+ [UIPasteboard generalPasteboard].itemProviders = @[ (__bridge NSItemProvider *)item.get() ]; > #endif > } > > void platformCopyRichTextWithImage() > { > auto richText = adoptNS([[NSMutableAttributedString alloc] init]); >- auto image = adoptNS([[NSTextAttachment alloc] initWithData:testImageData() ofType:(NSString *)kUTTypePNG]); >+ auto image = adoptNS([[NSTextAttachment alloc] initWithData:testImageData() ofType:(__bridge NSString *)kUTTypePNG]); > > [richText appendAttributedString:[[[NSAttributedString alloc] initWithString:@"Lorem ipsum "] autorelease]]; >- [richText appendAttributedString:[NSAttributedString attributedStringWithAttachment:image.get()]]; >+ [richText appendAttributedString:[NSAttributedString attributedStringWithAttachment:(__bridge NSTextAttachment *)image.get()]]; > [richText appendAttributedString:[[[NSAttributedString alloc] initWithString:@" dolor sit amet."] autorelease]]; > > #if PLATFORM(MAC) > NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; > [pasteboard clearContents]; >- [pasteboard writeObjects:@[ richText.get() ]]; >+ [pasteboard writeObjects:@[ (__bridge NSMutableAttributedString *)richText.get() ]]; > #elif PLATFORM(IOS) > auto item = adoptNS([[NSItemProvider alloc] init]); >- [item registerObject:richText.get() visibility:NSItemProviderRepresentationVisibilityAll]; >- [UIPasteboard generalPasteboard].itemProviders = @[ item.get() ]; >+ [item registerObject:(__bridge NSMutableAttributedString *)richText.get() visibility:NSItemProviderRepresentationVisibilityAll]; >+ [UIPasteboard generalPasteboard].itemProviders = @[ (__bridge NSItemProvider *)item.get() ]; > #endif > } > >@@ -518,8 +549,8 @@ void platformCopyPNG() > UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; > auto item = adoptNS([[UIItemProvider alloc] init]); > [item setPreferredPresentationStyle:UIPreferredPresentationStyleAttachment]; >- [item registerData:testImageData() type:(NSString *)kUTTypePNG]; >- pasteboard.itemProviders = @[ item.get() ]; >+ [item registerData:testImageData() type:(__bridge NSString *)kUTTypePNG]; >+ pasteboard.itemProviders = @[ (__bridge NSItemProvider *)item.get() ]; > #endif > } > >@@ -548,13 +579,13 @@ TEST(WKAttachmentTests, AttachmentElementInsertion) > RetainPtr<_WKAttachment> firstAttachment; > RetainPtr<_WKAttachment> secondAttachment; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > // Use the given content type for the attachment element's type. > firstAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo" contentType:@"text/html" data:testHTMLData()]; > EXPECT_WK_STREQ(@"foo", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]); > EXPECT_WK_STREQ(@"text/html", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]); > EXPECT_WK_STREQ(@"38 bytes", [webView valueOfAttribute:@"subtitle" forQuerySelector:@"attachment"]); >- observer.expectAttachmentUpdates(@[ ], @[ firstAttachment.get() ]); >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)firstAttachment.get() ]); > } > > _WKAttachmentInfo *info = [firstAttachment info]; >@@ -564,14 +595,14 @@ TEST(WKAttachmentTests, AttachmentElementInsertion) > EXPECT_EQ(info.filePath.length, 0U); > > { >- ObserveAttachmentUpdatesForScope scope(webView.get()); >+ ObserveAttachmentUpdatesForScope scope((__bridge TestWKWebView *)webView.get()); > // Since no content type is explicitly specified, compute it from the file extension. > [webView _executeEditCommand:@"DeleteBackward" argument:nil completion:nil]; > secondAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"bar.png" contentType:nil data:testImageData()]; > EXPECT_WK_STREQ(@"bar.png", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]); > EXPECT_WK_STREQ(@"image/png", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]); > EXPECT_WK_STREQ(@"37 KB", [webView valueOfAttribute:@"subtitle" forQuerySelector:@"attachment"]); >- scope.expectAttachmentUpdates(@[ firstAttachment.get() ], @[ secondAttachment.get() ]); >+ scope.expectAttachmentUpdates(@[ (__bridge _WKAttachment *)firstAttachment.get() ], @[ (__bridge _WKAttachment *)secondAttachment.get() ]); > } > > [firstAttachment expectRequestedDataToBe:testHTMLData()]; >@@ -586,9 +617,9 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenInsertingAndDeletingNewline) > auto webView = webViewForTestingAttachments(); > RetainPtr<_WKAttachment> attachment; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()]; >- observer.expectAttachmentUpdates(@[ ], @[attachment.get()]); >+ observer.expectAttachmentUpdates(@[ ], @[(__bridge _WKAttachment *)attachment.get()]); > } > [webView expectUpdatesAfterCommand:@"InsertParagraph" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]]; > [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]]; >@@ -603,7 +634,7 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenInsertingAndDeletingNewline) > EXPECT_TRUE([info.name isEqualToString:@"foo.txt"]); > EXPECT_EQ(info.filePath.length, 0U); > >- [webView expectUpdatesAfterCommand:@"DeleteForward" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]]; >+ [webView expectUpdatesAfterCommand:@"DeleteForward" withArgument:nil expectedRemovals:@[(__bridge _WKAttachment *)attachment.get()] expectedInsertions:@[]]; > [attachment expectRequestedDataToBe:testHTMLData()]; > } > >@@ -613,24 +644,24 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenUndoingAndRedoing) > RetainPtr<NSData> htmlData = testHTMLData(); > RetainPtr<_WKAttachment> attachment; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()]; >- observer.expectAttachmentUpdates(@[ ], @[attachment.get()]); >+ observer.expectAttachmentUpdates(@[ ], @[(__bridge _WKAttachment *)attachment.get()]); > } >- [webView expectUpdatesAfterCommand:@"Undo" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]]; >- [attachment expectRequestedDataToBe:htmlData.get()]; >+ [webView expectUpdatesAfterCommand:@"Undo" withArgument:nil expectedRemovals:@[(__bridge _WKAttachment *)attachment.get()] expectedInsertions:@[]]; >+ [attachment expectRequestedDataToBe:(__bridge NSData *)htmlData.get()]; > >- [webView expectUpdatesAfterCommand:@"Redo" withArgument:nil expectedRemovals:@[] expectedInsertions:@[attachment.get()]]; >- [attachment expectRequestedDataToBe:htmlData.get()]; >+ [webView expectUpdatesAfterCommand:@"Redo" withArgument:nil expectedRemovals:@[] expectedInsertions:@[(__bridge _WKAttachment *)attachment.get()]]; >+ [attachment expectRequestedDataToBe:(__bridge NSData *)htmlData.get()]; > >- [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]]; >- [attachment expectRequestedDataToBe:htmlData.get()]; >+ [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[(__bridge _WKAttachment *)attachment.get()] expectedInsertions:@[]]; >+ [attachment expectRequestedDataToBe:(__bridge NSData *)htmlData.get()]; > >- [webView expectUpdatesAfterCommand:@"Undo" withArgument:nil expectedRemovals:@[] expectedInsertions:@[attachment.get()]]; >- [attachment expectRequestedDataToBe:htmlData.get()]; >+ [webView expectUpdatesAfterCommand:@"Undo" withArgument:nil expectedRemovals:@[] expectedInsertions:@[(__bridge _WKAttachment *)attachment.get()]]; >+ [attachment expectRequestedDataToBe:(__bridge NSData *)htmlData.get()]; > >- [webView expectUpdatesAfterCommand:@"Redo" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]]; >- [attachment expectRequestedDataToBe:htmlData.get()]; >+ [webView expectUpdatesAfterCommand:@"Redo" withArgument:nil expectedRemovals:@[(__bridge _WKAttachment *)attachment.get()] expectedInsertions:@[]]; >+ [attachment expectRequestedDataToBe:(__bridge NSData *)htmlData.get()]; > } > > TEST(WKAttachmentTests, AttachmentUpdatesWhenChangingFontStyles) >@@ -639,9 +670,9 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenChangingFontStyles) > RetainPtr<_WKAttachment> attachment; > [webView _synchronouslyExecuteEditCommand:@"InsertText" argument:@"Hello"]; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()]; >- observer.expectAttachmentUpdates(@[ ], @[attachment.get()]); >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)attachment.get() ]); > } > [webView expectUpdatesAfterCommand:@"InsertText" withArgument:@"World" expectedRemovals:@[] expectedInsertions:@[]]; > [webView _synchronouslyExecuteEditCommand:@"SelectAll" argument:nil]; >@@ -654,7 +685,7 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenChangingFontStyles) > EXPECT_FALSE([webView hasAttribute:@"webkitattachmentid" forQuerySelector:@"attachment"]); > > // Inserting text should delete the current selection, removing the attachment in the process. >- [webView expectUpdatesAfterCommand:@"InsertText" withArgument:@"foo" expectedRemovals:@[attachment.get()] expectedInsertions:@[]]; >+ [webView expectUpdatesAfterCommand:@"InsertText" withArgument:@"foo" expectedRemovals:@[(__bridge _WKAttachment *)attachment.get()] expectedInsertions:@[]]; > [attachment expectRequestedDataToBe:testHTMLData()]; > } > >@@ -663,9 +694,9 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenInsertingLists) > auto webView = webViewForTestingAttachments(); > RetainPtr<_WKAttachment> attachment; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()]; >- observer.expectAttachmentUpdates(@[ ], @[attachment.get()]); >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)attachment.get() ]); > } > [webView expectUpdatesAfterCommand:@"InsertOrderedList" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]]; > // This edit command behaves more like a "toggle", and will actually break us out of the list we just inserted. >@@ -683,10 +714,10 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenInsertingRichMarkup) > auto webView = webViewForTestingAttachments(); > RetainPtr<_WKAttachment> attachment; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"InsertHTML" argument:@"<div><strong><attachment src='cid:123-4567' title='a'></attachment></strong></div>"]; > attachment = observer.observer().inserted[0]; >- observer.expectAttachmentUpdates(@[ ], @[attachment.get()]); >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)attachment.get() ]); > observer.expectSourceForIdentifier(@"cid:123-4567", [attachment uniqueIdentifier]); > } > EXPECT_FALSE([webView hasAttribute:@"webkitattachmentbloburl" forQuerySelector:@"attachment"]); >@@ -694,10 +725,10 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenInsertingRichMarkup) > EXPECT_FALSE([webView hasAttribute:@"webkitattachmentid" forQuerySelector:@"attachment"]); > EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').uniqueIdentifier"]); > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').remove()"]; > [webView waitForNextPresentationUpdate]; >- observer.expectAttachmentUpdates(@[attachment.get()], @[ ]); >+ observer.expectAttachmentUpdates(@[ (__bridge _WKAttachment *)attachment.get() ], @[ ]); > } > [attachment expectRequestedDataToBe:nil]; > } >@@ -707,23 +738,23 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenCuttingAndPasting) > auto webView = webViewForTestingAttachments(); > RetainPtr<_WKAttachment> attachment; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()]; >- observer.expectAttachmentUpdates(@[], @[attachment.get()]); >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)attachment.get() ]); > } > [attachment expectRequestedDataToBe:testHTMLData()]; > EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').uniqueIdentifier"]); > [webView _synchronouslyExecuteEditCommand:@"SelectAll" argument:nil]; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"Cut" argument:nil]; >- observer.expectAttachmentUpdates(@[attachment.get()], @[]); >+ observer.expectAttachmentUpdates(@[ (__bridge _WKAttachment *)attachment.get() ], @[]); > } > [attachment expectRequestedDataToBe:testHTMLData()]; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; >- observer.expectAttachmentUpdates(@[], @[attachment.get()]); >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)attachment.get() ]); > } > [attachment expectRequestedDataToBe:testHTMLData()]; > EXPECT_FALSE([webView hasAttribute:@"webkitattachmentbloburl" forQuerySelector:@"attachment"]); >@@ -736,63 +767,143 @@ TEST(WKAttachmentTests, AttachmentDataForEmptyFile) > auto webView = webViewForTestingAttachments(); > RetainPtr<_WKAttachment> attachment; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > attachment = [webView synchronouslyInsertAttachmentWithFilename:@"empty.txt" contentType:@"text/plain" data:[NSData data]]; >- observer.expectAttachmentUpdates(@[], @[attachment.get()]); >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)attachment.get() ]); > } > [attachment expectRequestedDataToBe:[NSData data]]; > EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').uniqueIdentifier"]); > { >- ObserveAttachmentUpdatesForScope scope(webView.get()); >+ ObserveAttachmentUpdatesForScope scope((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"DeleteBackward" argument:nil]; >- scope.expectAttachmentUpdates(@[attachment.get()], @[]); >+ scope.expectAttachmentUpdates(@[ (__bridge _WKAttachment *)attachment.get() ], @[ ]); > } > [attachment expectRequestedDataToBe:[NSData data]]; > } > >+TEST(WKAttachmentTests, DropFolderAsAttachmentAndMoveByDragging) >+{ >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ [configuration _setAttachmentElementEnabled:YES]; >+ >+ auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400) configuration:(__bridge WKWebViewConfiguration *)configuration.get()]); >+ [[simulator webView] synchronouslyLoadHTMLString:attachmentEditingTestMarkup]; >+ >+ runTestWithTemporaryFolder([simulator] (NSURL *folderURL) { >+ simulateFolderDragWithURL((__bridge DragAndDropSimulator *)simulator.get(), folderURL); >+ [simulator runFrom:CGPointMake(0, 0) to:CGPointMake(50, 50)]; >+ >+ TestWKWebView *webView = [simulator webView]; >+ auto attachment = retainPtr([simulator insertedAttachments].firstObject); >+ EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').uniqueIdentifier"]); >+ EXPECT_WK_STREQ((__bridge NSString *)kUTTypeDirectory, [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]); >+ EXPECT_WK_STREQ(folderURL.lastPathComponent, [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]); >+ >+ NSFileWrapper *image = [attachment info].fileWrapper.fileWrappers[@"image.png"]; >+ NSFileWrapper *archive = [attachment info].fileWrapper.fileWrappers[@"archive.zip"]; >+ EXPECT_TRUE([image.regularFileContents isEqualToData:testImageData()]); >+ EXPECT_TRUE([archive.regularFileContents isEqualToData:testZIPData()]); >+ >+ [webView evaluateJavaScript:@"getSelection().collapseToEnd()" completionHandler:nil]; >+ [webView _executeEditCommand:@"InsertParagraph" argument:nil completion:nil]; >+ [webView _executeEditCommand:@"InsertHTML" argument:@"<em>foo</em>" completion:nil]; >+ [webView _executeEditCommand:@"InsertParagraph" argument:nil completion:nil]; >+ >+ [webView expectElementTag:@"ATTACHMENT" toComeBefore:@"EM"]; >+ [simulator clearExternalDragInformation]; >+ [simulator runFrom:webView.attachmentElementMidPoint to:CGPointMake(300, 300)]; >+ [webView expectElementTag:@"EM" toComeBefore:@"ATTACHMENT"]; >+ }); >+} >+ >+TEST(WKAttachmentTests, InsertFolderAndFileWithUnknownExtension) >+{ >+ auto webView = webViewForTestingAttachments(); >+ auto file = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:testHTMLData()]); >+ [file setPreferredFilename:@"test.foobar"]; >+ auto image = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:testImageData()]); >+ auto document = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:testPDFData()]); >+ auto folder = adoptNS([[NSFileWrapper alloc] initDirectoryWithFileWrappers:@{ @"image.png": (__bridge NSFileWrapper *)image.get(), @"document.pdf": (__bridge NSFileWrapper *)document.get() }]); >+ [folder setPreferredFilename:@"folder"]; >+ >+ RetainPtr<_WKAttachment> firstAttachment; >+ RetainPtr<_WKAttachment> secondAttachment; >+ { >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); >+ firstAttachment = [webView synchronouslyInsertAttachmentWithFileWrapper:(__bridge NSFileWrapper *)file.get() contentType:nil]; >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)firstAttachment.get() ]); >+ } >+ { >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); >+ secondAttachment = [webView synchronouslyInsertAttachmentWithFileWrapper:(__bridge NSFileWrapper *)folder.get() contentType:nil]; >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)secondAttachment.get() ]); >+ } >+ >+ auto checkAttachmentConsistency = [webView, file, folder] (_WKAttachment *expectedFileAttachment, _WKAttachment *expectedFolderAttachment) { >+ [webView expectElementCount:2 tagName:@"ATTACHMENT"]; >+ EXPECT_TRUE(UTTypeConformsTo((__bridge CFStringRef)[webView valueOfAttribute:@"type" forQuerySelector:@"attachment[title=folder]"], kUTTypeDirectory)); >+ EXPECT_TRUE(UTTypeConformsTo((__bridge CFStringRef)[webView valueOfAttribute:@"type" forQuerySelector:@"attachment[title^=test]"], kUTTypeData)); >+ EXPECT_WK_STREQ(expectedFileAttachment.uniqueIdentifier, [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment[title^=test]').uniqueIdentifier"]); >+ EXPECT_WK_STREQ(expectedFolderAttachment.uniqueIdentifier, [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment[title=folder]').uniqueIdentifier"]); >+ EXPECT_TRUE([expectedFileAttachment.info.fileWrapper isEqual:(__bridge NSFileWrapper *)file.get()]); >+ EXPECT_TRUE([expectedFolderAttachment.info.fileWrapper isEqual:(__bridge NSFileWrapper *)folder.get()]); >+ }; >+ >+ checkAttachmentConsistency((__bridge _WKAttachment *)firstAttachment.get(), (__bridge _WKAttachment *)secondAttachment.get()); >+ >+ { >+ // Swap the two attachments' file wrappers without creating or destroying attachment elements. >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); >+ [firstAttachment synchronouslySetFileWrapper:(__bridge NSFileWrapper *)folder.get() newContentType:nil error:nil]; >+ [secondAttachment synchronouslySetFileWrapper:(__bridge NSFileWrapper *)file.get() newContentType:nil error:nil]; >+ observer.expectAttachmentUpdates(@[ ], @[ ]); >+ } >+ >+ checkAttachmentConsistency((__bridge _WKAttachment *)secondAttachment.get(), (__bridge _WKAttachment *)firstAttachment.get()); >+} >+ > TEST(WKAttachmentTests, ChangeAttachmentDataAndFileInformation) > { > auto webView = webViewForTestingAttachments(); > RetainPtr<_WKAttachment> attachment; > { > RetainPtr<NSData> pdfData = testPDFData(); >- ObserveAttachmentUpdatesForScope observer(webView.get()); >- attachment = [webView synchronouslyInsertAttachmentWithFilename:@"test.pdf" contentType:@"application/pdf" data:pdfData.get()]; >- [attachment expectRequestedDataToBe:pdfData.get()]; >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); >+ attachment = [webView synchronouslyInsertAttachmentWithFilename:@"test.pdf" contentType:@"application/pdf" data:(__bridge NSData *)pdfData.get()]; >+ [attachment expectRequestedDataToBe:(__bridge NSData *)pdfData.get()]; > EXPECT_WK_STREQ(@"test.pdf", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]); > EXPECT_WK_STREQ(@"application/pdf", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]); >- observer.expectAttachmentUpdates(@[], @[attachment.get()]); >+ observer.expectAttachmentUpdates(@[ ], @[(__bridge _WKAttachment *)attachment.get()]); > } > { > RetainPtr<NSData> imageData = testImageData(); >- ObserveAttachmentUpdatesForScope observer(webView.get()); >- [attachment synchronouslySetData:imageData.get() newContentType:@"image/png" newFilename:@"icon.png" error:nil]; >- [attachment expectRequestedDataToBe:imageData.get()]; >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); >+ [attachment synchronouslySetData:(__bridge NSData *)imageData.get() newContentType:@"image/png" newFilename:@"icon.png" error:nil]; >+ [attachment expectRequestedDataToBe:(__bridge NSData *)imageData.get()]; > EXPECT_WK_STREQ(@"icon.png", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]); > EXPECT_WK_STREQ(@"image/png", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]); >- observer.expectAttachmentUpdates(@[], @[]); >+ observer.expectAttachmentUpdates(@[ ], @[ ]); > } > { >- RetainPtr<NSData> textData = testHTMLData(); >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ RetainPtr<NSData> textData = [@"Hello world" dataUsingEncoding:NSUTF8StringEncoding]; >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > // The new content type should be inferred from the file name. >- [attachment synchronouslySetData:textData.get() newContentType:nil newFilename:@"foo.txt" error:nil]; >- [attachment expectRequestedDataToBe:textData.get()]; >+ [attachment synchronouslySetData:(__bridge NSData *)textData.get() newContentType:nil newFilename:@"foo.txt" error:nil]; >+ [attachment expectRequestedDataToBe:(__bridge NSData *)textData.get()]; > EXPECT_WK_STREQ(@"foo.txt", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]); > EXPECT_WK_STREQ(@"text/plain", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]); >- observer.expectAttachmentUpdates(@[], @[]); >+ observer.expectAttachmentUpdates(@[ ], @[ ]); > } > { >- RetainPtr<NSData> secondTextData = [@"Hello world" dataUsingEncoding:NSUTF8StringEncoding]; >- ObserveAttachmentUpdatesForScope observer(webView.get()); >- // Both the previous file name and type should be inferred. >- [attachment synchronouslySetData:secondTextData.get() newContentType:nil newFilename:nil error:nil]; >- [attachment expectRequestedDataToBe:secondTextData.get()]; >- EXPECT_WK_STREQ(@"foo.txt", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]); >- EXPECT_WK_STREQ(@"text/plain", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]); >- observer.expectAttachmentUpdates(@[], @[]); >+ RetainPtr<NSData> htmlData = testHTMLData(); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); >+ [attachment synchronouslySetData:(__bridge NSData *)htmlData.get() newContentType:@"text/html" newFilename:@"bar" error:nil]; >+ [attachment expectRequestedDataToBe:(__bridge NSData *)htmlData.get()]; >+ EXPECT_WK_STREQ(@"bar", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]); >+ EXPECT_WK_STREQ(@"text/html", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]); >+ observer.expectAttachmentUpdates(@[ ], @[ ]); > } >- [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]]; >+ [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[(__bridge _WKAttachment *)attachment.get()] expectedInsertions:@[ ]]; > } > > TEST(WKAttachmentTests, RemoveNewlinesBeforePastedImage) >@@ -802,7 +913,7 @@ TEST(WKAttachmentTests, RemoveNewlinesBeforePastedImage) > RetainPtr<_WKAttachment> attachment; > auto webView = webViewForTestingAttachments(); > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; > EXPECT_EQ(1U, observer.observer().inserted.count); > attachment = observer.observer().inserted[0]; >@@ -815,14 +926,14 @@ TEST(WKAttachmentTests, RemoveNewlinesBeforePastedImage) > > [webView stringByEvaluatingJavaScript:@"getSelection().collapse(document.body, 0)"]; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"InsertParagraph" argument:nil]; > [webView _synchronouslyExecuteEditCommand:@"InsertParagraph" argument:nil]; > observer.expectAttachmentUpdates(@[ ], @[ ]); > [webView expectElementTagsInOrder:@[ @"BR", @"BR", @"IMG" ]]; > } > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"DeleteBackward" argument:nil]; > [webView _synchronouslyExecuteEditCommand:@"DeleteBackward" argument:nil]; > observer.expectAttachmentUpdates(@[ ], @[ ]); >@@ -837,21 +948,21 @@ TEST(WKAttachmentTests, CutAndPastePastedImage) > RetainPtr<_WKAttachment> attachment; > auto webView = webViewForTestingAttachments(); > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; > EXPECT_EQ(1U, observer.observer().inserted.count); > attachment = observer.observer().inserted[0]; > } > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"SelectAll" argument:nil]; > [webView _synchronouslyExecuteEditCommand:@"Cut" argument:nil]; >- observer.expectAttachmentUpdates(@[ attachment.get() ], @[ ]); >+ observer.expectAttachmentUpdates(@[ (__bridge _WKAttachment *)attachment.get() ], @[ ]); > } > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; >- observer.expectAttachmentUpdates(@[ ], @[ attachment.get() ]); >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)attachment.get() ]); > } > } > >@@ -859,7 +970,7 @@ TEST(WKAttachmentTests, MovePastedImageByDragging) > { > auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); > [configuration _setAttachmentElementEnabled:YES]; >- auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400) configuration:configuration.get()]); >+ auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400) configuration:(__bridge WKWebViewConfiguration *)configuration.get()]); > TestWKWebView *webView = [simulator webView]; > [webView synchronouslyLoadHTMLString:attachmentEditingTestMarkup]; > >@@ -888,7 +999,7 @@ TEST(WKAttachmentTests, InsertPastedAttributedStringContainingImage) > RetainPtr<_WKAttachment> attachment; > auto webView = webViewForTestingAttachments(); > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; > EXPECT_EQ(0U, observer.observer().removed.count); > EXPECT_EQ(1U, observer.observer().inserted.count); >@@ -900,10 +1011,10 @@ TEST(WKAttachmentTests, InsertPastedAttributedStringContainingImage) > EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('img').webkitAttachmentIdentifier"]); > > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"SelectAll" argument:nil]; > [webView _synchronouslyExecuteEditCommand:@"DeleteBackward" argument:nil]; >- observer.expectAttachmentUpdates(@[attachment.get()], @[]); >+ observer.expectAttachmentUpdates(@[ (__bridge _WKAttachment *)attachment.get() ], @[ ]); > } > } > >@@ -916,7 +1027,7 @@ TEST(WKAttachmentTests, InsertPastedAttributedStringContainingMultipleAttachment > RetainPtr<_WKAttachment> pdfAttachment; > auto webView = webViewForTestingAttachments(); > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; > EXPECT_EQ(0U, observer.observer().removed.count); > EXPECT_EQ(3U, observer.observer().inserted.count); >@@ -948,14 +1059,14 @@ TEST(WKAttachmentTests, InsertPastedAttributedStringContainingMultipleAttachment > EXPECT_WK_STREQ([zipAttachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelectorAll('attachment')[1].uniqueIdentifier"]); > > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"SelectAll" argument:nil]; > [webView _synchronouslyExecuteEditCommand:@"DeleteBackward" argument:nil]; > NSArray<_WKAttachment *> *removedAttachments = [observer.observer() removed]; > EXPECT_EQ(3U, removedAttachments.count); >- EXPECT_TRUE([removedAttachments containsObject:zipAttachment.get()]); >- EXPECT_TRUE([removedAttachments containsObject:imageAttachment.get()]); >- EXPECT_TRUE([removedAttachments containsObject:pdfAttachment.get()]); >+ EXPECT_TRUE([removedAttachments containsObject:(__bridge _WKAttachment *)zipAttachment.get()]); >+ EXPECT_TRUE([removedAttachments containsObject:(__bridge _WKAttachment *)imageAttachment.get()]); >+ EXPECT_TRUE([removedAttachments containsObject:(__bridge _WKAttachment *)pdfAttachment.get()]); > } > } > >@@ -968,7 +1079,7 @@ TEST(WKAttachmentTests, DoNotInsertDataURLImagesAsAttachments) > > auto webView = webViewForTestingAttachments(); > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; > EXPECT_EQ(0U, observer.observer().inserted.count); > } >@@ -982,75 +1093,75 @@ TEST(WKAttachmentTests, InsertAndRemoveDuplicateAttachment) > { > auto webView = webViewForTestingAttachments(); > RetainPtr<NSData> data = testHTMLData(); >- auto fileWrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:data.get()]); >+ auto fileWrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:(__bridge NSData *)data.get()]); > RetainPtr<_WKAttachment> originalAttachment; > RetainPtr<_WKAttachment> pastedAttachment; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >- originalAttachment = [webView synchronouslyInsertAttachmentWithFileWrapper:fileWrapper.get() contentType:@"text/plain"]; >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); >+ originalAttachment = [webView synchronouslyInsertAttachmentWithFileWrapper:(__bridge NSFileWrapper *)fileWrapper.get() contentType:@"text/plain"]; > EXPECT_EQ(0U, observer.observer().removed.count); >- observer.expectAttachmentUpdates(@[], @[originalAttachment.get()]); >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)originalAttachment.get() ]); > } > [webView selectAll:nil]; > [webView _executeEditCommand:@"Copy" argument:nil completion:nil]; > [webView evaluateJavaScript:@"getSelection().collapseToEnd()" completionHandler:nil]; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; > EXPECT_EQ(0U, observer.observer().removed.count); > EXPECT_EQ(1U, observer.observer().inserted.count); > pastedAttachment = observer.observer().inserted.firstObject; >- EXPECT_FALSE([pastedAttachment isEqual:originalAttachment.get()]); >+ EXPECT_FALSE([pastedAttachment isEqual:(__bridge _WKAttachment *)originalAttachment.get()]); > } > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"DeleteBackward" argument:nil]; >- observer.expectAttachmentUpdates(@[pastedAttachment.get()], @[]); >- [originalAttachment expectRequestedDataToBe:data.get()]; >+ observer.expectAttachmentUpdates(@[ (__bridge _WKAttachment *)pastedAttachment.get() ], @[ ]); >+ [originalAttachment expectRequestedDataToBe:(__bridge NSData *)data.get()]; > } > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"DeleteBackward" argument:nil]; >- observer.expectAttachmentUpdates(@[originalAttachment.get()], @[]); >+ observer.expectAttachmentUpdates(@[ (__bridge _WKAttachment *)originalAttachment.get() ], @[ ]); > } > >- EXPECT_FALSE([originalAttachment isEqual:pastedAttachment.get()]); >+ EXPECT_FALSE([originalAttachment isEqual:(__bridge _WKAttachment *)pastedAttachment.get()]); > EXPECT_TRUE([[originalAttachment info].fileWrapper isEqual:[pastedAttachment info].fileWrapper]); >- EXPECT_TRUE([[originalAttachment info].fileWrapper isEqual:fileWrapper.get()]); >+ EXPECT_TRUE([[originalAttachment info].fileWrapper isEqual:(__bridge NSFileWrapper *)fileWrapper.get()]); > } > > TEST(WKAttachmentTests, InsertDuplicateAttachmentAndUpdateData) > { > auto webView = webViewForTestingAttachments(); > auto originalData = retainPtr(testHTMLData()); >- auto fileWrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:originalData.get()]); >+ auto fileWrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:(__bridge NSData *)originalData.get()]); > RetainPtr<_WKAttachment> originalAttachment; > RetainPtr<_WKAttachment> pastedAttachment; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >- originalAttachment = [webView synchronouslyInsertAttachmentWithFileWrapper:fileWrapper.get() contentType:@"text/plain"]; >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); >+ originalAttachment = [webView synchronouslyInsertAttachmentWithFileWrapper:(__bridge NSFileWrapper *)fileWrapper.get() contentType:@"text/plain"]; > EXPECT_EQ(0U, observer.observer().removed.count); >- observer.expectAttachmentUpdates(@[], @[originalAttachment.get()]); >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)originalAttachment.get() ]); > } > [webView selectAll:nil]; > [webView _executeEditCommand:@"Copy" argument:nil completion:nil]; > [webView evaluateJavaScript:@"getSelection().collapseToEnd()" completionHandler:nil]; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; > EXPECT_EQ(0U, observer.observer().removed.count); > EXPECT_EQ(1U, observer.observer().inserted.count); > pastedAttachment = observer.observer().inserted.firstObject; >- EXPECT_FALSE([pastedAttachment isEqual:originalAttachment.get()]); >+ EXPECT_FALSE([pastedAttachment isEqual:(__bridge _WKAttachment *)originalAttachment.get()]); > } > auto updatedData = retainPtr([@"HELLO WORLD" dataUsingEncoding:NSUTF8StringEncoding]); >- [originalAttachment synchronouslySetData:updatedData.get() newContentType:nil newFilename:nil error:nil]; >- [originalAttachment expectRequestedDataToBe:updatedData.get()]; >- [pastedAttachment expectRequestedDataToBe:originalData.get()]; >+ [originalAttachment synchronouslySetData:(__bridge NSData *)updatedData.get() newContentType:nil newFilename:nil error:nil]; >+ [originalAttachment expectRequestedDataToBe:(__bridge NSData *)updatedData.get()]; >+ [pastedAttachment expectRequestedDataToBe:(__bridge NSData *)originalData.get()]; > >- EXPECT_FALSE([originalAttachment isEqual:pastedAttachment.get()]); >+ EXPECT_FALSE([originalAttachment isEqual:(__bridge _WKAttachment *)pastedAttachment.get()]); > EXPECT_FALSE([[originalAttachment info].fileWrapper isEqual:[pastedAttachment info].fileWrapper]); >- EXPECT_FALSE([[originalAttachment info].fileWrapper isEqual:fileWrapper.get()]); >+ EXPECT_FALSE([[originalAttachment info].fileWrapper isEqual:(__bridge NSFileWrapper *)fileWrapper.get()]); > } > > TEST(WKAttachmentTests, InjectedBundleReplaceURLsWhenPastingAttributedString) >@@ -1059,9 +1170,9 @@ TEST(WKAttachmentTests, InjectedBundleReplaceURLsWhenPastingAttributedString) > > auto configuration = retainPtr([WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"BundleEditingDelegatePlugIn"]); > [[configuration processPool] _setObject:@{ @"image/png" : @"cid:foo-bar" } forBundleParameter:@"MIMETypeToReplacementURLMap"]; >- auto webView = webViewForTestingAttachments(CGSizeMake(500, 500), configuration.get()); >+ auto webView = webViewForTestingAttachments(CGSizeMake(500, 500), (__bridge WKWebViewConfiguration *)configuration.get()); > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; > EXPECT_EQ(2U, observer.observer().inserted.count); > } >@@ -1077,9 +1188,9 @@ TEST(WKAttachmentTests, InjectedBundleReplaceURLWhenPastingImage) > NSString *replacementURL = @"cid:foo-bar"; > auto configuration = retainPtr([WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"BundleEditingDelegatePlugIn"]); > [[configuration processPool] _setObject:@{ @"image/tiff" : replacementURL, @"image/png" : replacementURL } forBundleParameter:@"MIMETypeToReplacementURLMap"]; >- auto webView = webViewForTestingAttachments(CGSizeMake(500, 500), configuration.get()); >+ auto webView = webViewForTestingAttachments(CGSizeMake(500, 500), (__bridge WKWebViewConfiguration *)configuration.get()); > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; > EXPECT_EQ(0U, observer.observer().inserted.count); > } >@@ -1092,9 +1203,9 @@ TEST(WKAttachmentTests, InsertAttachmentUsingFileWrapperWithFilePath) > auto originalFileWrapper = adoptNS([[NSFileWrapper alloc] initWithURL:testImageFileURL() options:0 error:nil]); > RetainPtr<_WKAttachment> attachment; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >- attachment = [webView synchronouslyInsertAttachmentWithFileWrapper:originalFileWrapper.get() contentType:nil]; >- observer.expectAttachmentUpdates(@[ ], @[ attachment.get() ]); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); >+ attachment = [webView synchronouslyInsertAttachmentWithFileWrapper:(__bridge NSFileWrapper *)originalFileWrapper.get() contentType:nil]; >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)attachment.get() ]); > } > > _WKAttachmentInfo *infoBeforeUpdate = [attachment info]; >@@ -1105,8 +1216,8 @@ TEST(WKAttachmentTests, InsertAttachmentUsingFileWrapperWithFilePath) > > auto newFileWrapper = adoptNS([[NSFileWrapper alloc] initWithURL:testPDFFileURL() options:0 error:nil]); > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >- [attachment synchronouslySetFileWrapper:newFileWrapper.get() newContentType:nil error:nil]; >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); >+ [attachment synchronouslySetFileWrapper:(__bridge NSFileWrapper *)newFileWrapper.get() newContentType:nil error:nil]; > observer.expectAttachmentUpdates(@[ ], @[ ]); > } > >@@ -1123,17 +1234,17 @@ TEST(WKAttachmentTests, InvalidateAttachmentsAfterMainFrameNavigation) > RetainPtr<_WKAttachment> pdfAttachment; > RetainPtr<_WKAttachment> htmlAttachment; > { >- ObserveAttachmentUpdatesForScope insertionObserver(webView.get()); >+ ObserveAttachmentUpdatesForScope insertionObserver((__bridge TestWKWebView *)webView.get()); > pdfAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"attachment.pdf" contentType:@"application/pdf" data:testPDFData()]; > htmlAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"index.html" contentType:@"text/html" data:testHTMLData()]; >- insertionObserver.expectAttachmentUpdates(@[ ], @[ pdfAttachment.get(), htmlAttachment.get() ]); >+ insertionObserver.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)pdfAttachment.get(), (__bridge _WKAttachment *)htmlAttachment.get() ]); > EXPECT_TRUE([pdfAttachment isConnected]); > EXPECT_TRUE([htmlAttachment isConnected]); > } > >- ObserveAttachmentUpdatesForScope removalObserver(webView.get()); >+ ObserveAttachmentUpdatesForScope removalObserver((__bridge TestWKWebView *)webView.get()); > [webView synchronouslyLoadTestPageNamed:@"simple"]; >- removalObserver.expectAttachmentUpdates(@[ pdfAttachment.get(), htmlAttachment.get() ], @[ ]); >+ removalObserver.expectAttachmentUpdates(@[ (__bridge _WKAttachment *)pdfAttachment.get(), (__bridge _WKAttachment *)htmlAttachment.get() ], @[ ]); > EXPECT_FALSE([pdfAttachment isConnected]); > EXPECT_FALSE([htmlAttachment isConnected]); > [pdfAttachment expectRequestedDataToBe:nil]; >@@ -1146,18 +1257,18 @@ TEST(WKAttachmentTests, InvalidateAttachmentsAfterWebProcessTermination) > RetainPtr<_WKAttachment> pdfAttachment; > RetainPtr<_WKAttachment> htmlAttachment; > { >- ObserveAttachmentUpdatesForScope insertionObserver(webView.get()); >+ ObserveAttachmentUpdatesForScope insertionObserver((__bridge TestWKWebView *)webView.get()); > pdfAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"attachment.pdf" contentType:@"application/pdf" data:testPDFData()]; > htmlAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"index.html" contentType:@"text/html" data:testHTMLData()]; >- insertionObserver.expectAttachmentUpdates(@[ ], @[ pdfAttachment.get(), htmlAttachment.get() ]); >+ insertionObserver.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)pdfAttachment.get(), (__bridge _WKAttachment *)htmlAttachment.get() ]); > EXPECT_TRUE([pdfAttachment isConnected]); > EXPECT_TRUE([htmlAttachment isConnected]); > } > { >- ObserveAttachmentUpdatesForScope removalObserver(webView.get()); >+ ObserveAttachmentUpdatesForScope removalObserver((__bridge TestWKWebView *)webView.get()); > [webView stringByEvaluatingJavaScript:@"getSelection().collapseToEnd()"]; > [webView _synchronouslyExecuteEditCommand:@"DeleteBackward" argument:nil]; >- removalObserver.expectAttachmentUpdates(@[ htmlAttachment.get() ], @[ ]); >+ removalObserver.expectAttachmentUpdates(@[ (__bridge _WKAttachment *)htmlAttachment.get() ], @[ ]); > EXPECT_TRUE([pdfAttachment isConnected]); > EXPECT_FALSE([htmlAttachment isConnected]); > [htmlAttachment expectRequestedDataToBe:testHTMLData()]; >@@ -1165,16 +1276,16 @@ TEST(WKAttachmentTests, InvalidateAttachmentsAfterWebProcessTermination) > > __block bool webProcessTerminated = false; > auto navigationDelegate = adoptNS([[TestNavigationDelegate alloc] init]); >- [webView setNavigationDelegate:navigationDelegate.get()]; >+ [webView setNavigationDelegate:(__bridge TestNavigationDelegate *)navigationDelegate.get()]; > [navigationDelegate setWebContentProcessDidTerminate:^(WKWebView *) { > webProcessTerminated = true; > }]; > >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _killWebContentProcess]; > TestWebKitAPI::Util::run(&webProcessTerminated); > >- observer.expectAttachmentUpdates(@[ pdfAttachment.get() ], @[ ]); >+ observer.expectAttachmentUpdates(@[ (__bridge _WKAttachment *)pdfAttachment.get() ], @[ ]); > EXPECT_FALSE([pdfAttachment isConnected]); > EXPECT_FALSE([htmlAttachment isConnected]); > [pdfAttachment expectRequestedDataToBe:nil]; >@@ -1185,12 +1296,12 @@ TEST(WKAttachmentTests, MoveAttachmentElementAsIconByDragging) > { > auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); > [configuration _setAttachmentElementEnabled:YES]; >- auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400) configuration:configuration.get()]); >+ auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400) configuration:(__bridge WKWebViewConfiguration *)configuration.get()]); > TestWKWebView *webView = [simulator webView]; > [webView synchronouslyLoadHTMLString:attachmentEditingTestMarkup]; > > auto data = retainPtr(testPDFData()); >- auto attachment = retainPtr([webView synchronouslyInsertAttachmentWithFilename:@"document.pdf" contentType:@"application/pdf" data:data.get()]); >+ auto attachment = retainPtr([webView synchronouslyInsertAttachmentWithFilename:@"document.pdf" contentType:@"application/pdf" data:(__bridge NSData *)data.get()]); > > [webView _executeEditCommand:@"InsertParagraph" argument:nil completion:nil]; > [webView _executeEditCommand:@"InsertHTML" argument:@"<strong>text</strong>" completion:nil]; >@@ -1202,7 +1313,7 @@ TEST(WKAttachmentTests, MoveAttachmentElementAsIconByDragging) > > EXPECT_WK_STREQ("document.pdf", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]); > EXPECT_WK_STREQ("application/pdf", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]); >- [attachment expectRequestedDataToBe:data.get()]; >+ [attachment expectRequestedDataToBe:(__bridge NSData *)data.get()]; > EXPECT_EQ([simulator insertedAttachments].count, [simulator removedAttachments].count); > #if PLATFORM(MAC) > EXPECT_FALSE(isCompletelyTransparent([simulator draggingInfo].draggedImage)); >@@ -1266,7 +1377,7 @@ TEST(WKAttachmentTestsMac, InsertPastedFileURLsAsAttachments) > RetainPtr<NSArray<_WKAttachment *>> insertedAttachments; > auto webView = webViewForTestingAttachments(); > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"Paste" argument:nil]; > insertedAttachments = [observer.observer() inserted]; > EXPECT_EQ(2U, [insertedAttachments count]); >@@ -1287,7 +1398,7 @@ TEST(WKAttachmentTestsMac, InsertPastedFileURLsAsAttachments) > EXPECT_GT(attachment.info.filePath.length, 0U); > > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"SelectAll" argument:nil]; > [webView _synchronouslyExecuteEditCommand:@"DeleteBackward" argument:nil]; > NSArray<_WKAttachment *> *removedAttachments = [observer.observer() removed]; >@@ -1301,7 +1412,7 @@ TEST(WKAttachmentTestsMac, InsertDroppedFilePromisesAsAttachments) > { > auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); > [configuration _setAttachmentElementEnabled:YES]; >- auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400) configuration:configuration.get()]); >+ auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400) configuration:(__bridge WKWebViewConfiguration *)configuration.get()]); > TestWKWebView *webView = [simulator webView]; > [webView synchronouslyLoadHTMLString:attachmentEditingTestMarkup]; > [simulator writePromisedFiles:@[ testPDFFileURL(), testImageFileURL() ]]; >@@ -1339,12 +1450,12 @@ TEST(WKAttachmentTestsMac, DragAttachmentAsFilePromise) > { > auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); > [configuration _setAttachmentElementEnabled:YES]; >- auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400) configuration:configuration.get()]); >+ auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400) configuration:(__bridge WKWebViewConfiguration *)configuration.get()]); > TestWKWebView *webView = [simulator webView]; > [webView synchronouslyLoadHTMLString:attachmentEditingTestMarkup]; > > auto fileWrapper = adoptNS([[NSFileWrapper alloc] initWithURL:testPDFFileURL() options:0 error:nil]); >- auto attachment = retainPtr([webView synchronouslyInsertAttachmentWithFileWrapper:fileWrapper.get() contentType:nil]); >+ auto attachment = retainPtr([webView synchronouslyInsertAttachmentWithFileWrapper:(__bridge NSFileWrapper *)fileWrapper.get() contentType:nil]); > [simulator runFrom:[webView attachmentElementMidPoint] to:CGPointMake(300, 300)]; > > NSArray<NSURL *> *urls = [simulator receivePromisedFiles]; >@@ -1361,10 +1472,10 @@ TEST(WKAttachmentTestsMac, DragAttachmentAsFilePromise) > TEST(WKAttachmentTestsIOS, InsertDroppedImageAsAttachment) > { > auto webView = webViewForTestingAttachments(); >- auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]); >+ auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:(__bridge TestWKWebView *)webView.get()]); > auto item = adoptNS([[NSItemProvider alloc] init]); >- [item registerData:testImageData() type:(NSString *)kUTTypePNG]; >- [dragAndDropSimulator setExternalItemProviders:@[ item.get() ]]; >+ [item registerData:testImageData() type:(__bridge NSString *)kUTTypePNG]; >+ [dragAndDropSimulator setExternalItemProviders:@[ (__bridge NSItemProvider *)item.get() ]]; > [dragAndDropSimulator runFrom:CGPointZero to:CGPointMake(50, 50)]; > > EXPECT_EQ(1U, [dragAndDropSimulator insertedAttachments].count); >@@ -1374,22 +1485,22 @@ TEST(WKAttachmentTestsIOS, InsertDroppedImageAsAttachment) > EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('img').webkitAttachmentIdentifier"]); > > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"SelectAll" argument:nil]; > [webView _synchronouslyExecuteEditCommand:@"DeleteBackward" argument:nil]; >- observer.expectAttachmentUpdates(@[attachment.get()], @[]); >+ observer.expectAttachmentUpdates(@[ (__bridge _WKAttachment *)attachment.get() ], @[]); > } > } > > TEST(WKAttachmentTestsIOS, InsertDroppedAttributedStringContainingAttachment) > { > auto webView = webViewForTestingAttachments(); >- auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]); >- auto image = adoptNS([[NSTextAttachment alloc] initWithData:testImageData() ofType:(NSString *)kUTTypePNG]); >+ auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:(__bridge TestWKWebView *)webView.get()]); >+ auto image = adoptNS([[NSTextAttachment alloc] initWithData:testImageData() ofType:(__bridge NSString *)kUTTypePNG]); > auto item = adoptNS([[NSItemProvider alloc] init]); >- [item registerObject:[NSAttributedString attributedStringWithAttachment:image.get()] visibility:NSItemProviderRepresentationVisibilityAll]; >+ [item registerObject:[NSAttributedString attributedStringWithAttachment:(__bridge NSTextAttachment *)image.get()] visibility:NSItemProviderRepresentationVisibilityAll]; > >- [dragAndDropSimulator setExternalItemProviders:@[ item.get() ]]; >+ [dragAndDropSimulator setExternalItemProviders:@[ (__bridge NSItemProvider *)item.get() ]]; > [dragAndDropSimulator runFrom:CGPointZero to:CGPointMake(50, 50)]; > > EXPECT_EQ(1U, [dragAndDropSimulator insertedAttachments].count); >@@ -1402,10 +1513,10 @@ TEST(WKAttachmentTestsIOS, InsertDroppedAttributedStringContainingAttachment) > EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('img').webkitAttachmentIdentifier"]); > > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); > [webView _synchronouslyExecuteEditCommand:@"SelectAll" argument:nil]; > [webView _synchronouslyExecuteEditCommand:@"DeleteBackward" argument:nil]; >- observer.expectAttachmentUpdates(@[attachment.get()], @[]); >+ observer.expectAttachmentUpdates(@[ (__bridge _WKAttachment *)attachment.get() ], @[]); > } > } > >@@ -1418,7 +1529,7 @@ TEST(WKAttachmentTestsIOS, InsertDroppedRichAndPlainTextFilesAsAttachments) > auto richTextItem = adoptNS([[NSItemProvider alloc] init]); > auto richText = adoptNS([[NSAttributedString alloc] initWithString:@"Hello world" attributes:@{ NSFontAttributeName: [UIFont boldSystemFontOfSize:12] }]); > [richTextItem setPreferredPresentationStyle:UIPreferredPresentationStyleAttachment]; >- [richTextItem registerObject:richText.get() visibility:NSItemProviderRepresentationVisibilityAll]; >+ [richTextItem registerObject:(__bridge NSAttributedString *)richText.get() visibility:NSItemProviderRepresentationVisibilityAll]; > [richTextItem setSuggestedName:@"hello.rtf"]; > > auto plainTextItem = adoptNS([[NSItemProvider alloc] init]); >@@ -1427,8 +1538,8 @@ TEST(WKAttachmentTestsIOS, InsertDroppedRichAndPlainTextFilesAsAttachments) > [plainTextItem setSuggestedName:@"world.txt"]; > > auto webView = webViewForTestingAttachments(); >- auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]); >- [dragAndDropSimulator setExternalItemProviders:@[ richTextItem.get(), plainTextItem.get() ]]; >+ auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:(__bridge TestWKWebView *)webView.get()]); >+ [dragAndDropSimulator setExternalItemProviders:@[ (__bridge NSItemProvider *)richTextItem.get(), (__bridge NSItemProvider *)plainTextItem.get() ]]; > [dragAndDropSimulator runFrom:CGPointZero to:CGPointMake(50, 50)]; > > EXPECT_EQ(2U, [dragAndDropSimulator insertedAttachments].count); >@@ -1451,12 +1562,12 @@ TEST(WKAttachmentTestsIOS, InsertDroppedZipArchiveAsAttachment) > // presentation style (e.g. Notes) into Mail. > auto item = adoptNS([[NSItemProvider alloc] init]); > NSData *data = testZIPData(); >- [item registerData:data type:(NSString *)kUTTypeZipArchive]; >+ [item registerData:data type:(__bridge NSString *)kUTTypeZipArchive]; > [item setSuggestedName:@"archive.zip"]; > > auto webView = webViewForTestingAttachments(); >- auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]); >- [dragAndDropSimulator setExternalItemProviders:@[ item.get() ]]; >+ auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:(__bridge TestWKWebView *)webView.get()]); >+ [dragAndDropSimulator setExternalItemProviders:@[ (__bridge NSItemProvider *)item.get() ]]; > [dragAndDropSimulator runFrom:CGPointZero to:CGPointMake(50, 50)]; > > EXPECT_EQ(1U, [dragAndDropSimulator insertedAttachments].count); >@@ -1478,15 +1589,15 @@ TEST(WKAttachmentTestsIOS, InsertDroppedItemProvidersInOrder) > > auto inlineTextItem = adoptNS([[NSItemProvider alloc] init]); > auto appleURL = retainPtr([NSURL URLWithString:@"https://www.apple.com/"]); >- [inlineTextItem registerObject:appleURL.get() visibility:NSItemProviderRepresentationVisibilityAll]; >+ [inlineTextItem registerObject:(__bridge NSURL *)appleURL.get() visibility:NSItemProviderRepresentationVisibilityAll]; > > auto secondAttachmentItem = adoptNS([[NSItemProvider alloc] init]); >- [secondAttachmentItem registerData:testPDFData() type:(NSString *)kUTTypePDF]; >+ [secondAttachmentItem registerData:testPDFData() type:(__bridge NSString *)kUTTypePDF]; > [secondAttachmentItem setSuggestedName:@"second.pdf"]; > > auto webView = webViewForTestingAttachments(); >- auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]); >- [dragAndDropSimulator setExternalItemProviders:@[ firstAttachmentItem.get(), inlineTextItem.get(), secondAttachmentItem.get() ]]; >+ auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:(__bridge TestWKWebView *)webView.get()]); >+ [dragAndDropSimulator setExternalItemProviders:@[ (__bridge NSItemProvider *)firstAttachmentItem.get(), (__bridge NSItemProvider *)inlineTextItem.get(), (__bridge NSItemProvider *)secondAttachmentItem.get() ]]; > [dragAndDropSimulator runFrom:CGPointZero to:CGPointMake(50, 50)]; > > EXPECT_EQ(2U, [dragAndDropSimulator insertedAttachments].count); >@@ -1508,18 +1619,18 @@ TEST(WKAttachmentTestsIOS, DragAttachmentInsertedAsFile) > { > auto item = adoptNS([[NSItemProvider alloc] init]); > auto data = retainPtr(testPDFData()); >- [item registerData:data.get() type:(NSString *)kUTTypePDF]; >+ [item registerData:(__bridge NSData *)data.get() type:(__bridge NSString *)kUTTypePDF]; > [item setSuggestedName:@"document.pdf"]; > > auto webView = webViewForTestingAttachments(); >- auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]); >- [dragAndDropSimulator setExternalItemProviders:@[ item.get() ]]; >+ auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:(__bridge TestWKWebView *)webView.get()]); >+ [dragAndDropSimulator setExternalItemProviders:@[ (__bridge NSItemProvider *)item.get() ]]; > [dragAndDropSimulator runFrom:CGPointZero to:CGPointMake(50, 50)]; > > // First, verify that the attachment was successfully dropped. > EXPECT_EQ(1U, [dragAndDropSimulator insertedAttachments].count); > _WKAttachment *attachment = [dragAndDropSimulator insertedAttachments].firstObject; >- [attachment expectRequestedDataToBe:data.get()]; >+ [attachment expectRequestedDataToBe:(__bridge NSData *)data.get()]; > EXPECT_WK_STREQ("document.pdf", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]); > EXPECT_WK_STREQ("application/pdf", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]); > >@@ -1531,7 +1642,7 @@ TEST(WKAttachmentTestsIOS, DragAttachmentInsertedAsFile) > EXPECT_EQ(1U, [dragAndDropSimulator sourceItemProviders].count); > NSItemProvider *itemProvider = [dragAndDropSimulator sourceItemProviders].firstObject; > EXPECT_EQ(UIPreferredPresentationStyleAttachment, itemProvider.preferredPresentationStyle); >- [itemProvider expectType:(NSString *)kUTTypePDF withData:data.get()]; >+ [itemProvider expectType:(__bridge NSString *)kUTTypePDF withData:(__bridge NSData *)data.get()]; > EXPECT_WK_STREQ("document.pdf", [itemProvider suggestedName]); > [dragAndDropSimulator endDataTransfer]; > } >@@ -1542,25 +1653,25 @@ TEST(WKAttachmentTestsIOS, DragAttachmentInsertedAsData) > auto data = retainPtr(testPDFData()); > RetainPtr<_WKAttachment> attachment; > { >- ObserveAttachmentUpdatesForScope observer(webView.get()); >- attachment = [webView synchronouslyInsertAttachmentWithFilename:@"document.pdf" contentType:@"application/pdf" data:data.get()]; >- observer.expectAttachmentUpdates(@[], @[attachment.get()]); >+ ObserveAttachmentUpdatesForScope observer((__bridge TestWKWebView *)webView.get()); >+ attachment = [webView synchronouslyInsertAttachmentWithFilename:@"document.pdf" contentType:@"application/pdf" data:(__bridge NSData *)data.get()]; >+ observer.expectAttachmentUpdates(@[ ], @[ (__bridge _WKAttachment *)attachment.get() ]); > } > > // First, verify that the attachment was successfully inserted from raw data. >- [attachment expectRequestedDataToBe:data.get()]; >+ [attachment expectRequestedDataToBe:(__bridge NSData *)data.get()]; > EXPECT_WK_STREQ("document.pdf", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]); > EXPECT_WK_STREQ("application/pdf", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]); > > [webView evaluateJavaScript:@"getSelection().removeAllRanges()" completionHandler:nil]; >- auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]); >+ auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:(__bridge TestWKWebView *)webView.get()]); > [dragAndDropSimulator runFrom:CGPointMake(25, 25) to:CGPointMake(-100, -100)]; > > // Next, verify that dragging the attachment produces an item provider with a PDF attachment. > EXPECT_EQ(1U, [dragAndDropSimulator sourceItemProviders].count); > NSItemProvider *itemProvider = [dragAndDropSimulator sourceItemProviders].firstObject; > EXPECT_EQ(UIPreferredPresentationStyleAttachment, itemProvider.preferredPresentationStyle); >- [itemProvider expectType:(NSString *)kUTTypePDF withData:data.get()]; >+ [itemProvider expectType:(__bridge NSString *)kUTTypePDF withData:(__bridge NSData *)data.get()]; > EXPECT_WK_STREQ("document.pdf", [itemProvider suggestedName]); > [dragAndDropSimulator endDataTransfer]; > } >diff --git a/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h b/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h >index 761a36f0e1c0dd6b93acb5649ec5e2c08b3bda96..1d7e10e8928a19c61ec116b6b2c5eca707e45589 100644 >--- a/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h >+++ b/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h >@@ -80,6 +80,7 @@ typedef NSDictionary<NSNumber *, NSValue *> *ProgressToCGPointValueMap; > // The start location, end location, and locations of additional item requests are all in window coordinates. > - (void)runFrom:(CGPoint)startLocation to:(CGPoint)endLocation; > - (void)endDataTransfer; >+- (void)clearExternalDragInformation; > @property (nonatomic, readonly) NSArray<_WKAttachment *> *insertedAttachments; > @property (nonatomic, readonly) NSArray<_WKAttachment *> *removedAttachments; > @property (nonatomic, readonly) TestWKWebView *webView; >diff --git a/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm b/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm >index 0f97a39db60ab2902a58834145a7409b231b57e6..cebd4600a948103dfb05797a3d44eaf06385dd72 100644 >--- a/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm >+++ b/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm >@@ -568,6 +568,11 @@ static NSArray *dragAndDropEventNames() > [self _scheduleAdvanceProgress]; > } > >+- (void)clearExternalDragInformation >+{ >+ _externalItemProviders = nil; >+} >+ > - (CGPoint)_currentLocation > { > CGFloat distanceX = _endLocation.x - _startLocation.x; >diff --git a/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm b/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm >index e528301e56d4bd33bc0edb0985b1d37b33ebaf1f..2efbb5c9eb6328df2dd79846d69dc99b0afbce22 100644 >--- a/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm >+++ b/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm >@@ -358,6 +358,13 @@ static NSImage *defaultExternalDragImage() > return _externalPromisedFiles.get(); > } > >+- (void)clearExternalDragInformation >+{ >+ _externalPromisedFiles = nil; >+ _externalDragImage = nil; >+ _externalDragPasteboard = nil; >+} >+ > static BOOL getFilePathsAndTypeIdentifiers(NSArray<NSURL *> *fileURLs, NSArray<NSString *> **outFilePaths, NSArray<NSString *> **outTypeIdentifiers) > { > NSMutableArray *filePaths = [NSMutableArray arrayWithCapacity:fileURLs.count];
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 188903
:
348089
|
348112
| 348155 |
348187