Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / pasteboard / script-tests / get-data-text-plain-paste.js
blob03ffc30f485f8a0f5a77c5635daf13efa4119f5e
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");
9 else
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;