1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_copyimage.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,59 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +--> 1.8 +<head> 1.9 + <title>Test for copy image</title> 1.10 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.11 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.12 +</head> 1.13 +<body> 1.14 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=518249">Mozilla Bug 518249</a> 1.15 +<p id="display"></p> 1.16 +<div id="content" style="display: none"> 1.17 +</div> 1.18 +<pre id="test"> 1.19 +<script class="testbody" type="text/javascript"> 1.20 + 1.21 +function testCopyImage () { 1.22 + // selection of the node 1.23 + var node = document.getElementById('logo'); 1.24 + var webnav = SpecialPowers.wrap(window) 1.25 + .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) 1.26 + .getInterface(SpecialPowers.Ci.nsIWebNavigation) 1.27 + 1.28 + var docShell = webnav.QueryInterface(SpecialPowers.Ci.nsIDocShell); 1.29 + 1.30 + docShell.chromeEventHandler.ownerDocument.popupNode = node; 1.31 + 1.32 + // let's copy the node 1.33 + var documentViewer = docShell.contentViewer 1.34 + .QueryInterface(SpecialPowers.Ci.nsIContentViewerEdit); 1.35 + documentViewer.copyImage(documentViewer.COPY_IMAGE_ALL); 1.36 + 1.37 + //--------- now check the content of the clipboard 1.38 + var clipboard = SpecialPowers.Cc["@mozilla.org/widget/clipboard;1"] 1.39 + .getService(SpecialPowers.Ci.nsIClipboard); 1.40 + 1.41 + // does the clipboard contain text/unicode data ? 1.42 + ok(clipboard.hasDataMatchingFlavors(["text/unicode"], 1, clipboard.kGlobalClipboard), "clipboard contains unicode text"); 1.43 + // does the clipboard contain text/html data ? 1.44 + ok(clipboard.hasDataMatchingFlavors(["text/html"], 1, clipboard.kGlobalClipboard), "clipboard contains html text"); 1.45 + // does the clipboard contain image data ? 1.46 + ok(clipboard.hasDataMatchingFlavors(["image/png"], 1, clipboard.kGlobalClipboard), "clipboard contains image"); 1.47 + 1.48 + SimpleTest.finish(); 1.49 +} 1.50 + 1.51 + 1.52 +SimpleTest.waitForExplicitFinish(); 1.53 + 1.54 +addLoadEvent(testCopyImage); 1.55 + 1.56 +</script> 1.57 +</pre> 1.58 +<div> 1.59 + <img id="logo" src="about:logo"> 1.60 +</div> 1.61 +</body> 1.62 +</html>