4 https://bugzilla.mozilla.org/show_bug.cgi?id=565392
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"/>
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=565392">Mozilla Bug
565392</a>
14 <div id=
"content" style=
"display: none">
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);
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);
48 transferable.getTransferData(mime, 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);