gecko/content/base/test/test_bug578096.html

46 lines
1.3 KiB
HTML
Raw Normal View History

2010-09-09 19:43:22 -07:00
<!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">
const Cc = SpecialPowers.Cc;
const Ci = SpecialPowers.Ci;
2010-09-09 19:43:22 -07:00
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();
SpecialPowers.wrap(document.getElementById('file')).value = file.path;
2010-09-09 19:43:22 -07:00
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(event) {
if (xhr.readyState == 4) {
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>