Bug 1613552 [wpt PR 21618] - Fix timeout vs. task-queue race conditions in promise...
[gecko.git] / widget / tests / test_bug444800.xhtml
blobf2fac6509d8913032e8e4cc91e3e186877e3fb23
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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IClipboard;
27 function copyImageToClipboard()
29 var tmpNode = document.popupNode;
30 document.popupNode = document.getElementById("bitmapImage");
32 const kCmd = "cmd_copyImageContents";
33 var controller = top.document.commandDispatcher
34 .getControllerForCommand(kCmd);
35 ok((controller && controller.isCommandEnabled(kCmd)), "have copy command");
36 controller.doCommand(kCmd);
38 document.popupNode = tmpNode;
41 function getLoadContext() {
42 return window.docShell.QueryInterface(Ci.nsILoadContext);
45 function runImageClipboardTests(aCBSvc, aImageType)
47 // Verify that hasDataMatchingFlavors() is working correctly.
48 var typeArray = [ aImageType ];
49 var hasImage = aCBSvc.hasDataMatchingFlavors(typeArray,
50 knsIClipboard.kGlobalClipboard);
51 ok(hasImage, aImageType + " - hasDataMatchingFlavors()");
53 // Verify that getData() is working correctly.
54 var xfer = Cc["@mozilla.org/widget/transferable;1"]
55 .createInstance(Ci.nsITransferable);
56 xfer.init(getLoadContext());
57 xfer.addDataFlavor(aImageType);
58 aCBSvc.getData(xfer, knsIClipboard.kGlobalClipboard);
60 var typeObj = {}, dataObj = {};
61 xfer.getAnyTransferData(typeObj, dataObj);
62 var gotValue = (null != dataObj.value);
63 ok(gotValue, aImageType + " - getData() returned a value");
64 if (gotValue)
66 const knsIInputStream = Ci.nsIInputStream;
67 var imgStream = dataObj.value.QueryInterface(knsIInputStream);
68 ok((null != imgStream), aImageType + " - got an nsIInputStream");
69 var bytesAvailable = imgStream.available();
70 ok((bytesAvailable > 10), aImageType + " - got some data");
74 function initAndRunTests()
76 SimpleTest.waitForExplicitFinish();
78 copyImageToClipboard();
80 var cbSvc = Cc["@mozilla.org/widget/clipboard;1"]
81 .getService(knsIClipboard);
83 // Work around a problem on Windows where clipboard is not ready after copy.
84 setTimeout(function() { runTests(cbSvc); }, 0);
87 function runTests(aCBSvc)
89 runImageClipboardTests(aCBSvc, "image/png");
90 runImageClipboardTests(aCBSvc, "image/jpg");
91 runImageClipboardTests(aCBSvc, "image/jpeg");
93 SimpleTest.finish();
96 ]]>
97 </script>
98 </window>