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