summaryrefslogtreecommitdiffstats
path: root/dom/plugins/test/mochitest/neverending.sjs
blob: 1576ce344c79726535ce9135baebdc22b42c68f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var timer = null; // declare timer outside to prevent premature GC
function handleRequest(request, response)
{
  response.processAsync();
  response.setHeader("Content-Type", "text/plain", false);

  for (var i = 0; i < 1000; ++i)
    response.write("Hello... ");

  timer = Components.classes["@mozilla.org/timer;1"]
    .createInstance(Components.interfaces.nsITimer);
  timer.initWithCallback(function() {
      response.write("world.\n");
      response.finish();
    }, 10 * 1000 /* 10 secs */, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
}