gecko-dev/content/base/test/test_bug578096.html
2010-09-09 22:43:22 -04:00

49 lines
1.4 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=578096
-->
<head>
<title>Test for Bug 578096</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=578096">Mozilla Bug 578096</a>
<p id="display"></p>
<div id="content">
<input type="file" id="file" onchange="fireXHR()">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
const Cc = Components.classes;
const Ci = Components.interfaces;
var file = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("TmpD", Ci.nsIFile);
file.append("foo.txt");
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
SimpleTest.waitForExplicitFinish();
document.getElementById('file').value = file.path;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(event) {
if (xhr.readyState == 4) {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
file.remove(false);
ok(true, "We didn't throw! Yay!");
SimpleTest.finish();
}
}
xhr.open('POST', window.location, true);
xhr.send(document.getElementById('file').files[0]);
</script>
</pre>
</body>
</html>