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