mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
45f8681fa5
The dom/base tests changed here use SpecialPowers.loadChromeScript to construct a DOM File in the parent and send it to the child, using the existing remote-blob infrastructure. The dom/html tests don't need a real file, so they now construct in-memory files. As a convenient side-effect, these tests are now enabled for desktop e10s (they were already being run out-of-process on B2G); most of them failed before this change due to the code that's being moved/removed.
30 lines
994 B
JavaScript
30 lines
994 B
JavaScript
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
|
Cu.importGlobalProperties(["File"]);
|
|
|
|
var fileNum = 1;
|
|
|
|
function createFileWithData(fileData) {
|
|
var willDelete = fileData === null;
|
|
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
|
|
var testFile = dirSvc.get("ProfD", Ci.nsIFile);
|
|
testFile.append("fileAPItestfile" + fileNum);
|
|
fileNum++;
|
|
var outStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
|
|
outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
|
|
0666, 0);
|
|
if (willDelete) {
|
|
fileData = "some irrelevant test data\n";
|
|
}
|
|
outStream.write(fileData, fileData.length);
|
|
outStream.close();
|
|
var domFile = new File(testFile);
|
|
if (willDelete) {
|
|
testFile.remove(/* recursive: */ false);
|
|
}
|
|
return domFile;
|
|
}
|
|
|
|
addMessageListener("files.open", function (message) {
|
|
sendAsyncMessage("files.opened", message.map(createFileWithData));
|
|
});
|