зеркало из https://github.com/mozilla/gecko-dev.git
102 строки
5.6 KiB
XML
102 строки
5.6 KiB
XML
<?xml version="1.0"?>
|
|
<?xml-stylesheet href="chrome://global/skin"
|
|
type="text/css"?>
|
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
|
type="text/css"?>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=444800
|
|
-->
|
|
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
title="Mozilla Bug 444800" onload="initAndRunTests()">
|
|
<script type="application/javascript"
|
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=444800"
|
|
target="_blank">Mozilla Bug 444800</a>
|
|
<p/>
|
|
<img id="bitmapImage" src="data:image/bmp;base64,Qk2KAwAAAAAAAIoAAAB8AAAADwAAABAAAAABABgAAAAAAAADAAASCwAAEgsAAAAAAAAAAAAAAAD%2FAAD%2FAAD%2FAAAAAAAA%2FwEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2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ATA[
|
|
const knsIClipboard = Ci.nsIClipboard;
|
|
|
|
function copyImageToClipboard()
|
|
{
|
|
var tmpNode = document.popupNode;
|
|
document.popupNode = document.getElementById("bitmapImage");
|
|
|
|
const kCmd = "cmd_copyImageContents";
|
|
var controller = top.document.commandDispatcher
|
|
.getControllerForCommand(kCmd);
|
|
ok((controller && controller.isCommandEnabled(kCmd)), "have copy command");
|
|
controller.doCommand(kCmd);
|
|
|
|
document.popupNode = tmpNode;
|
|
}
|
|
|
|
function getLoadContext() {
|
|
return window.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
.getInterface(Ci.nsIWebNavigation)
|
|
.QueryInterface(Ci.nsILoadContext);
|
|
}
|
|
|
|
function runImageClipboardTests(aCBSvc, aImageType)
|
|
{
|
|
// Verify that hasDataMatchingFlavors() is working correctly.
|
|
var typeArray = [ aImageType ];
|
|
var hasImage = aCBSvc.hasDataMatchingFlavors(typeArray, typeArray.length,
|
|
knsIClipboard.kGlobalClipboard);
|
|
ok(hasImage, aImageType + " - hasDataMatchingFlavors()");
|
|
|
|
// Verify that getData() is working correctly.
|
|
var xfer = Cc["@mozilla.org/widget/transferable;1"]
|
|
.createInstance(Ci.nsITransferable);
|
|
xfer.init(getLoadContext());
|
|
xfer.addDataFlavor(aImageType);
|
|
aCBSvc.getData(xfer, knsIClipboard.kGlobalClipboard);
|
|
|
|
var typeObj = {}, dataObj = {}, lenObj = {};
|
|
xfer.getAnyTransferData(typeObj, dataObj, lenObj);
|
|
var gotValue = (null != dataObj.value);
|
|
ok(gotValue, aImageType + " - getData() returned a value");
|
|
if (gotValue)
|
|
{
|
|
const knsIInputStream = Ci.nsIInputStream;
|
|
var imgStream = dataObj.value.QueryInterface(knsIInputStream);
|
|
ok((null != imgStream), aImageType + " - got an nsIInputStream");
|
|
var bytesAvailable = imgStream.available();
|
|
ok((bytesAvailable > 10), aImageType + " - got some data");
|
|
}
|
|
}
|
|
|
|
function initAndRunTests()
|
|
{
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
copyImageToClipboard();
|
|
|
|
var cbSvc = Cc["@mozilla.org/widget/clipboard;1"]
|
|
.getService(knsIClipboard);
|
|
|
|
// Work around a problem on Windows where clipboard is not ready after copy.
|
|
setTimeout(function() { runTests(cbSvc); }, 0);
|
|
}
|
|
|
|
function runTests(aCBSvc)
|
|
{
|
|
runImageClipboardTests(aCBSvc, "image/png");
|
|
runImageClipboardTests(aCBSvc, "image/jpg");
|
|
runImageClipboardTests(aCBSvc, "image/jpeg");
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
]]>
|
|
</script>
|
|
</window>
|