var pipe1; var pipe2; var copier; var test_result; var test_content; var test_source_closed; var test_sink_closed; var test_nr;
var copyObserver = {
onStartRequest() {},
onStopRequest(request, statusCode) { // check status code Assert.equal(statusCode, test_result);
// check number of copied bytes Assert.equal(pipe2.inputStream.available(), test_content.length);
// check content var scinp = new ScriptableInputStream(pipe2.inputStream); var content = scinp.read(scinp.available()); Assert.equal(content, test_content);
function do_test() {
test_nr++;
test_content = "test" + test_nr;
switch (test_nr) { case 1: case 2: // close sink case 3: // close source case 4: // close both // test canceling transfer // use some undefined error code to check if it is successfully passed // to the request observer
test_result = 0x87654321;
startCopier(test_source_closed, test_sink_closed);
pipe1.outputStream.write(test_content, test_content.length);
pipe1.outputStream.flush();
do_timeout(20, function () {
copier.cancel(test_result);
pipe1.outputStream.write("a", 1);
}); break; case 5: case 6: // close sink case 7: // close source case 8: // close both // test copying with EOF on source
test_result = 0;
startCopier(test_source_closed, test_sink_closed);
pipe1.outputStream.write(test_content, test_content.length); // we will close the source
test_source_closed = true;
pipe1.outputStream.close(); break; case 9: case 10: // close sink case 11: // close source case 12: // close both // test copying with error on sink // use some undefined error code to check if it is successfully passed // to the request observer
test_result = 0x87654321;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.