B2G/gecko/dom/plugins/test/mochitest/neverending.sjs
// declare timer outside to prevent premature GC

declare timer outside to prevent premature GC
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 , Components.interfaces.nsITimer.TYPE_ONE_SHOT);
}
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 , Components . interfaces . nsITimer . TYPE_ONE_SHOT ) ; }
declare timer outside to prevent premature GC
declare timer outside to prevent premature GC
/* 10 secs */