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