Backed out changeset c8d01bb9a6a2 (bug 1866098) for causing bp-nu build bustages...
[gecko.git] / widget / tests / test_bug565392.html
bloba0efc0a7f908223652e7ed55bfef1b2f858cfd41
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=565392
5 -->
6 <head>
7 <title>Test for Bug 565392</title>
8 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=565392">Mozilla Bug 565392</a>
13 <p id="display"></p>
14 <div id="content" style="display: none">
16 </div>
17 <pre id="test">
18 <script type="application/javascript">
20 /** Test for Bug 565392 */
22 var dir1 = Services.dirsvc.get("ProfD", Ci.nsIFile);
23 var clipboard = Services.clipboard;
25 function getLoadContext() {
26 return window.docShell.QueryInterface(Ci.nsILoadContext);
29 function getTransferableFile(file) {
30 var transferable = Cc["@mozilla.org/widget/transferable;1"]
31 .createInstance(Ci.nsITransferable);
32 transferable.init(getLoadContext());
33 transferable.setTransferData("application/x-moz-file", file);
34 return transferable;
37 function setClipboardData(transferable) {
38 clipboard.setData(transferable, null, 1);
41 function getClipboardData(mime) {
42 var transferable = Cc["@mozilla.org/widget/transferable;1"]
43 .createInstance(Ci.nsITransferable);
44 transferable.init(getLoadContext());
45 transferable.addDataFlavor(mime);
46 clipboard.getData(transferable, 1);
47 var data = {};
48 transferable.getTransferData(mime, data);
49 return data;
52 setClipboardData(getTransferableFile(dir1));
53 is(clipboard.hasDataMatchingFlavors(["application/x-moz-file"], 1), true);
54 var data = getClipboardData("application/x-moz-file");
55 var file = data.value.QueryInterface(Ci.nsIFile);
56 ok(file.isDirectory(), true);
57 is(file.target, dir1.target, true);
59 </script>
60 </pre>
61 </body>
62 </html>