|
1 function setOurState(data) { |
|
2 x = { data: data, QueryInterface: function(iid) { return this } }; |
|
3 x.wrappedJSObject = x; |
|
4 setObjectState("bug602838", x); |
|
5 } |
|
6 |
|
7 function getOurState() { |
|
8 var data; |
|
9 getObjectState("bug602838", function(x) { |
|
10 // x can be null if no one has set any state yet |
|
11 if (x) { |
|
12 data = x.wrappedJSObject.data; |
|
13 } |
|
14 }); |
|
15 return data; |
|
16 } |
|
17 |
|
18 function handleRequest(request, response) |
|
19 { |
|
20 if (request.queryString) { |
|
21 let blockedResponse = getOurState(); |
|
22 if (typeof(blockedResponse) == "object") { |
|
23 blockedResponse.finish(); |
|
24 setOurState(null); |
|
25 } else { |
|
26 setOurState("unblocked"); |
|
27 } |
|
28 return; |
|
29 } |
|
30 response.setHeader("Cache-Control", "no-cache", false); |
|
31 response.setHeader("Content-Type", "text/javascript", false); |
|
32 response.write("ok(asyncRan, 'Async script should have run first.'); firstRan = true;"); |
|
33 if (getOurState() != "unblocked") { |
|
34 response.processAsync(); |
|
35 setOurState(response); |
|
36 } |
|
37 } |