gecko-dev/content/base/test/test_bug414796.html

56 строки
1.6 KiB
HTML
Исходник Обычный вид История

<!DOCTYPE HTML>
<html>
<head>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=414796
-->
<title>Test for Bug 414796</title>
<script type="text/javascript" src="/MochiKit/packed.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=414796">Mozilla Bug 414796</a>
<p id="display">
<input id="fileList" type="file"></input>
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// Write a test file > 8192 characters
var testData = "asdfblahqwer";
for (var i = 0; i < 10; i++) {
testData = testData + testData;
}
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
testFile.append("testfile");
var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
0666, 0);
outStream.write(testData, testData.length);
outStream.close();
var fileList = document.getElementById('fileList');
fileList.value = testFile.path;
var domFileData = fileList.files[0].getAsText("iso-8859-1");
ok(domFileData.length == testData.length);
ok(domFileData == testData);
testFile.remove(false);
</script>
</pre>
</body> </html>