PageRenderTime 7ms CodeModel.GetById 5ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/parser/htmlparser/tests/mochitest/file_bug655682.sjs

http://github.com/zpao/v8monkey
Unknown | 34 lines | 32 code | 2 blank | 0 comment | 0 complexity | 569e8087b6c9d456313a6ceeadd745ed MD5 | raw file
 1var timer;
 2var callback;
 3
 4function handleRequest(request, response)
 5{
 6  if (request.queryString.indexOf("trigger") != -1) {
 7    setState("triggered", "triggered");
 8    response.setHeader("Cache-Control", "no-cache", false);
 9    response.setHeader("Content-Type", "text/javascript; charset=utf-8", false);
10    response.write(";");
11  } else {
12    response.processAsync();
13    response.setHeader("Cache-Control", "no-cache", false);
14    response.setHeader("Content-Type", "text/html; charset=utf-8", false);
15    response.write("<table><tr><td>A</td>     ");
16    response.bodyOutputStream.flush();
17    timer = Components.classes["@mozilla.org/timer;1"]
18      .createInstance(Components.interfaces.nsITimer);
19
20    callback = function() {
21      if (getState("triggered") == "triggered") {
22        response.write("<td>B</td></tr></table>");
23        response.finish();
24      } else {
25        timer.initWithCallback(callback,
26                               10,
27                               Components.interfaces.nsITimer.TYPE_ONE_SHOT);
28      }
29    }
30    timer.initWithCallback(callback,
31                           10,
32                           Components.interfaces.nsITimer.TYPE_ONE_SHOT);
33    }
34}