Backed out changeset c8d01bb9a6a2 (bug 1866098) for causing bp-nu build bustages...
[gecko.git] / widget / tests / test_bug444800.xhtml
blob85a73b3288cae272c0868b5f97b0462b672db9e4
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin"
3 type="text/css"?>
4 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
5 type="text/css"?>
6 <!--
7 https://bugzilla.mozilla.org/show_bug.cgi?id=444800
8 -->
9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
10 title="Mozilla Bug 444800" onload="initAndRunTests()">
11 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
13 <body xmlns="http://www.w3.org/1999/xhtml">
14 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=444800"
15 target="_blank">Mozilla Bug 444800</a>
16 <p/>
17 <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%2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ipboard;
27 function copyImageToClipboard()
29 SpecialPowers.setCommandNode(window, document.getElementById("bitmapImage"));
31 const kCmd = "cmd_copyImageContents";
32 var controller = top.document.commandDispatcher
33 .getControllerForCommand(kCmd);
34 ok((controller && controller.isCommandEnabled(kCmd)), "have copy command");
35 controller.doCommand(kCmd);
37 SpecialPowers.setCommandNode(window, null);
40 function getLoadContext() {
41 return window.docShell.QueryInterface(Ci.nsILoadContext);
44 function runImageClipboardTests(aCBSvc, aImageType)
46 // Verify that hasDataMatchingFlavors() is working correctly.
47 var typeArray = [ aImageType ];
48 var hasImage = aCBSvc.hasDataMatchingFlavors(typeArray,
49 knsIClipboard.kGlobalClipboard);
50 ok(hasImage, aImageType + " - hasDataMatchingFlavors()");
52 // Verify that getData() is working correctly.
53 var xfer = Cc["@mozilla.org/widget/transferable;1"]
54 .createInstance(Ci.nsITransferable);
55 xfer.init(getLoadContext());
56 xfer.addDataFlavor(aImageType);
57 aCBSvc.getData(xfer, knsIClipboard.kGlobalClipboard);
59 var typeObj = {}, dataObj = {};
60 xfer.getAnyTransferData(typeObj, dataObj);
61 var gotValue = (null != dataObj.value);
62 ok(gotValue, aImageType + " - getData() returned a value");
63 if (gotValue)
65 const knsIInputStream = Ci.nsIInputStream;
66 var imgStream = dataObj.value.QueryInterface(knsIInputStream);
67 ok((null != imgStream), aImageType + " - got an nsIInputStream");
68 var bytesAvailable = imgStream.available();
69 ok((bytesAvailable > 10), aImageType + " - got some data");
73 function initAndRunTests()
75 SimpleTest.waitForExplicitFinish();
77 copyImageToClipboard();
79 var cbSvc = Cc["@mozilla.org/widget/clipboard;1"]
80 .getService(knsIClipboard);
82 // Work around a problem on Windows where clipboard is not ready after copy.
83 setTimeout(function() { runTests(cbSvc); }, 0);
86 function runTests(aCBSvc)
88 runImageClipboardTests(aCBSvc, "image/png");
89 runImageClipboardTests(aCBSvc, "image/jpg");
90 runImageClipboardTests(aCBSvc, "image/jpeg");
92 SimpleTest.finish();
95 ]]>
96 </script>
97 </window>