1 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.');
3 var handlePaste = function(e
) {
4 var pasteText
= e
.clipboardData
.getData("text/plain");
5 // Check that the content we get is the same content we copied.
6 var expectedText
= 'foo';
7 if (pasteText
== expectedText
)
8 testPassed("Pasted text matched expected text");
10 testFailed("Expected: " +expectedText
+ "\nbut was: " + pasteText
);
13 var editDiv
= document
.createElement('div');
14 editDiv
.contentEditable
= true;
15 editDiv
.innerHTML
= "foo";
16 document
.body
.appendChild(editDiv
);
17 editDiv
.addEventListener('paste', handlePaste
, false);
19 // Select foo and copy it.
20 var selection
= window
.getSelection();
21 selection
.collapse(editDiv
, 0);
22 selection
.modify("extend", "forward", "word");
23 document
.execCommand("Copy");
25 // Paste, and make sure we can read the html text off the clipboard.
26 document
.execCommand("Paste");
28 var successfullyParsed
= true;