michael@0: var timer = null; // Declare outside to prevent premature GC 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/javascript", false); michael@0: response.write("var i = 0;"); 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: }, 500, Components.interfaces.nsITimer.TYPE_ONE_SHOT); michael@0: } michael@0: