1 function waitForTrue(state) {
2 return new Promise(resolve => {
3 let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
6 if (getState(state) == "true") {
12 Ci.nsITimer.TYPE_REPEATING_SLACK
16 function handleRequest(request, response) {
17 response.processAsync();
19 if (request.queryString != "stop") {
20 // This is called from a synchronous XHR that we want to block until
21 // we get a stop notification.
22 waitForTrue("stop").then(() => {
26 // Signal the other connection that we've closed the connection
27 // for the synchronous XHR.
28 setState("stopped", "true");
31 // Close the connection for the synchronous XHR.
32 setState("stop", "true");
34 // Let's wait until we've actually closed the connection for the XHR.
35 waitForTrue("stopped").then(() => {