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.)

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

mercurial