content/base/test/test_copyimage.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 -->
     5 <head>
     6   <title>Test for copy image</title>
     7   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     8   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     9 </head>
    10 <body>
    11 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=518249">Mozilla Bug 518249</a>
    12 <p id="display"></p>
    13 <div id="content" style="display: none">
    14 </div>
    15 <pre id="test">
    16 <script class="testbody" type="text/javascript">
    18 function testCopyImage () {
    19   // selection of the node
    20   var node = document.getElementById('logo');
    21   var webnav = SpecialPowers.wrap(window)
    22                .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
    23                .getInterface(SpecialPowers.Ci.nsIWebNavigation)
    25   var docShell = webnav.QueryInterface(SpecialPowers.Ci.nsIDocShell);
    27   docShell.chromeEventHandler.ownerDocument.popupNode = node;
    29   // let's copy the node
    30   var documentViewer = docShell.contentViewer
    31                                .QueryInterface(SpecialPowers.Ci.nsIContentViewerEdit);
    32   documentViewer.copyImage(documentViewer.COPY_IMAGE_ALL);
    34   //--------- now check the content of the clipboard
    35   var clipboard = SpecialPowers.Cc["@mozilla.org/widget/clipboard;1"]
    36                                .getService(SpecialPowers.Ci.nsIClipboard);
    38   // does the clipboard contain text/unicode data ?
    39   ok(clipboard.hasDataMatchingFlavors(["text/unicode"], 1, clipboard.kGlobalClipboard), "clipboard contains unicode text");
    40   // does the clipboard contain text/html data ?
    41   ok(clipboard.hasDataMatchingFlavors(["text/html"], 1, clipboard.kGlobalClipboard), "clipboard contains html text");
    42   // does the clipboard contain image data ?
    43   ok(clipboard.hasDataMatchingFlavors(["image/png"], 1, clipboard.kGlobalClipboard), "clipboard contains image");
    45   SimpleTest.finish();
    46 }
    49 SimpleTest.waitForExplicitFinish();
    51 addLoadEvent(testCopyImage);
    53 </script>
    54 </pre>
    55 <div>
    56   <img id="logo" src="about:logo">
    57 </div>
    58 </body>
    59 </html>

mercurial