forked from mirrors/gecko-dev
This patch was autogenerated by my decomponents.py
It covers almost every file with the extension js, jsm, html, py,
xhtml, or xul.
It removes blank lines after removed lines, when the removed lines are
preceded by either blank lines or the start of a new block. The "start
of a new block" is defined fairly hackily: either the line starts with
//, ends with */, ends with {, <![CDATA[, """ or '''. The first two
cover comments, the third one covers JS, the fourth covers JS embedded
in XUL, and the final two cover JS embedded in Python. This also
applies if the removed line was the first line of the file.
It covers the pattern matching cases like "var {classes: Cc,
interfaces: Ci, utils: Cu, results: Cr} = Components;". It'll remove
the entire thing if they are all either Ci, Cr, Cc or Cu, or it will
remove the appropriate ones and leave the residue behind. If there's
only one behind, then it will turn it into a normal, non-pattern
matching variable definition. (For instance, "const { classes: Cc,
Constructor: CC, interfaces: Ci, utils: Cu } = Components" becomes
"const CC = Components.Constructor".)
MozReview-Commit-ID: DeSHcClQ7cG
--HG--
extra : rebase_source : d9c41878036c1ef7766ef5e91a7005025bc1d72b
150 lines
4.1 KiB
JavaScript
150 lines
4.1 KiB
JavaScript
// test bug 1312774.
|
|
// Create 6 (=network.http.max-persistent-connections-per-server)
|
|
// common Http requests and 2 urgent-start Http requests to a single
|
|
// host and path, in parallel.
|
|
// Let all the requests unanswered by the server handler. (process them
|
|
// async and don't finish)
|
|
// The first 6 pending common requests will fill the limit for per-server
|
|
// parallelism.
|
|
// But the two urgent requests must reach the server despite those 6 common
|
|
// pending requests.
|
|
// The server handler doesn't let the test finish until all 8 expected requests
|
|
// arrive.
|
|
// Note: if the urgent request handling is broken (the urgent-marked requests
|
|
// get blocked by queuing) this test will time out
|
|
|
|
ChromeUtils.import("resource://testing-common/httpd.js");
|
|
ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
|
var server = new HttpServer();
|
|
server.start(-1);
|
|
var baseURL = "http://localhost:" + server.identity.primaryPort + "/";
|
|
var maxConnections = 0;
|
|
var urgentRequests = 0;
|
|
var totalRequests = 0;
|
|
var debug = false;
|
|
|
|
|
|
function log(msg) {
|
|
if (!debug) {
|
|
return;
|
|
}
|
|
|
|
if (msg) {
|
|
dump("TEST INFO | " + msg + "\n");
|
|
}
|
|
}
|
|
|
|
function make_channel(url) {
|
|
var request = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
|
request.QueryInterface(Ci.nsIHttpChannel);
|
|
return request;
|
|
}
|
|
|
|
function serverStopListener() {
|
|
server.stop();
|
|
}
|
|
|
|
function commonHttpRequest(id) {
|
|
let uri = baseURL;
|
|
var chan = make_channel(uri);
|
|
var listner = new HttpResponseListener(id);
|
|
chan.setRequestHeader("X-ID", id, false);
|
|
chan.setRequestHeader("Cache-control", "no-store", false);
|
|
chan.asyncOpen2(listner);
|
|
log("Create common http request id=" + id);
|
|
}
|
|
|
|
function urgentStartHttpRequest(id) {
|
|
let uri = baseURL;
|
|
var chan = make_channel(uri);
|
|
var listner = new HttpResponseListener(id);
|
|
var cos = chan.QueryInterface(Ci.nsIClassOfService);
|
|
cos.addClassFlags(Ci.nsIClassOfService.UrgentStart);
|
|
chan.setRequestHeader("X-ID", id, false);
|
|
chan.setRequestHeader("Cache-control", "no-store", false);
|
|
chan.asyncOpen2(listner);
|
|
log("Create urgent-start http request id=" + id);
|
|
}
|
|
|
|
function setup_httpRequests() {
|
|
log("setup_httpRequests");
|
|
for (var i = 0; i < maxConnections ; i++) {
|
|
commonHttpRequest(i);
|
|
do_test_pending();
|
|
}
|
|
}
|
|
|
|
function setup_urgentStartRequests() {
|
|
for (var i = 0; i < urgentRequests; i++) {
|
|
urgentStartHttpRequest(1000 + i);
|
|
do_test_pending();
|
|
}
|
|
}
|
|
|
|
function HttpResponseListener(id)
|
|
{
|
|
this.id = id
|
|
};
|
|
|
|
var testOrder = 0;
|
|
HttpResponseListener.prototype =
|
|
{
|
|
onStartRequest: function (request, ctx) {
|
|
},
|
|
|
|
onDataAvailable: function (request, ctx, stream, off, cnt) {
|
|
},
|
|
|
|
onStopRequest: function (request, ctx, status) {
|
|
log("STOP id=" + this.id);
|
|
do_test_finished();
|
|
}
|
|
};
|
|
|
|
var responseQueue = new Array();
|
|
function setup_http_server()
|
|
{
|
|
log("setup_http_server");
|
|
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
|
maxConnections = prefs.getIntPref("network.http.max-persistent-connections-per-server");
|
|
urgentRequests = 2;
|
|
totalRequests = maxConnections + urgentRequests;
|
|
var allCommonHttpRequestReceived = false;
|
|
// Start server; will be stopped at test cleanup time.
|
|
server.registerPathHandler('/', function(metadata, response)
|
|
{
|
|
var id = metadata.getHeader("X-ID");
|
|
log("Server recived the response id=" + id);
|
|
response.processAsync();
|
|
responseQueue.push(response);
|
|
|
|
if (responseQueue.length == maxConnections && !allCommonHttpRequestReceived) {
|
|
allCommonHttpRequestReceived = true;
|
|
setup_urgentStartRequests();
|
|
}
|
|
// Wait for all expected requests to come but don't process then.
|
|
// Collect them in a queue for later processing. We don't want to
|
|
// respond to the client until all the expected requests are made
|
|
// to the server.
|
|
if (responseQueue.length == maxConnections + urgentRequests) {
|
|
processResponse();
|
|
}
|
|
});
|
|
|
|
registerCleanupFunction(function() {
|
|
server.stop(serverStopListener);
|
|
});
|
|
}
|
|
|
|
function processResponse() {
|
|
while (responseQueue.length) {
|
|
var resposne = responseQueue.pop();
|
|
resposne.finish();
|
|
}
|
|
}
|
|
|
|
function run_test() {
|
|
setup_http_server();
|
|
setup_httpRequests();
|
|
}
|
|
|