browser/devtools/netmonitor/test/sjs_sorting-test-server.sjs

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/netmonitor/test/sjs_sorting-test-server.sjs	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,21 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +const { classes: Cc, interfaces: Ci } = Components;
     1.8 +
     1.9 +function handleRequest(request, response) {
    1.10 +  response.processAsync();
    1.11 +
    1.12 +  let params = request.queryString.split("&");
    1.13 +  let index = params.filter((s) => s.contains("index="))[0].split("=")[1];
    1.14 +
    1.15 +  let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
    1.16 +  timer.initWithCallback(() => {
    1.17 +    // to avoid garbage collection
    1.18 +    timer = null;
    1.19 +    response.setStatusLine(request.httpVersion, index == 1 ? 101 : index * 100, "Meh");
    1.20 +    response.setHeader("Content-Type", "text/" + index, false);
    1.21 +    response.write(new Array(index * 10).join(index)); // + 0.01 KB
    1.22 +    response.finish();
    1.23 +  }, 10, Ci.nsITimer.TYPE_ONE_SHOT); // Make sure this request takes a few ms.
    1.24 +}

mercurial