content/base/test/test_copypaste.xul

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
michael@0 3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
michael@0 4 <!--
michael@0 5 https://bugzilla.mozilla.org/show_bug.cgi?id=888839
michael@0 6 -->
michael@0 7 <window title="Mozilla Bug 888839"
michael@0 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
michael@0 10
michael@0 11 <script type="application/javascript"><![CDATA[
michael@0 12
michael@0 13 let { classes: Cc, interfaces: Ci } = Components;
michael@0 14
michael@0 15 SimpleTest.waitForExplicitFinish();
michael@0 16 addLoadEvent(runTest);
michael@0 17
michael@0 18 function runTest() {
michael@0 19 let desc = document.querySelector("description");
michael@0 20 window.getSelection().selectAllChildren(desc);
michael@0 21
michael@0 22 let webnav = window.
michael@0 23 QueryInterface(Ci.nsIInterfaceRequestor).
michael@0 24 getInterface(Ci.nsIWebNavigation);
michael@0 25
michael@0 26 webnav.
michael@0 27 QueryInterface(Ci.nsIDocShell).
michael@0 28 contentViewer.
michael@0 29 QueryInterface(Ci.nsIContentViewerEdit).
michael@0 30 copySelection();
michael@0 31
michael@0 32 let mime = "text/unicode";
michael@0 33 let whichClipboard = Ci.nsIClipboard.kGlobalClipboard;
michael@0 34 let clipboard = Cc["@mozilla.org/widget/clipboard;1"].
michael@0 35 getService(Ci.nsIClipboard);
michael@0 36 ok(clipboard.hasDataMatchingFlavors([mime], 1, whichClipboard),
michael@0 37 "Clipboard should have text/unicode");
michael@0 38
michael@0 39 let transferable = Cc["@mozilla.org/widget/transferable;1"].
michael@0 40 createInstance(Ci.nsITransferable);
michael@0 41 transferable.init(webnav.QueryInterface(Ci.nsILoadContext));
michael@0 42 transferable.addDataFlavor(mime);
michael@0 43 clipboard.getData(transferable, whichClipboard);
michael@0 44 var data = {};
michael@0 45 transferable.getTransferData(mime, data, {});
michael@0 46 is(data.value.QueryInterface(Ci.nsISupportsString).data,
michael@0 47 "\n hello\n world\n ",
michael@0 48 "Paste is not HTML, so it should not be pretty printed");
michael@0 49
michael@0 50 SimpleTest.finish();
michael@0 51 }
michael@0 52
michael@0 53 ]]></script>
michael@0 54
michael@0 55 <description style="-moz-user-focus: normal; -moz-user-select: text;"><![CDATA[
michael@0 56 hello
michael@0 57 world
michael@0 58 ]]></description>
michael@0 59
michael@0 60 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 61 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=888839"
michael@0 62 target="_blank">Mozilla Bug 888839</a>
michael@0 63 </body>
michael@0 64 </window>

mercurial