Bug 872379 - Netmonitor tests SJS: Store a reference to the response timer to avoid garbage collection before the timer fires. Otherwise netmonitor tests timeout waiting for missing responses. r=vp

This commit is contained in:
Sami Jaktholm 2014-06-30 03:09:00 -04:00
parent edb9591ffe
commit 23cea067c1
3 changed files with 12 additions and 3 deletions

View File

@ -29,7 +29,10 @@ function handleRequest(request, response) {
cachedCount++;
}
Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer).initWithCallback(() => {
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
timer.initWithCallback(() => {
// to avoid garbage collection
timer = null;
switch (format) {
case "txt": {
response.setStatusLine(request.httpVersion, status, "DA DA DA");

View File

@ -9,7 +9,10 @@ function handleRequest(request, response) {
let params = request.queryString.split("&");
let index = params.filter((s) => s.contains("index="))[0].split("=")[1];
Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer).initWithCallback(() => {
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
timer.initWithCallback(() => {
// to avoid garbage collection
timer = null;
response.setStatusLine(request.httpVersion, index == 1 ? 101 : index * 100, "Meh");
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");

View File

@ -9,7 +9,10 @@ function handleRequest(request, response) {
let params = request.queryString.split("&");
let status = params.filter((s) => s.contains("sts="))[0].split("=")[1];
Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer).initWithCallback(() => {
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
timer.initWithCallback(() => {
// to avoid garbage collection
timer = null;
switch (status) {
case "100":
response.setStatusLine(request.httpVersion, 101, "Switching Protocols");