2009-05-18 Julie Parent <jparent@google.com>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 May 2009 10:55:42 +0000 (10:55 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 May 2009 10:55:42 +0000 (10:55 +0000)
        Reviewed by Oliver Hunt.

        Add missing files from r43821
        https://bugs.webkit.org/show_bug.cgi?id=25780

        * editing/pasteboard/get-data-text-plain-drop-expected.txt: Added.
        * editing/pasteboard/get-data-text-plain-drop.html: Added.
        * editing/pasteboard/get-data-text-plain-paste-expected.txt: Added.
        * editing/pasteboard/get-data-text-plain-paste.html: Added.
        * editing/pasteboard/resources/TEMPLATE.html: Copied from LayoutTests/editing/execCommand/resources/TEMPLATE.html.
        * editing/pasteboard/resources/get-data-text-plain-paste.js: Added.
        (handlePaste):

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

LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/get-data-text-plain-drop-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/get-data-text-plain-drop.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/get-data-text-plain-paste-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/get-data-text-plain-paste.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/resources/TEMPLATE.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/resources/get-data-text-plain-paste.js [new file with mode: 0644]

index e2e4688..dcf2732 100644 (file)
@@ -2,6 +2,21 @@
 
         Reviewed by Oliver Hunt.
 
+        Add missing files from r43821
+        https://bugs.webkit.org/show_bug.cgi?id=25780
+
+        * editing/pasteboard/get-data-text-plain-drop-expected.txt: Added.
+        * editing/pasteboard/get-data-text-plain-drop.html: Added.
+        * editing/pasteboard/get-data-text-plain-paste-expected.txt: Added.
+        * editing/pasteboard/get-data-text-plain-paste.html: Added.
+        * editing/pasteboard/resources/TEMPLATE.html: Copied from LayoutTests/editing/execCommand/resources/TEMPLATE.html.
+        * editing/pasteboard/resources/get-data-text-plain-paste.js: Added.
+        (handlePaste):
+
+2009-05-18  Julie Parent  <jparent@google.com>
+
+        Reviewed by Oliver Hunt.
+
         https://bugs.webkit.org/show_bug.cgi?id=25780
         Adds layout tests for getData (text/plain) during paste and drop events.
 
diff --git a/LayoutTests/editing/pasteboard/get-data-text-plain-drop-expected.txt b/LayoutTests/editing/pasteboard/get-data-text-plain-drop-expected.txt
new file mode 100644 (file)
index 0000000..fa10987
--- /dev/null
@@ -0,0 +1,5 @@
+This tests that getData is supported for type text/plain during drop. We select "drag", drag it, and then check that on drop getData returns "drag". To run this test manually, just drag "drag" on to "drop".
+
+drag
+drop
+SUCCESS: Pasted text matched expected text
diff --git a/LayoutTests/editing/pasteboard/get-data-text-plain-drop.html b/LayoutTests/editing/pasteboard/get-data-text-plain-drop.html
new file mode 100644 (file)
index 0000000..2f55c08
--- /dev/null
@@ -0,0 +1,65 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../editing.js" type="text/javascript"></script>
+<script type="text/javascript">
+if (window.layoutTestController) {  
+    window.layoutTestController.waitUntilDone(); 
+    layoutTestController.dumpAsText();
+}
+
+var handleDrop = function(e) {
+    var console = document.getElementById('console');
+    var pasteText = e.dataTransfer.getData("text/plain");
+    // Check that the content we get is the same content we dragged.
+    var expectedText = 'drag';
+    if (pasteText == expectedText)
+        console.innerHTML += "SUCCESS: Pasted text matched expected text";
+    else
+        console.innerHTML += "FAILURE: Expected: " +expectedText + "\nbut was: " + pasteText;
+}
+
+var handleDrag = function(e) {
+    // Cancel the drag, so we get the drop.
+    e.preventDefault();
+}
+    
+function runTest() {
+    var console = document.getElementById('console');
+    var editDiv = document.getElementById('test');
+    editDiv.addEventListener('drop', handleDrop, false);
+    editDiv.addEventListener('dragover', handleDrag, false);
+  
+    // Select the text to drag.
+    selection.setPosition(editDiv, 0);
+    extendSelectionForwardByWordCommand(); 
+
+    if (!window.layoutTestController)
+        return;
+    
+    // Now, drag foo.
+    var drag = document.getElementById('drag');
+    var x = drag.offsetLeft + drag.offsetWidth / 2;
+    var y = drag.offsetTop + drag.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    eventSender.leapForward(400);
+
+    // And drop it.
+    var drop = document.getElementById("drop");
+    x = drop.offsetLeft + drop.offsetWidth / 2;
+    y = drop.offsetTop + drop.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseUp();
+    window.layoutTestController.notifyDone();
+}
+
+</script>
+<title>Test getData during drag and drop.</title>
+</head>
+<body onload='runTest();'>
+<p>This tests that getData is supported for type text/plain during drop.  We select "drag", drag it, and then check that on drop getData returns "drag".  To run this test manually, just drag "drag" on to "drop".</p>
+<div contentEditable id='test'><div><span id='drag'>drag</span></div><div><span id='drop'>drop</span></div></div>
+<div id='console'></div>
+</body>
+</html>
diff --git a/LayoutTests/editing/pasteboard/get-data-text-plain-paste-expected.txt b/LayoutTests/editing/pasteboard/get-data-text-plain-paste-expected.txt
new file mode 100644 (file)
index 0000000..d78e085
--- /dev/null
@@ -0,0 +1,10 @@
+This tests that getData is supported for type text/plain during paste. We select "foo", copy it, and then check that on paste getData returns "foo". To run manually, select "foo", copy it, and paste it.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Pasted text matched expected text
+PASS successfullyParsed is true
+
+TEST COMPLETE
+foo
diff --git a/LayoutTests/editing/pasteboard/get-data-text-plain-paste.html b/LayoutTests/editing/pasteboard/get-data-text-plain-paste.html
new file mode 100644 (file)
index 0000000..27e2e45
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/get-data-text-plain-paste.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/editing/pasteboard/resources/TEMPLATE.html b/LayoutTests/editing/pasteboard/resources/TEMPLATE.html
new file mode 100644 (file)
index 0000000..70ce56c
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="YOUR_JS_FILE_HERE"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/editing/pasteboard/resources/get-data-text-plain-paste.js b/LayoutTests/editing/pasteboard/resources/get-data-text-plain-paste.js
new file mode 100644 (file)
index 0000000..3f45623
--- /dev/null
@@ -0,0 +1,28 @@
+description('This tests that getData is supported for type text/plain during paste.  We select "foo", copy it, and then check that on paste getData returns "foo". To run manually, select "foo", copy it, and paste it.');
+
+var handlePaste = function(e) {
+  var pasteText = e.clipboardData.getData("text/plain");
+  // Check that the content we get is the same content we copied.
+  var expectedText = 'foo';
+  if (pasteText == expectedText)
+    testPassed("Pasted text matched expected text");
+  else
+    testFailed("Expected: " +expectedText + "\nbut was: " + pasteText);
+}
+
+var editDiv = document.createElement('div');
+editDiv.contentEditable = true;
+editDiv.innerHTML = "foo";
+document.body.appendChild(editDiv);
+editDiv.addEventListener('paste', handlePaste, false);
+    
+// Select foo and copy it.    
+var selection = window.getSelection();
+selection.setPosition(editDiv, 0);
+selection.modify("extend", "forward", "word"); 
+document.execCommand("Copy");
+
+// Paste, and make sure we can read the html text off the clipboard.
+document.execCommand("Paste");
+         
+var successfullyParsed = true;