2010-06-09 23:08:09 +04:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=565392
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 565392</title>
|
2016-12-04 19:23:40 +03:00
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
|
2010-06-09 23:08:09 +04:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=565392">Mozilla Bug 565392</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 565392 **/
|
|
|
|
|
|
|
|
var ds = Cc["@mozilla.org/file/directory_service;1"]
|
|
|
|
.getService(Ci.nsIProperties);
|
|
|
|
var dir1 = ds.get("ProfD", Ci.nsIFile);
|
|
|
|
var clipboard = Cc["@mozilla.org/widget/clipboard;1"]
|
|
|
|
.getService(Ci.nsIClipboard);
|
|
|
|
|
2012-04-17 06:14:01 +04:00
|
|
|
function getLoadContext() {
|
2018-08-01 20:07:11 +03:00
|
|
|
return window.docShell.QueryInterface(Ci.nsILoadContext);
|
2012-04-17 06:14:01 +04:00
|
|
|
}
|
|
|
|
|
2010-06-09 23:08:09 +04:00
|
|
|
function getTransferableFile(file) {
|
|
|
|
var transferable = Cc['@mozilla.org/widget/transferable;1']
|
|
|
|
.createInstance(Ci.nsITransferable);
|
2012-04-17 06:14:01 +04:00
|
|
|
transferable.init(getLoadContext());
|
2018-11-20 18:13:18 +03:00
|
|
|
transferable.setTransferData("application/x-moz-file", file, 0);
|
2010-06-09 23:08:09 +04:00
|
|
|
return transferable;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setClipboardData(transferable) {
|
|
|
|
clipboard.setData(transferable, null, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getClipboardData(mime) {
|
|
|
|
var transferable = Cc['@mozilla.org/widget/transferable;1']
|
|
|
|
.createInstance(Ci.nsITransferable);
|
2012-04-17 06:14:01 +04:00
|
|
|
transferable.init(getLoadContext());
|
2010-06-09 23:08:09 +04:00
|
|
|
transferable.addDataFlavor(mime);
|
|
|
|
clipboard.getData(transferable, 1);
|
|
|
|
var data = {};
|
2018-11-20 18:13:18 +03:00
|
|
|
transferable.getTransferData(mime, data, {}) ;
|
2010-06-09 23:08:09 +04:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
setClipboardData(getTransferableFile(dir1))
|
|
|
|
is(clipboard.hasDataMatchingFlavors(["application/x-moz-file"], 1,1), true);
|
|
|
|
var data = getClipboardData("application/x-moz-file");
|
|
|
|
var file = data.value.QueryInterface(Ci.nsIFile);
|
|
|
|
ok(file.isDirectory(), true);
|
|
|
|
is(file.target, dir1.target, true);
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|