/** *Basicreadingtestforasynchronouslyopenedjarchannel
*/ function testAsync() { var uri = jarBase + "/inner40.zip"; var chan = NetUtil.newChannel({ uri, loadUsingSystemPrincipal: true }); Assert.less(chan.contentLength, 0);
chan.asyncOpen( new Listener(function (l) { Assert.greater(chan.contentLength, 0); Assert.ok(l.gotStartRequest); Assert.ok(l.gotStopRequest); Assert.equal(l.available, chan.contentLength);
run_next_test();
})
);
}
add_test(testAsync); // Run same test again so we test the codepath for a zipcache hit
add_test(testAsync);
/** *BasictestfornsIZipReader.
*/ function testZipEntry() { var uri = jarBase + "/inner40.zip"; var chan = NetUtil.newChannel({
uri,
loadUsingSystemPrincipal: true,
}).QueryInterface(Ci.nsIJARChannel); var entry = chan.zipEntry; Assert.equal(entry.CRC32, 0x8b635486); Assert.equal(entry.realSize, 184);
run_next_test();
}
add_test(testZipEntry);
/** *Basicreadingtestforsynchronouslyopenedjarchannels
*/
add_test(function testSync() { var uri = jarBase + "/inner40.zip"; var chan = NetUtil.newChannel({ uri, loadUsingSystemPrincipal: true }); var stream = chan.open(); Assert.greater(chan.contentLength, 0); Assert.equal(stream.available(), chan.contentLength);
stream.close();
stream.close(); // should still not throw
run_next_test();
});
/** *Basicreadingtestforsynchronouslyopened,nestedjarchannels
*/
add_test(function testSyncNested() { var uri = "jar:" + jarBase + "/inner40.zip!/foo"; var chan = NetUtil.newChannel({ uri, loadUsingSystemPrincipal: true }); var stream = chan.open(); Assert.greater(chan.contentLength, 0); Assert.equal(stream.available(), chan.contentLength);
stream.close();
stream.close(); // should still not throw
run_next_test();
});
/** *Basicreadingtestforasynchronouslyopened,nestedjarchannels
*/
add_test(function testAsyncNested() { var uri = "jar:" + jarBase + "/inner40.zip!/foo"; var chan = NetUtil.newChannel({ uri, loadUsingSystemPrincipal: true });
chan.asyncOpen( new Listener(function (l) { Assert.greater(chan.contentLength, 0); Assert.ok(l.gotStartRequest); Assert.ok(l.gotStopRequest); Assert.equal(l.available, chan.contentLength);
run_next_test();
})
);
});
/** *Verifythatfilelocksarereleasedwhenclosingasynchronously *openedjarchannelstream
*/
add_test(function testSyncCloseUnlocks() { var copy = tmpDir.clone();
copy.append(fileBase);
file.copyTo(copy.parent, copy.leafName); var uri = "jar:" + ios.newFileURI(copy).spec + "!/inner40.zip"; var chan = NetUtil.newChannel({ uri, loadUsingSystemPrincipal: true }); var stream = chan.open(); Assert.greater(chan.contentLength, 0);
stream.close();
// Drop any jar caches
obs.notifyObservers(null, "chrome-flush-caches");
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.