Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: editor/libeditor/tests/chrome.toml
<?xml version="1.0"?>
type="text/css"?>
type="text/css"?>
<!--
-->
<p/>
id="i1"
type="content"
editortype="htmlmail"
style="width: 400px; height: 100px;"/>
<p/>
<pre id="test">
</pre>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
var utils = SpecialPowers.getDOMWindowUtils(window);
function getLoadContext() {
return window.docShell.QueryInterface(Ci.nsILoadContext);
}
function runTest() {
var trans = Cc["@mozilla.org/widget/transferable;1"]
.createInstance(Ci.nsITransferable);
trans.init(getLoadContext());
trans.addDataFlavor("text/html");
var cstr = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
cstr.data = test_data;
trans.setTransferData("text/html", cstr);
window.docShell
.rootTreeItem
.QueryInterface(Ci.nsIDocShell)
.appType = Ci.nsIDocShell.APP_TYPE_EDITOR;
var e = document.getElementById('i1');
var doc = e.contentDocument;
doc.designMode = "on";
doc.body.innerHTML = "";
doc.defaultView.focus();
var selection = doc.defaultView.getSelection();
selection.removeAllRanges();
selection.selectAllChildren(doc.body);
selection.collapseToEnd();
var point = doc.defaultView.getSelection().getRangeAt(0).startOffset;
ok(point==0, "Cursor should be at editor start before paste");
utils.sendContentCommandEvent("pasteTransferable", trans);
point = doc.defaultView.getSelection().getRangeAt(0).startOffset;
ok(point>0, "Cursor should not be at editor start after paste");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
]]>
</script>
</window>