Bug 926544 - content/base/test/test_bug578096.html needs to create file in the chrome process. r=jgriffin

This commit is contained in:
Martijn Wargers 2013-10-30 22:32:12 +01:00
parent 6583dbf261
commit 8dd41305bb
3 changed files with 38 additions and 19 deletions

View File

@ -0,0 +1,14 @@
var file;
addMessageListener("file.create", function (message) {
file = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("TmpD", Components.interfaces.nsIFile);
file.append("foo.txt");
file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0600);
sendAsyncMessage("file.path", file.path);
});
addMessageListener("file.remove", function (message) {
file.remove(false);
sendAsyncMessage("file.removed", {});
});

View File

@ -33,6 +33,7 @@ support-files =
bug475156.sjs
bug482935.sjs
bug540854.sjs
bug578096LoadChromeScript.js
bug638112-response.txt
bug638112.sjs
bug682592-subframe-ref.html

View File

@ -17,28 +17,32 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=578096
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
const Cc = SpecialPowers.Cc;
const Ci = SpecialPowers.Ci;
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;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(event) {
if (xhr.readyState == 4) {
file.remove(false);
ok(true, "We didn't throw! Yay!");
SimpleTest.finish();
var url = SimpleTest.getTestFileURL("bug578096LoadChromeScript.js");
var script = SpecialPowers.loadChromeScript(url);
script.addMessageListener("file.path", function (message) {
SpecialPowers.wrap(document.getElementById('file')).value = message;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(event) {
if (xhr.readyState == 4) {
script.sendAsyncMessage("file.remove", {});
}
}
}
xhr.open('POST', window.location, true);
xhr.send(document.getElementById('file').files[0]);
xhr.open('POST', window.location, true);
xhr.send(document.getElementById('file').files[0]);
});
script.addMessageListener("file.removed", function (message) {
ok(true, "We didn't throw! Yay!");
script.destroy();
SimpleTest.finish();
});
script.sendAsyncMessage("file.create", {});
</script>
</pre>
</body>