michael@0: var timer; // Place timer in global scope to avoid it getting GC'ed prematurely
michael@0:
michael@0: function handleRequest(request, response)
michael@0: {
michael@0: response.setHeader("Cache-Control", "no-cache", false);
michael@0: response.setHeader("Content-Type", "text/html", false);
michael@0: response.write("");
michael@0: response.write("
");
michael@0: for (var i = 0; i < 2000; i++) {
michael@0: response.write("Lorem ipsum dolor sit amet. ");
michael@0: }
michael@0: response.write("
");
michael@0: response.bodyOutputStream.flush();
michael@0: response.processAsync();
michael@0: timer = Components.classes["@mozilla.org/timer;1"]
michael@0: .createInstance(Components.interfaces.nsITimer);
michael@0: timer.initWithCallback(function() {
michael@0: response.finish();
michael@0: }, 1200, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
michael@0: }
michael@0: