Test for Bug 578096. a=test-only

This commit is contained in:
Kyle Huey 2010-09-09 22:43:22 -04:00
Родитель b7b7281213
Коммит c7ce5bdef2
2 изменённых файлов: 49 добавлений и 0 удалений

Просмотреть файл

@ -414,6 +414,7 @@ _TEST_FILES2 = \
file_x-frame-options_main.html \
file_x-frame-options_page.sjs \
test_createHTMLDocument.html \
test_bug578096.html \
$(NULL)
# This test fails on the Mac for some reason

Просмотреть файл

@ -0,0 +1,48 @@
<!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>