test_bug489202.xhtml (2458B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet href="chrome://global/skin" 3 type="text/css"?> 4 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 5 type="text/css"?> 6 <!-- 7 https://bugzilla.mozilla.org/show_bug.cgi?id=489202 8 --> 9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 10 title="Mozilla Bug 489202" onload="runTest();"> 11 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 12 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 13 14 <body xmlns="http://www.w3.org/1999/xhtml"> 15 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=489202" 16 target="_blank">Mozilla Bug 489202</a> 17 <p/> 18 <editor xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 19 id="i1" 20 type="content" 21 editortype="htmlmail" 22 style="width: 400px; height: 100px;"/> 23 <p/> 24 <pre id="test"> 25 </pre> 26 </body> 27 <script class="testbody" type="application/javascript"> 28 <![CDATA[ 29 var utils = SpecialPowers.getDOMWindowUtils(window); 30 31 function getLoadContext() { 32 return window.docShell.QueryInterface(Ci.nsILoadContext); 33 } 34 35 function runTest() { 36 var trans = Cc["@mozilla.org/widget/transferable;1"] 37 .createInstance(Ci.nsITransferable); 38 trans.init(getLoadContext()); 39 trans.addDataFlavor("text/html"); 40 var test_data = '<meta/><a href="http://mozilla.org/">mozilla.org</a>'; 41 var cstr = Cc["@mozilla.org/supports-string;1"] 42 .createInstance(Ci.nsISupportsString); 43 cstr.data = test_data; 44 trans.setTransferData("text/html", cstr); 45 46 window.docShell 47 .rootTreeItem 48 .QueryInterface(Ci.nsIDocShell) 49 .appType = Ci.nsIDocShell.APP_TYPE_EDITOR; 50 var e = document.getElementById('i1'); 51 var doc = e.contentDocument; 52 doc.designMode = "on"; 53 doc.body.innerHTML = ""; 54 doc.defaultView.focus(); 55 var selection = doc.defaultView.getSelection(); 56 selection.removeAllRanges(); 57 selection.selectAllChildren(doc.body); 58 selection.collapseToEnd(); 59 60 var point = doc.defaultView.getSelection().getRangeAt(0).startOffset; 61 ok(point==0, "Cursor should be at editor start before paste"); 62 63 utils.sendContentCommandEvent("pasteTransferable", trans); 64 65 point = doc.defaultView.getSelection().getRangeAt(0).startOffset; 66 ok(point>0, "Cursor should not be at editor start after paste"); 67 SimpleTest.finish(); 68 } 69 70 SimpleTest.waitForExplicitFinish(); 71 ]]> 72 </script> 73 </window>