content/base/test/script_bug602838.sjs

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

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

mercurial