file_bug543062.sjs (1098B)
1 var timer; 2 3 function armTimer(response) { 4 timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); 5 timer.initWithCallback( 6 function () { 7 if ( 8 getState("docwritepreloadssecond") == "second" && 9 getState("docwritepreloadsthird") == "third" 10 ) { 11 response.write( 12 "ok(true, 'Second and third scripts should have started loading while the first one is loading');" 13 ); 14 response.finish(); 15 } else { 16 armTimer(response); 17 } 18 }, 19 20, 20 Ci.nsITimer.TYPE_ONE_SHOT 21 ); 22 } 23 24 function handleRequest(request, response) { 25 response.setHeader("Cache-Control", "no-cache", false); 26 response.setHeader("Content-Type", "text/javascript", false); 27 if (request.queryString.includes("first")) { 28 response.write("// first\n"); 29 response.processAsync(); 30 armTimer(response); 31 } else if (request.queryString.includes("second")) { 32 response.write("// second\n"); 33 setState("docwritepreloadssecond", "second"); 34 } else { 35 response.write("// third\n"); 36 setState("docwritepreloadsthird", "third"); 37 } 38 }