parser/htmlparser/tests/mochitest/file_bug543062.sjs

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/parser/htmlparser/tests/mochitest/file_bug543062.sjs	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,32 @@
     1.4 +var timer;
     1.5 +
     1.6 +function armTimer(response) {
     1.7 +  timer = Components.classes["@mozilla.org/timer;1"]
     1.8 +    .createInstance(Components.interfaces.nsITimer);
     1.9 +  timer.initWithCallback(function() {
    1.10 +      if (getState("docwritepreloadssecond") == "second" && getState("docwritepreloadsthird") == "third") {
    1.11 +        response.write("ok(true, 'Second and third scripts should have started loading while the first one is loading');");
    1.12 +        response.finish();
    1.13 +      } else {
    1.14 +        armTimer(response);
    1.15 +      }
    1.16 +    }, 20, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
    1.17 +}
    1.18 +
    1.19 +function handleRequest(request, response)
    1.20 +{
    1.21 +  response.setHeader("Cache-Control", "no-cache", false);
    1.22 +  response.setHeader("Content-Type", "text/javascript", false);
    1.23 +  if (request.queryString.indexOf("first") != -1) {
    1.24 +    response.write("// first\n");
    1.25 +    response.processAsync();
    1.26 +    armTimer(response);
    1.27 +  } else if (request.queryString.indexOf("second") != -1) {
    1.28 +    response.write("// second\n");
    1.29 +    setState("docwritepreloadssecond", "second");
    1.30 +  } else {
    1.31 +    response.write("// third\n");
    1.32 +    setState("docwritepreloadsthird", "third");
    1.33 +  }
    1.34 +}
    1.35 +

mercurial