| <script> |
| function log(message) { |
| var li = document.createElement("li"); |
| li.appendChild(document.createTextNode(message)); |
| var console = document.getElementById("console"); |
| console.appendChild(li); |
| } |
| |
| function assert(func, args, expected) { |
| var f = func + '("' + args + '")'; |
| var result = eval(f); |
| if (result != expected) |
| log('Failure: ' + f + ' was ' + result + ', expected: ' + expected); |
| else |
| log('Success: ' + f + ' == ' + result); |
| } |
| </script> |
| |
| <input id="textfield" type="text" style="width: 600"> |
| <br> |
| <div id="richcontent">This <b>styled <i>text</i></b>, and <a href="http://www.google.com"> link</a> will be pasted into the textfield. All richness should be stripped.</div> |
| <ol id="console"></ol> |
| <script> |
| if (window.testRunner) |
| window.testRunner.waitUntilDone(); |
| |
| var richcontent = document.getElementById("richcontent"); |
| var s = window.getSelection(); |
| s.setBaseAndExtent(richcontent, 0, richcontent, richcontent.childNodes.length); |
| assert("document.execCommand", "Copy", true); |
| |
| var e = document.getElementById("textfield"); |
| e.focus(); |
| e.setSelectionRange(0, 0); |
| |
| window.setTimeout(paste, 500); |
| function paste() { |
| assert("document.execCommand", "Paste", true); |
| if (window.testRunner) |
| window.testRunner.notifyDone(); |
| } |
| </script> |