Title: [227921] branches/safari-605-branch/Tools
- Revision
- 227921
- Author
- [email protected]
- Date
- 2018-01-31 12:08:43 -0800 (Wed, 31 Jan 2018)
Log Message
Cherry-pick r227859. rdar://problem/37079016
Modified Paths
Diff
Modified: branches/safari-605-branch/Tools/ChangeLog (227920 => 227921)
--- branches/safari-605-branch/Tools/ChangeLog 2018-01-31 19:37:34 UTC (rev 227920)
+++ branches/safari-605-branch/Tools/ChangeLog 2018-01-31 20:08:43 UTC (rev 227921)
@@ -1,3 +1,24 @@
+2018-01-31 Jason Marcell <[email protected]>
+
+ Cherry-pick r227859. rdar://problem/37079016
+
+ 2018-01-30 Wenson Hsieh <[email protected]>
+
+ [iOS] API test UIPasteboardTests.DataTransferGetDataWhenPastingPlatformRepresentations fails after r223440
+ https://bugs.webkit.org/show_bug.cgi?id=182307
+ <rdar://problem/36041485>
+
+ Reviewed by Ryosuke Niwa.
+
+ Adjusts a failing API test that we forgot to rebaseline after r223440, which ensures that the result of reading
+ "text/html" from the DataTransfer is sanitized markup. To do this, teach the test harness
+ (dump-datatransfer-types.html) to ignore inline styles in markup if a flag is set, and then set that flag in
+ UIPasteboardTests.DataTransferGetDataWhenPastingPlatformRepresentations.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/dump-datatransfer-types.html:
+ * TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:
+ (TestWebKitAPI::TEST):
+
2018-01-30 Jason Marcell <[email protected]>
Cherry-pick r226783. rdar://problem/37077980
Modified: branches/safari-605-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/dump-datatransfer-types.html (227920 => 227921)
--- branches/safari-605-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/dump-datatransfer-types.html 2018-01-31 19:37:34 UTC (rev 227920)
+++ branches/safari-605-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/dump-datatransfer-types.html 2018-01-31 20:08:43 UTC (rev 227921)
@@ -55,6 +55,9 @@
// Setting this flag to `true` allows the page to write custom MIME types via the DataTransfer when dragging or copying.
writeCustomData = false;
+// Setting this flag to `true` strips out inline styles in markup generated when getting "text/html" from a DataTransfer.
+ignoreInlineStyles = false;
+
// Entries in this dictionary will be supplied as custom data using DataTransfer.setData when dragging or copying.
// This is prepopulated with sample data by default, but tests may override this as needed.
customData = {
@@ -66,11 +69,24 @@
"baz/uri-list" : "https://www.webkit.org"
};
+function stripInlineStylesFromPasteboardData(data)
+{
+ const parsedDocument = new DOMParser().parseFromString(data, "text/html");
+ const treeWalker = parsedDocument.createTreeWalker(parsedDocument.body, NodeFilter.SHOW_ELEMENT);
+ while (treeWalker.nextNode())
+ treeWalker.currentNode.removeAttribute("style");
+ return parsedDocument.body.innerHTML;
+}
+
function updateResultWithEvent(event) {
let pasteboard = event.dataTransfer || event.clipboardData;
const eventData = {};
- for (const type of pasteboard.types)
- eventData[type] = pasteboard.getData(type);
+ for (const type of pasteboard.types) {
+ let pasteboardData = pasteboard.getData(type);
+ if (ignoreInlineStyles && type === "text/html")
+ pasteboardData = stripInlineStylesFromPasteboardData(pasteboardData);
+ eventData[type] = pasteboardData;
+ }
result[event.type] = eventData;
if (event.type === "paste" || event.type === "drop") {
output.value = JSON.stringify(result, null, " ");
Modified: branches/safari-605-branch/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm (227920 => 227921)
--- branches/safari-605-branch/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm 2018-01-31 19:37:34 UTC (rev 227920)
+++ branches/safari-605-branch/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm 2018-01-31 20:08:43 UTC (rev 227921)
@@ -167,11 +167,12 @@
TEST(UIPasteboardTests, DataTransferGetDataWhenPastingPlatformRepresentations)
{
auto webView = setUpWebViewForPasteboardTests(@"dump-datatransfer-types");
+ [webView stringByEvaluatingJavaScript:@"ignoreInlineStyles = true"];
// This simulates how a native app on iOS might write to the pasteboard when copying.
RetainPtr<NSURL> testURL = [NSURL URLWithString:@"https://www.apple.com/"];
RetainPtr<NSString> testPlainTextString = @"WebKit";
- RetainPtr<NSString> testMarkupString = @"<a href=''>The WebKit Project</a>";
+ RetainPtr<NSString> testMarkupString = @"<a href="" WebKit Project</a>";
auto itemProvider = adoptNS([[NSItemProvider alloc] init]);
[itemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML visibility:NSItemProviderRepresentationVisibilityAll loadHandler:^NSProgress *(DataLoadCompletionBlock completionHandler)
{
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes