michael@0: function setOurState(data) { michael@0: x = { data: data, QueryInterface: function(iid) { return this } }; michael@0: x.wrappedJSObject = x; michael@0: setObjectState("bug602838", x); michael@0: } michael@0: michael@0: function getOurState() { michael@0: var data; michael@0: getObjectState("bug602838", function(x) { michael@0: // x can be null if no one has set any state yet michael@0: if (x) { michael@0: data = x.wrappedJSObject.data; michael@0: } michael@0: }); michael@0: return data; michael@0: } michael@0: michael@0: function handleRequest(request, response) michael@0: { michael@0: if (request.queryString) { michael@0: let blockedResponse = getOurState(); michael@0: if (typeof(blockedResponse) == "object") { michael@0: blockedResponse.finish(); michael@0: setOurState(null); michael@0: } else { michael@0: setOurState("unblocked"); michael@0: } michael@0: return; michael@0: } michael@0: response.setHeader("Cache-Control", "no-cache", false); michael@0: response.setHeader("Content-Type", "text/javascript", false); michael@0: response.write("ok(asyncRan, 'Async script should have run first.'); firstRan = true;"); michael@0: if (getOurState() != "unblocked") { michael@0: response.processAsync(); michael@0: setOurState(response); michael@0: } michael@0: }