content/base/test/test_copypaste.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/test/test_copypaste.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
     1.6 +<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
     1.7 +<!--
     1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=888839
     1.9 +-->
    1.10 +<window title="Mozilla Bug 888839"
    1.11 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.12 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    1.13 +
    1.14 +  <script type="application/javascript"><![CDATA[
    1.15 +
    1.16 +let { classes: Cc, interfaces: Ci } = Components;
    1.17 +
    1.18 +SimpleTest.waitForExplicitFinish();
    1.19 +addLoadEvent(runTest);
    1.20 +
    1.21 +function runTest() {
    1.22 +  let desc = document.querySelector("description");
    1.23 +  window.getSelection().selectAllChildren(desc);
    1.24 +
    1.25 +  let webnav = window.
    1.26 +               QueryInterface(Ci.nsIInterfaceRequestor).
    1.27 +               getInterface(Ci.nsIWebNavigation);
    1.28 +
    1.29 +  webnav.
    1.30 +    QueryInterface(Ci.nsIDocShell).
    1.31 +    contentViewer.
    1.32 +    QueryInterface(Ci.nsIContentViewerEdit).
    1.33 +    copySelection();
    1.34 +
    1.35 +  let mime = "text/unicode";
    1.36 +  let whichClipboard = Ci.nsIClipboard.kGlobalClipboard;
    1.37 +  let clipboard = Cc["@mozilla.org/widget/clipboard;1"].
    1.38 +                  getService(Ci.nsIClipboard);
    1.39 +  ok(clipboard.hasDataMatchingFlavors([mime], 1, whichClipboard),
    1.40 +     "Clipboard should have text/unicode");
    1.41 +
    1.42 +  let transferable = Cc["@mozilla.org/widget/transferable;1"].
    1.43 +                     createInstance(Ci.nsITransferable);
    1.44 +  transferable.init(webnav.QueryInterface(Ci.nsILoadContext));
    1.45 +  transferable.addDataFlavor(mime);
    1.46 +  clipboard.getData(transferable, whichClipboard);
    1.47 +  var data = {};
    1.48 +  transferable.getTransferData(mime, data, {});
    1.49 +  is(data.value.QueryInterface(Ci.nsISupportsString).data,
    1.50 +     "\n    hello\n    world\n  ",
    1.51 +     "Paste is not HTML, so it should not be pretty printed");
    1.52 +
    1.53 +  SimpleTest.finish();
    1.54 +}
    1.55 +
    1.56 +  ]]></script>
    1.57 +
    1.58 +  <description style="-moz-user-focus: normal; -moz-user-select: text;"><![CDATA[
    1.59 +    hello
    1.60 +    world
    1.61 +  ]]></description>
    1.62 +
    1.63 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.64 +  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=888839"
    1.65 +     target="_blank">Mozilla Bug 888839</a>
    1.66 +  </body>
    1.67 +</window>

mercurial