Bug 536324 part 4 - Test to make sure 64-bit content length works. r=sworkman

This commit is contained in:
Nick Hurley 2012-10-22 10:51:07 -07:00
parent e7f284c9d3
commit 684928aad9
2 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,66 @@
/* Test to ensure our 64-bit content length implementation works, at least for
a simple HTTP case */
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const Cr = Components.results;
Cu.import("resource://testing-common/httpd.js");
// This C-L is significantly larger than (U)INT32_MAX, to make sure we do
// 64-bit properly.
const CONTENT_LENGTH = "1152921504606846975";
var httpServer = null;
var listener = {
onStartRequest: function (req, ctx) {
},
onDataAvailable: function (req, ctx, stream, off, count) {
do_check_eq(req.getResponseHeader("Content-Length"), CONTENT_LENGTH);
// We're done here, cancel the channel
req.cancel(NS_BINDING_ABORT);
},
onStopRequest: function (req, ctx, stat) {
httpServer.stop(do_test_finished);
}
};
function hugeContentLength(metadata, response) {
var text = "abcdefghijklmnopqrstuvwxyz";
var bytes_written = 0;
response.seizePower();
response.write("HTTP/1.1 200 OK\r\n");
response.write("Content-Length: " + CONTENT_LENGTH + "\r\n");
response.write("Connection: close\r\n");
response.write("\r\n");
// Write enough data to ensure onDataAvailable gets called
while (bytes_written < 4096) {
response.write(text);
bytes_written += text.length;
}
response.finish();
}
function test_hugeContentLength() {
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var chan = ios.newChannel("http://localhost:4444/", null, null)
.QueryInterface(Ci.nsIHttpChannel);
chan.asyncOpen(listener, null);
}
add_test(test_hugeContentLength);
function run_test() {
httpServer = new HttpServer();
httpServer.registerPathHandler("/", hugeContentLength);
httpServer.start(4444);
run_next_test();
}

View File

@ -57,6 +57,7 @@ skip-if = os == "android"
skip-if = os == "android"
[test_bug515583.js]
[test_bug528292.js]
[test_bug536324_64bit_content_length.js]
[test_bug540566.js]
[test_bug543805.js]
[test_bug553970.js]