test_bug1327798.html (1736B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Test for bug 1327798</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <script src="/tests/SimpleTest/EventUtils.js"></script> 7 <link rel="stylesheet" href="/tests/SimpleTest/test.css"> 8 </head> 9 <body> 10 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?=id=1327798">Mozilla Bug 1327798</a> 11 <p id="display"></p> 12 <div id="content" style="display: none;"></div> 13 14 <div contenteditable="true" id="editable1"><b>Formatted Text</b><br></div> 15 <pre> 16 <script class="testbody" type="application/javascript"> 17 SimpleTest.waitForExplicitFinish(); 18 SimpleTest.waitForFocus(() => { 19 var editable = document.getElementById("editable1"); 20 editable.focus(); 21 22 window.getSelection().selectAllChildren(editable1); 23 24 SpecialPowers.doCommand(window, "cmd_copy"); 25 26 //--------- now check the content of the clipboard 27 var clipboard = SpecialPowers.Cc["@mozilla.org/widget/clipboard;1"] 28 .getService(SpecialPowers.Ci.nsIClipboard); 29 // does the clipboard contain text/plain data ? 30 ok(clipboard.hasDataMatchingFlavors(["text/plain"], clipboard.kGlobalClipboard), 31 "clipboard contains unicode text"); 32 // does the clipboard contain text/html data ? 33 ok(clipboard.hasDataMatchingFlavors(["text/html"], clipboard.kGlobalClipboard), 34 "clipboard contains html text"); 35 36 window.addEventListener("paste", (e) => { 37 is(e.clipboardData.types.indexOf('text/html'), -1, "clipboardData shouldn't have text/html"); 38 is(e.clipboardData.getData('text/plain'), "Formatted Text", "getData(text/plain) should return plain text"); 39 SimpleTest.finish(); 40 }); 41 42 SpecialPowers.doCommand(window, "cmd_pasteNoFormatting"); 43 }); 44 </script> 45 </pre> 46 </body> 47 </html>