2 <?xml-stylesheet href=
"chrome://global/skin"
4 <?xml-stylesheet href=
"chrome://mochikit/content/tests/SimpleTest/test.css"
7 https://bugzilla.mozilla.org/show_bug.cgi?id=444800
9 <window xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
10 title=
"Mozilla Bug 444800" onload=
"initAndRunTests()">
11 <script type=
"application/javascript"
12 src=
"chrome://mochikit/content/MochiKit/packed.js"/>
13 <script type=
"application/javascript"
14 src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
16 <body xmlns=
"http://www.w3.org/1999/xhtml">
17 <a href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=444800"
18 target=
"_blank">Mozilla Bug
444800</a>
20 <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%2FAAAA%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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%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F0vf%2FAABmXAAA%2F%2B7I%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FXJ%2FSAAAA8s2Y%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%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%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%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%2FAAAA"/>
26 <script class=
"testbody" type=
"application/javascript">
28 const knsIClipboard = Components.interfaces.nsIClipboard;
30 function copyImageToClipboard()
32 var tmpNode = document.popupNode;
33 document.popupNode = document.getElementById(
"bitmapImage");
35 const kCmd =
"cmd_copyImageContents";
36 var controller = top.document.commandDispatcher
37 .getControllerForCommand(kCmd);
38 ok((controller && controller.isCommandEnabled(kCmd)),
"have copy command");
39 controller.doCommand(kCmd);
41 document.popupNode = tmpNode;
44 function runImageClipboardTests(aCBSvc, aImageType)
46 // Verify that hasDataMatchingFlavors() is working correctly.
47 var typeArray = [ aImageType ];
48 var hasImage = aCBSvc.hasDataMatchingFlavors(typeArray, typeArray.length,
49 knsIClipboard.kGlobalClipboard);
50 ok(hasImage, aImageType +
" - hasDataMatchingFlavors()");
52 // Verify that getData() is working correctly.
53 var xfer = Components.classes[
"@mozilla.org/widget/transferable;1"]
54 .createInstance(Components.interfaces.nsITransferable);
55 xfer.addDataFlavor(aImageType);
56 aCBSvc.getData(xfer, knsIClipboard.kGlobalClipboard);
58 var typeObj = {}, dataObj = {}, lenObj = {};
59 xfer.getAnyTransferData(typeObj, dataObj, lenObj);
60 var gotValue = (null != dataObj.value);
61 ok(gotValue, aImageType +
" - getData() returned a value");
64 const knsIInputStream = Components.interfaces.nsIInputStream;
65 var imgStream = dataObj.value.QueryInterface(knsIInputStream);
66 ok((null != imgStream), aImageType +
" - got an nsIInputStream");
67 var bytesAvailable = imgStream.available();
68 ok((bytesAvailable
> 10), aImageType +
" - got some data");
72 function initAndRunTests()
74 SimpleTest.waitForExplicitFinish();
76 copyImageToClipboard();
78 var cbSvc = Components.classes[
"@mozilla.org/widget/clipboard;1"]
79 .getService(knsIClipboard);
81 // Work around a problem on Windows where clipboard is not ready after copy.
82 setTimeout(function() { runTests(cbSvc); },
0);
85 function runTests(aCBSvc)
87 runImageClipboardTests(aCBSvc,
"image/png");
88 runImageClipboardTests(aCBSvc,
"image/jpg");