Augment editing/pasteboard/data-transfer-get-data-non-normalized-types.html to check...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Oct 2017 05:00:03 +0000 (05:00 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Oct 2017 05:00:03 +0000 (05:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177707

Reviewed by Ryosuke Niwa.

Augment an existing layout test to check that whitespace is stripped from types passed into DataTransfer's
getData and setData methods.

* editing/pasteboard/data-transfer-get-data-non-normalized-types-expected.txt:
* editing/pasteboard/data-transfer-get-data-non-normalized-types.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222687 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/data-transfer-get-data-non-normalized-types-expected.txt
LayoutTests/editing/pasteboard/data-transfer-get-data-non-normalized-types.html

index b76b8b1de6f0d2d559b340c359292ee07c07c426..cdef64fedd7a311afae512aa16febc7416b09546 100644 (file)
@@ -1,3 +1,16 @@
+2017-09-30  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Augment editing/pasteboard/data-transfer-get-data-non-normalized-types.html to check whitespace stripping
+        https://bugs.webkit.org/show_bug.cgi?id=177707
+
+        Reviewed by Ryosuke Niwa.
+
+        Augment an existing layout test to check that whitespace is stripped from types passed into DataTransfer's
+        getData and setData methods.
+
+        * editing/pasteboard/data-transfer-get-data-non-normalized-types-expected.txt:
+        * editing/pasteboard/data-transfer-get-data-non-normalized-types.html:
+
 2017-09-30  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Add a layout test test that exercises setData and getData for non-normalized types
index dc65d1c1c29894477c3733b96559dbcc85d97c50..5dcf360fba92a763ce66908fc863eeb65eecae18 100644 (file)
@@ -1,12 +1,14 @@
 Rich text
 {
-    "text/plain;": "",
-    "text/uri-list;": "http://www.apple.com/",
-    "text/html;": "<b style='color: green'></b>"
+    " text/plain; ": "",
+    "text/uri-list; ": "http://www.apple.com/",
+    "text/html; ": "<b style='color: green'></b>",
+    "\fcustom type\u000b": "custom data"
 }
 {
-    "Text": "",
-    "URL": "http://www.apple.com/",
-    "text/html;charset=utf-8": "<b style='color: green'></b>"
+    "\tText": "",
+    "\r\nURL": "http://www.apple.com/",
+    "    text/html;charset=utf-8 ": "<b style='color: green'></b>",
+    " custom type\t\n": "custom data"
 }
 
index c983c3928f6f117f4a7ecf7d1d29b25286e7bffd..eaeda72cd53665c1e64388c18edf349659f9fd64 100644 (file)
@@ -31,33 +31,34 @@ html, body {
 
 function handleCopy1(event) {
     event.clipboardData.setData("Text", "");
-    event.clipboardData.setData("URL", "http://www.apple.com/");
-    event.clipboardData.setData("text/html;charset=utf-8", "<b style='color: green'></b>");
+    event.clipboardData.setData(" URL\r", "http://www.apple.com/");
+    event.clipboardData.setData(" text/html;charset=utf-8 ", "<b style='color: green'></b>");
+    event.clipboardData.setData("custom type\t\n", "custom data");
     event.preventDefault();
 }
 
 function handleCopy2(event) {
-    event.clipboardData.setData("text/plain;", "");
-    event.clipboardData.setData("text/uri-list;", "http://www.apple.com/");
-    event.clipboardData.setData("text/html;", "<b style='color: green'></b>");
+    event.clipboardData.setData("text/plain;\t", "");
+    event.clipboardData.setData("text/uri-list;\n", "http://www.apple.com/");
+    event.clipboardData.setData("text/html;    ", "<b style='color: green'></b>");
+    event.clipboardData.setData("custom type", "custom data");
     event.preventDefault();
 }
 
+function getDataWithTypesFromEvent(event, types) {
+    const result = {};
+    for (const type of types)
+        result[type] = event.clipboardData.getData(type);
+    return result;
+}
+
 function handlePaste1(event) {
-    output.textContent += JSON.stringify({
-        "text/plain;": event.clipboardData.getData("text/plain;"),
-        "text/uri-list;": event.clipboardData.getData("text/uri-list;"),
-        "text/html;": event.clipboardData.getData("text/html;")
-    }, null, "    ") + "\n";
+    output.textContent += JSON.stringify(getDataWithTypesFromEvent(event, [" text/plain; ", "text/uri-list; ", "text/html; ", "\fcustom type\v"]), null, "    ") + "\n";
     event.preventDefault();
 }
 
 function handlePaste2(event) {
-    output.textContent += JSON.stringify({
-        "Text": event.clipboardData.getData("Text"),
-        "URL": event.clipboardData.getData("URL"),
-        "text/html;charset=utf-8": event.clipboardData.getData("text/html;charset=utf-8")
-    }, null, "    ") + "\n"
+    output.textContent += JSON.stringify(getDataWithTypesFromEvent(event, ["\tText", "\r\nURL", "    text/html;charset=utf-8 ", " custom type\t\n"]), null, "    ") + "\n";
     event.preventDefault();
 }