2010-02-11 00:35:49 -08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<input id="target" type="file" />
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cu = Components.utils;
|
|
|
|
const Cm = Components.manager;
|
|
|
|
|
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
|
|
|
.loadSubScript("chrome://mochikit/content/browser/toolkit/content/tests/browser/common/mockObjects.js", this);
|
|
|
|
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
|
|
|
|
function MockFilePicker() { };
|
|
|
|
MockFilePicker.prototype = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFilePicker]),
|
|
|
|
init: function(aParent, aTitle, aMode) { },
|
|
|
|
appendFilters: function(aFilterMask) { },
|
|
|
|
appendFilter: function(aTitle, aFilter) { },
|
|
|
|
defaultString: "",
|
|
|
|
defaultExtension: "",
|
|
|
|
filterIndex: 0,
|
|
|
|
displayDirectory: null,
|
|
|
|
get file() {
|
2010-08-27 08:49:10 -07:00
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
2010-02-11 00:35:49 -08:00
|
|
|
var f = window.parent.dirs[window.parent.index].clone();
|
|
|
|
f.append("aFile.txt");
|
|
|
|
return f;
|
|
|
|
},
|
|
|
|
get fileURL() {
|
|
|
|
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
},
|
|
|
|
get files() {
|
|
|
|
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
},
|
|
|
|
show: function MFP_show() {
|
2010-08-27 08:49:10 -07:00
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
2010-02-11 00:35:49 -08:00
|
|
|
if (this.displayDirectory)
|
|
|
|
window.parent.postMessage(this.displayDirectory.path, "*");
|
|
|
|
else
|
|
|
|
window.parent.postMessage("", "*");
|
2010-08-27 08:49:10 -07:00
|
|
|
mockFilePickerRegisterer.unregister();
|
2010-02-11 00:35:49 -08:00
|
|
|
return Ci.nsIFilePicker.returnOK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var mockFilePickerRegisterer =
|
|
|
|
new MockObjectRegisterer("@mozilla.org/filepicker;1",MockFilePicker);
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
var wu = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIDOMWindowUtils);
|
|
|
|
|
|
|
|
var fileInput = document.getElementById("target");
|
|
|
|
var rect = fileInput.getBoundingClientRect();
|
|
|
|
|
|
|
|
mockFilePickerRegisterer.register();
|
|
|
|
try {
|
|
|
|
wu.sendMouseEvent("mousedown", rect.left + 5, rect.top + 5, 0, 1, 0);
|
|
|
|
wu.sendMouseEvent("mouseup", rect.left + 5, rect.top + 5, 0, 1, 0);
|
|
|
|
} catch (e) {
|
|
|
|
Cu.reportError(e);
|
|
|
|
} finally {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.onload = function() {
|
|
|
|
setTimeout(test, 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|