Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: dom/workers/test/chrome.toml
<?xml version="1.0"?>
<!--
-->
<script type="application/javascript" src="dom_worker_helper.js"/>
<!-- test results are displayed in the html:body -->
<div id="content" style="display: none">
<input id="fileList" type="file"></input>
</div>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
var fileNum = 0;
/**
* Create a file which contains the given data.
*/
function createFileWithData(fileData) {
var testFile = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("ProfD", Ci.nsIFile);
testFile.append("workerFileReaderSyncErrors" + fileNum++);
var outStream = Cc["@mozilla.org/network/file-output-stream;1"]
.createInstance(Ci.nsIFileOutputStream);
outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
0o666, 0);
outStream.write(fileData, fileData.length);
outStream.close();
var fileList = document.getElementById('fileList');
fileList.value = testFile.path;
return fileList.files[0];
}
/**
* Creates a worker which runs errors cases.
*/
function runWorkerErrors(file) {
var worker = new Worker("fileReaderSyncErrors_worker.js");
worker.onerror = function(event) {
ok(false, "Worker had an error: " + event.message);
finish();
};
worker.onmessage = function(event) {
if(event.data == undefined) {
// Worker returns undefined when tests have finished running.
finish();
} else {
// Otherwise worker will return results of tests to be evaluated.
is(event.data.actual, event.data.expected, event.data.message);
}
};
worker.postMessage(file);
waitForWorkerFinish();
}
// Run worker which creates exceptions.
runWorkerErrors(createFileWithData("text"));
]]>
</script>
</window>