Changeset 228340 in webkit
- Timestamp:
- Feb 9, 2018 3:41:34 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r228336 r228340 1 2018-02-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Pasting from Excel no longer provides text/html data 4 https://bugs.webkit.org/show_bug.cgi?id=182636 5 <rdar://problem/37087060> 6 7 Reviewed by Ryosuke Niwa. 8 9 Rebaseline some existing layout tests. We now expose "text/html" alongside "Files" on DataTransfer.types() in 10 some circumstances. This also provides some test coverage for ensuring that the paste codepath iOS allows the 11 page to request HTML, even if there are files on the pasteboard. See the WebCore ChangeLog for more detail. 12 13 * editing/pasteboard/data-transfer-item-list-add-file-multiple-times-expected.txt: 14 * editing/pasteboard/data-transfer-item-list-add-file-on-copy-expected.txt: 15 * editing/pasteboard/data-transfer-item-list-add-file-on-drag-expected.txt: 16 17 Adjust test expectations for the additional "text/html" type. 18 19 * editing/pasteboard/paste-image-does-not-reveal-file-url-expected.txt: 20 * editing/pasteboard/paste-image-does-not-reveal-file-url.html: 21 22 Instead of checking that types is [ "Files" ], just check that types contains "Files". On iOS, copying a 23 selected image does not also copy HTML, but on macOS it does; this covers both cases. 24 1 25 2018-02-09 Matt Baker <mattbaker@apple.com> 2 26 -
trunk/LayoutTests/editing/pasteboard/data-transfer-item-list-add-file-multiple-times-expected.txt
r223340 r228340 248 248 { 249 249 "data": { 250 "Files": "" 250 "Files": "", 251 "text/html": "<strong>some styled text</strong>" 251 252 }, 252 253 "items": [ … … 297 298 { 298 299 "data": { 299 "Files": "" 300 "Files": "", 301 "text/html": "<strong>some styled text</strong>" 300 302 }, 301 303 "items": [ … … 342 344 { 343 345 "data": { 344 "Files": "" 346 "Files": "", 347 "text/html": "<strong>some styled text</strong>" 345 348 }, 346 349 "items": [ -
trunk/LayoutTests/editing/pasteboard/data-transfer-item-list-add-file-on-copy-expected.txt
r222885 r228340 130 130 { 131 131 "data": { 132 "Files": "" 132 "Files": "", 133 "text/html": "<a>goodbye world</a>" 133 134 }, 134 135 "items": [ … … 165 166 { 166 167 "data": { 167 "Files": "" 168 "Files": "", 169 "text/html": "<a>goodbye world</a>" 168 170 }, 169 171 "items": [ … … 214 216 { 215 217 "data": { 216 "Files": "" 218 "Files": "", 219 "text/html": "<a>goodbye world</a>" 217 220 }, 218 221 "items": [ -
trunk/LayoutTests/editing/pasteboard/data-transfer-item-list-add-file-on-drag-expected.txt
r222885 r228340 130 130 { 131 131 "data": { 132 "Files": "" 132 "Files": "", 133 "text/html": "<a>goodbye world</a>" 133 134 }, 134 135 "items": [ … … 165 166 { 166 167 "data": { 167 "Files": "" 168 "Files": "", 169 "text/html": "<a>goodbye world</a>" 168 170 }, 169 171 "items": [ … … 214 216 { 215 217 "data": { 216 "Files": "" 218 "Files": "", 219 "text/html": "<a>goodbye world</a>" 217 220 }, 218 221 "items": [ -
trunk/LayoutTests/editing/pasteboard/paste-image-does-not-reveal-file-url-expected.txt
r222688 r228340 4 4 5 5 6 PASS JSON.stringify(event.clipboardData.types) is "[\"Files\"]"6 PASS event.clipboardData.types.includes("Files") is true 7 7 PASS event.clipboardData.getData("url") is "" 8 8 PASS event.clipboardData.getData("text/plain") is "" -
trunk/LayoutTests/editing/pasteboard/paste-image-does-not-reveal-file-url.html
r222688 r228340 32 32 function check(event) 33 33 { 34 shouldBe EqualToString('JSON.stringify(event.clipboardData.types)', '["Files"]');34 shouldBeTrue('event.clipboardData.types.includes("Files")'); 35 35 shouldBeEqualToString('event.clipboardData.getData("url")', ''); 36 36 shouldBeEqualToString('event.clipboardData.getData("text/plain")', ''); -
trunk/Source/WebCore/ChangeLog
r228339 r228340 1 2018-02-09 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Pasting from Excel no longer provides text/html data 4 https://bugs.webkit.org/show_bug.cgi?id=182636 5 <rdar://problem/37087060> 6 7 Reviewed by Ryosuke Niwa. 8 9 After r222656, we treat images on the pasteboard as files. However, we also have an existing policy which hides 10 text data ("text/uri-list", "text/html", "text/plain") from the page when files are present on the pasteboard. 11 When copying a table, Microsoft Excel writes a rendering of the table to the pasteboard as an image. This means 12 that we'll hide other data types (importantly, 'text/html') upon pasting, even though important clients (such as 13 Google Docs and Confluence) depend on the 'text/html' data in order to correctly handle the paste (rather than 14 paste as an image of a table). 15 16 To fix this, we add an exception to the DataTransfer.getData codepath when the pasteboard contains files. 17 Instead of always returning the empty string for text/html, we still allow pasteboard access, but only read 18 from a limited set of rich text types, i.e. web archive, RTF(D), and HTML markup. Importantly, this prevents 19 us from exposing any file paths that appear as plain text or URLs on the pasteboard. Just as in the regular 20 codepath for getData(), if the pasteboard data comes from the same origin, we allow unsanitized access; 21 otherwise, we use WebContentMarkupReader to extract markup from the pasteboard. 22 23 Tests: PasteMixedContent.ImageFileAndPlainText 24 PasteMixedContent.ImageFileAndWebArchive 25 PasteMixedContent.ImageFileAndHTML 26 PasteMixedContent.ImageFileAndRTF 27 PasteMixedContent.ImageFileAndURL 28 PasteMixedContent.ImageFileWithHTMLAndURL 29 DataInteractionTests.DataTransferGetDataWhenDroppingImageAndMarkup 30 31 Also rebaselined some layout tests, which cover changes in behavior when dropping on macOS and pasting on iOS. 32 33 * dom/DataTransfer.cpp: 34 (WebCore::DataTransfer::getDataForItem const): 35 36 Augment the codepath handling the case where the pasteboard contains files, such that we allow reading 37 "text/html", but only from rich text types. 38 39 (WebCore::DataTransfer::readStringFromPasteboard const): 40 41 Factor out logic for reading from the pasteboard into a private helper. This is called in two places from 42 getDataForItem: in the normal (existing) path, and in the case where we allow 'text/html' to be read despite 43 files appearing in the pasteboard. 44 45 One important difference here is that this helper now takes a WebContentReadingPolicy, whose purpose is to 46 prevent reading from non-rich-text types when files appear in the pasteboard. 47 48 Another tweak here is that we now use `lowercaseType` instead of the original (unadjusted) `type` when reading 49 from the pasteboard. This doesn't seem to be intended in the first place. 50 51 (WebCore::DataTransfer::types const): 52 53 Tweak the implementation of DataTransfer.types() in the case where files exist on the pasteboard, such that we 54 also add "text/html" if it is present in the list of DOM-safe types. 55 56 * dom/DataTransfer.h: 57 * platform/Pasteboard.h: 58 59 Introduce WebContentReadingPolicy, which indicates whether or not we should limit web content reading from the 60 pasteboard to only rich text types upon paste or drop. Normally, we allow all types to be read as web content 61 (::AnyType), but when files appear on the pasteboard, we force OnlyRichTextTypes to ensure that no other types 62 can unintentionally be read back as web content. 63 64 * platform/StaticPasteboard.h: 65 * platform/gtk/PasteboardGtk.cpp: 66 (WebCore::Pasteboard::read): 67 * platform/ios/PasteboardIOS.mm: 68 69 Teach Pasteboard (on iOS) to respect WebContentReadingPolicy. 70 71 (WebCore::isTypeAllowedByReadingPolicy): 72 (WebCore::Pasteboard::read): 73 (WebCore::Pasteboard::readRespectingUTIFidelities): 74 * platform/mac/PasteboardMac.mm: 75 76 Teach Pasteboard (on macOS) to respect WebContentReadingPolicy. 77 78 (WebCore::Pasteboard::read): 79 * platform/win/PasteboardWin.cpp: 80 (WebCore::Pasteboard::read): 81 * platform/wpe/PasteboardWPE.cpp: 82 (WebCore::Pasteboard::read): 83 84 Adjust non-Cocoa Pasteboard implementations for an interface change. 85 1 86 2018-02-09 Zalan Bujtas <zalan@apple.com> 2 87 -
trunk/Source/WebCore/dom/DataTransfer.cpp
r227282 r228340 155 155 return urlString; 156 156 } 157 158 if (lowercaseType == "text/html" && RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled()) { 159 // If the pasteboard contains files and the page requests 'text/html', we only read from rich text types to prevent file 160 // paths from leaking (e.g. from plain text data on the pasteboard) since we sanitize cross-origin markup. However, if 161 // custom pasteboard data is disabled, then we can't ensure that the markup we deliver is sanitized, so we fall back to 162 // current behavior and return an empty string. 163 return readStringFromPasteboard(document, lowercaseType, WebContentReadingPolicy::OnlyRichTextTypes); 164 } 165 157 166 return { }; 158 167 } 159 168 169 return readStringFromPasteboard(document, lowercaseType, WebContentReadingPolicy::AnyType); 170 } 171 172 String DataTransfer::readStringFromPasteboard(Document& document, const String& lowercaseType, WebContentReadingPolicy policy) const 173 { 160 174 if (!RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled()) 161 175 return m_pasteboard->readString(lowercaseType); … … 171 185 return { }; 172 186 173 if (!is<StaticPasteboard>(*m_pasteboard) && type == "text/html") {187 if (!is<StaticPasteboard>(*m_pasteboard) && lowercaseType == "text/html") { 174 188 if (!document.frame()) 175 189 return { }; 176 190 WebContentMarkupReader reader { *document.frame() }; 177 m_pasteboard->read(reader );191 m_pasteboard->read(reader, policy); 178 192 return reader.markup; 179 193 } 180 194 181 return m_pasteboard->readString( type);195 return m_pasteboard->readString(lowercaseType); 182 196 } 183 197 … … 294 308 if (safeTypes.contains("text/uri-list")) 295 309 types.append(ASCIILiteral("text/uri-list")); 310 if (safeTypes.contains("text/html") && RuntimeEnabledFeatures::sharedFeatures().customPasteboardDataEnabled()) 311 types.append(ASCIILiteral("text/html")); 296 312 return types; 297 313 } -
trunk/Source/WebCore/dom/DataTransfer.h
r223440 r228340 40 40 class File; 41 41 class Pasteboard; 42 enum class WebContentReadingPolicy; 42 43 43 44 class DataTransfer : public RefCounted<DataTransfer> { … … 122 123 #endif 123 124 125 String readStringFromPasteboard(Document&, const String& lowercaseType, WebContentReadingPolicy) const; 124 126 bool shouldSuppressGetAndSetDataToAvoidExposingFilePaths() const; 125 127 -
trunk/Source/WebCore/platform/Pasteboard.h
r226657 r228340 65 65 class SharedBuffer; 66 66 67 enum class WebContentReadingPolicy { AnyType, OnlyRichTextTypes }; 67 68 enum ShouldSerializeSelectedTextForDataTransfer { DefaultSelectedTextType, IncludeImageAltTextForDataTransfer }; 68 69 … … 210 211 211 212 virtual WEBCORE_EXPORT void read(PasteboardPlainText&); 212 virtual WEBCORE_EXPORT void read(PasteboardWebContentReader& );213 virtual WEBCORE_EXPORT void read(PasteboardWebContentReader&, WebContentReadingPolicy = WebContentReadingPolicy::AnyType); 213 214 virtual WEBCORE_EXPORT void read(PasteboardFileReader&); 214 215 … … 274 275 #if PLATFORM(IOS) 275 276 bool respectsUTIFidelities() const; 276 void readRespectingUTIFidelities(PasteboardWebContentReader& );277 void readRespectingUTIFidelities(PasteboardWebContentReader&, WebContentReadingPolicy); 277 278 278 279 enum class ReaderResult { -
trunk/Source/WebCore/platform/StaticPasteboard.h
r223195 r228340 54 54 55 55 void read(PasteboardPlainText&) final { } 56 void read(PasteboardWebContentReader& ) final { }56 void read(PasteboardWebContentReader&, WebContentReadingPolicy) final { } 57 57 58 58 void write(const PasteboardURL&) final { } -
trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp
r223728 r228340 237 237 } 238 238 239 void Pasteboard::read(PasteboardWebContentReader& )239 void Pasteboard::read(PasteboardWebContentReader&, WebContentReadingPolicy) 240 240 { 241 241 } -
trunk/Source/WebCore/platform/ios/PasteboardIOS.mm
r226396 r228340 164 164 } 165 165 166 static bool isTypeAllowedByReadingPolicy(NSString *type, WebContentReadingPolicy policy) 167 { 168 return policy == WebContentReadingPolicy::AnyType 169 || [type isEqualToString:WebArchivePboardType] 170 || [type isEqualToString:(NSString *)kUTTypeHTML] 171 || [type isEqualToString:(NSString *)kUTTypeRTF] 172 || [type isEqualToString:(NSString *)kUTTypeFlatRTFD]; 173 } 174 166 175 Pasteboard::ReaderResult Pasteboard::readPasteboardWebContentDataForType(PasteboardWebContentReader& reader, PasteboardStrategy& strategy, NSString *type, int itemIndex) 167 176 { … … 226 235 } 227 236 228 void Pasteboard::read(PasteboardWebContentReader& reader )237 void Pasteboard::read(PasteboardWebContentReader& reader, WebContentReadingPolicy policy) 229 238 { 230 239 reader.contentOrigin = readOrigin(); 231 240 if (respectsUTIFidelities()) { 232 readRespectingUTIFidelities(reader );241 readRespectingUTIFidelities(reader, policy); 233 242 return; 234 243 } … … 246 255 for (int i = 0; i < numberOfItems; i++) { 247 256 for (int typeIndex = 0; typeIndex < numberOfTypes; typeIndex++) { 248 auto itemResult = readPasteboardWebContentDataForType(reader, strategy, [types objectAtIndex:typeIndex], i); 257 NSString *type = [types objectAtIndex:typeIndex]; 258 if (!isTypeAllowedByReadingPolicy(type, policy)) 259 continue; 260 261 auto itemResult = readPasteboardWebContentDataForType(reader, strategy, type, i); 249 262 if (itemResult == ReaderResult::PasteboardWasChangedExternally) 250 263 return; 264 251 265 if (itemResult == ReaderResult::ReadType) 252 266 break; … … 263 277 } 264 278 265 void Pasteboard::readRespectingUTIFidelities(PasteboardWebContentReader& reader )279 void Pasteboard::readRespectingUTIFidelities(PasteboardWebContentReader& reader, WebContentReadingPolicy policy) 266 280 { 267 281 ASSERT(respectsUTIFidelities()); … … 270 284 #if ENABLE(ATTACHMENT_ELEMENT) 271 285 auto info = strategy.informationForItemAtIndex(index, m_pasteboardName); 272 bool canReadAttachment = RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled() && !info.pathForFileUpload.isEmpty();286 bool canReadAttachment = policy == WebContentReadingPolicy::AnyType && RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled() && !info.pathForFileUpload.isEmpty(); 273 287 if (canReadAttachment && info.preferredPresentationStyle == PasteboardItemPresentationStyle::Attachment) { 274 288 reader.readFilePaths({ info.pathForFileUpload }); … … 282 296 ReaderResult result = ReaderResult::DidNotReadType; 283 297 for (auto& type : typesForItemInOrderOfFidelity) { 298 if (!isTypeAllowedByReadingPolicy(type, policy)) 299 continue; 300 284 301 result = readPasteboardWebContentDataForType(reader, strategy, type, index); 285 302 if (result == ReaderResult::PasteboardWasChangedExternally) -
trunk/Source/WebCore/platform/mac/PasteboardMac.mm
r228338 r228340 332 332 } 333 333 334 void Pasteboard::read(PasteboardWebContentReader& reader )334 void Pasteboard::read(PasteboardWebContentReader& reader, WebContentReadingPolicy policy) 335 335 { 336 336 PasteboardStrategy& strategy = *platformStrategies()->pasteboardStrategy(); … … 348 348 } 349 349 350 if ( types.contains(String(legacyFilenamesPasteboardType()))) {350 if (policy == WebContentReadingPolicy::AnyType && types.contains(String(legacyFilenamesPasteboardType()))) { 351 351 Vector<String> paths; 352 352 strategy.getPathnamesForType(paths, legacyFilenamesPasteboardType(), m_pasteboardName); … … 374 374 } 375 375 } 376 377 if (policy == WebContentReadingPolicy::OnlyRichTextTypes) 378 return; 376 379 377 380 if (types.contains(String(legacyTIFFPasteboardType()))) { -
trunk/Source/WebCore/platform/win/PasteboardWin.cpp
r226205 r228340 1074 1074 } 1075 1075 1076 void Pasteboard::read(PasteboardWebContentReader& )1076 void Pasteboard::read(PasteboardWebContentReader&, WebContentReadingPolicy) 1077 1077 { 1078 1078 } -
trunk/Source/WebCore/platform/wpe/PasteboardWPE.cpp
r223195 r228340 98 98 } 99 99 100 void Pasteboard::read(PasteboardWebContentReader& )100 void Pasteboard::read(PasteboardWebContentReader&, WebContentReadingPolicy) 101 101 { 102 102 notImplemented(); -
trunk/Tools/ChangeLog
r228323 r228340 1 2018-02-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Pasting from Excel no longer provides text/html data 4 https://bugs.webkit.org/show_bug.cgi?id=182636 5 <rdar://problem/37087060> 6 7 Reviewed by Ryosuke Niwa. 8 9 Add new API tests to exercise pasting images with various other content types on macOS, and when dropping images 10 and HTML markup on iOS. See the WebCore ChangeLog for more detail. 11 12 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 13 * TestWebKitAPI/Tests/WebKitCocoa/DataTransfer.html: Added. 14 15 Add a new API test harness that dumps various bits of information about a DataTransfer upon paste and drop. 16 While somewhat similar to some existing harnesses, this makes a distinction between the raw HTML data on the 17 pasteboard and the actual result of inserting said HTML into the DOM. This allows us to check that the HTML has 18 been sanitized, while making checks for the actual content of the HTML robust against inline style changes. 19 20 * TestWebKitAPI/Tests/WebKitCocoa/PasteImage.mm: 21 * TestWebKitAPI/Tests/WebKitCocoa/PasteMixedContent.mm: Added. 22 23 Add a new test suite to exercise pasting mixed content types. In these test cases, the pasteboard contains a 24 file, with some combination of plain text, rich text, and URLs. 25 26 (imagePath): 27 (writeTypesAndDataToPasteboard): 28 29 Add a helper to write a var-arg list of content types and data to the general NSPasteboard. 30 31 (setUpWebView): 32 (markupString): 33 (TestWebKitAPI::TEST): 34 * TestWebKitAPI/Tests/ios/DataInteractionTests.mm: 35 (TestWebKitAPI::testIconImageData): 36 (TestWebKitAPI::TEST): 37 * TestWebKitAPI/cocoa/TestWKWebView.h: 38 39 Move a private declaration of -[WKWebView paste:] out to TestWKWebView.h, so that it can be shared across 40 multiple tests. Currently, it only resides in PasteImage.mm, but I need it in PasteMixedContent.mm as well. 41 1 42 2018-02-09 Carlos Garcia Campos <cgarcia@igalia.com> 2 43 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r228309 r228340 742 742 F4512E131F60C44600BB369E /* DataTransferItem-getAsEntry.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4512E121F60C43400BB369E /* DataTransferItem-getAsEntry.html */; }; 743 743 F4538EF71E8473E600B5C953 /* large-red-square.png in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4538EF01E846B4100B5C953 /* large-red-square.png */; }; 744 F457A9B8202D5CDC00F7E9D5 /* PasteMixedContent.mm in Sources */ = {isa = PBXBuildFile; fileRef = F457A9B6202D5CDC00F7E9D5 /* PasteMixedContent.mm */; }; 745 F457A9D6202D68AF00F7E9D5 /* DataTransfer.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F457A9B3202D535300F7E9D5 /* DataTransfer.html */; }; 744 746 F45B63FB1F197F4A009D38B9 /* image-map.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F45B63FA1F197F33009D38B9 /* image-map.html */; }; 745 747 F45B63FE1F19D410009D38B9 /* ActionSheetTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F45B63FC1F19D410009D38B9 /* ActionSheetTests.mm */; }; … … 895 897 290F4275172A221C00939FF0 /* custom-protocol-sync-xhr.html in Copy Resources */, 896 898 F486B1D01F67952300F34BDD /* DataTransfer-setDragImage.html in Copy Resources */, 899 F457A9D6202D68AF00F7E9D5 /* DataTransfer.html in Copy Resources */, 897 900 F4512E131F60C44600BB369E /* DataTransferItem-getAsEntry.html in Copy Resources */, 898 901 C07E6CB213FD73930038B22B /* devicePixelRatio.html in Copy Resources */, … … 1863 1866 F4512E121F60C43400BB369E /* DataTransferItem-getAsEntry.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "DataTransferItem-getAsEntry.html"; sourceTree = "<group>"; }; 1864 1867 F4538EF01E846B4100B5C953 /* large-red-square.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "large-red-square.png"; sourceTree = "<group>"; }; 1868 F457A9B3202D535300F7E9D5 /* DataTransfer.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DataTransfer.html; sourceTree = "<group>"; }; 1869 F457A9B6202D5CDC00F7E9D5 /* PasteMixedContent.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PasteMixedContent.mm; sourceTree = "<group>"; }; 1865 1870 F45B63FA1F197F33009D38B9 /* image-map.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "image-map.html"; sourceTree = "<group>"; }; 1866 1871 F45B63FC1F19D410009D38B9 /* ActionSheetTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ActionSheetTests.mm; sourceTree = "<group>"; }; … … 2131 2136 9BCB7C2620130600003E7C0C /* PasteHTML.mm */, 2132 2137 9BDCCD851F7D0B0700009A18 /* PasteImage.mm */, 2138 F457A9B6202D5CDC00F7E9D5 /* PasteMixedContent.mm */, 2133 2139 9BDD95561F83683600D20C60 /* PasteRTFD.mm */, 2134 2140 9B2346411F943A2400DB1D23 /* PasteWebArchive.mm */, … … 2365 2371 F4AB57891F65164B00DB0DA1 /* custom-draggable-div.html */, 2366 2372 F486B1CF1F6794FF00F34BDD /* DataTransfer-setDragImage.html */, 2373 F457A9B3202D535300F7E9D5 /* DataTransfer.html */, 2367 2374 F4512E121F60C43400BB369E /* DataTransferItem-getAsEntry.html */, 2368 2375 0799C34A1EBA32F4003B7532 /* disableGetUserMedia.html */, … … 3556 3563 9BCB7C2820130600003E7C0C /* PasteHTML.mm in Sources */, 3557 3564 9BDCCD871F7D0B0700009A18 /* PasteImage.mm in Sources */, 3565 F457A9B8202D5CDC00F7E9D5 /* PasteMixedContent.mm in Sources */, 3558 3566 9BDD95581F83683600D20C60 /* PasteRTFD.mm in Sources */, 3559 3567 9B2346421F943E2700DB1D23 /* PasteWebArchive.mm in Sources */, -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteImage.mm
r228240 r228340 37 37 #endif 38 38 39 @interface WKWebView ()40 - (void)paste:(id)sender;41 @end42 43 39 #if PLATFORM(MAC) 44 40 void writeImageDataToPasteboard(NSString *type, NSData *data) -
trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm
r227910 r228340 1500 1500 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110300 1501 1501 1502 static NSData *testIconImageData() 1503 { 1504 return [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"icon" ofType:@"png" inDirectory:@"TestWebKitAPI.resources"]]; 1505 } 1506 1507 TEST(DataInteractionTests, DataTransferGetDataWhenDroppingImageAndMarkup) 1508 { 1509 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 1510 WKPreferencesSetCustomPasteboardDataEnabled((WKPreferencesRef)[webView configuration].preferences, true); 1511 [webView synchronouslyLoadTestPageNamed:@"DataTransfer"]; 1512 1513 auto simulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]); 1514 auto itemProvider = adoptNS([[UIItemProvider alloc] init]); 1515 [itemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypePNG withData:testIconImageData()]; 1516 NSString *markupString = @"<script>bar()</script><strong onmousedown=javascript:void(0)>HELLO WORLD</strong>"; 1517 [itemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:[markupString dataUsingEncoding:NSUTF8StringEncoding]]; 1518 [itemProvider setSuggestedName:@"icon"]; 1519 [simulator setExternalItemProviders:@[ itemProvider.get() ]]; 1520 [simulator runFrom:CGPointZero to:CGPointMake(50, 100)]; 1521 1522 EXPECT_WK_STREQ("Files, text/html", [webView stringByEvaluatingJavaScript:@"types.textContent"]); 1523 EXPECT_WK_STREQ("(STRING, text/html), (FILE, image/png)", [webView stringByEvaluatingJavaScript:@"items.textContent"]); 1524 EXPECT_WK_STREQ("('icon.png', image/png)", [webView stringByEvaluatingJavaScript:@"files.textContent"]); 1525 EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"urlData.textContent"]); 1526 EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"textData.textContent"]); 1527 EXPECT_WK_STREQ("HELLO WORLD", [webView stringByEvaluatingJavaScript:@"htmlData.textContent"]); 1528 EXPECT_FALSE([[webView stringByEvaluatingJavaScript:@"rawHTMLData.textContent"] containsString:@"script"]); 1529 } 1530 1502 1531 TEST(DataInteractionTests, DataTransferGetDataWhenDroppingPlainText) 1503 1532 { -
trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h
r226396 r228340 34 34 @class _WKActivatedElementInfo; 35 35 #endif 36 37 @interface WKWebView (AdditionalDeclarations) 38 #if PLATFORM(MAC) 39 - (void)paste:(id)sender; 40 #endif 41 @end 36 42 37 43 @interface TestMessageHandler : NSObject <WKScriptMessageHandler>
Note: See TracChangeset
for help on using the changeset viewer.