gecko/layout/forms/test/bug536567_subframe.html

83 lines
2.4 KiB
HTML
Raw Normal View History

<!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() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
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() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
if (this.displayDirectory)
window.parent.postMessage(this.displayDirectory.path, "*");
else
window.parent.postMessage("", "*");
mockFilePickerRegisterer.unregister();
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>