1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/script_bug602838.sjs Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,37 @@ 1.4 +function setOurState(data) { 1.5 + x = { data: data, QueryInterface: function(iid) { return this } }; 1.6 + x.wrappedJSObject = x; 1.7 + setObjectState("bug602838", x); 1.8 +} 1.9 + 1.10 +function getOurState() { 1.11 + var data; 1.12 + getObjectState("bug602838", function(x) { 1.13 + // x can be null if no one has set any state yet 1.14 + if (x) { 1.15 + data = x.wrappedJSObject.data; 1.16 + } 1.17 + }); 1.18 + return data; 1.19 +} 1.20 + 1.21 +function handleRequest(request, response) 1.22 +{ 1.23 + if (request.queryString) { 1.24 + let blockedResponse = getOurState(); 1.25 + if (typeof(blockedResponse) == "object") { 1.26 + blockedResponse.finish(); 1.27 + setOurState(null); 1.28 + } else { 1.29 + setOurState("unblocked"); 1.30 + } 1.31 + return; 1.32 + } 1.33 + response.setHeader("Cache-Control", "no-cache", false); 1.34 + response.setHeader("Content-Type", "text/javascript", false); 1.35 + response.write("ok(asyncRan, 'Async script should have run first.'); firstRan = true;"); 1.36 + if (getOurState() != "unblocked") { 1.37 + response.processAsync(); 1.38 + setOurState(response); 1.39 + } 1.40 +}