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.)

     1 function setOurState(data) {
     2   x = { data: data, QueryInterface: function(iid) { return this } };
     3   x.wrappedJSObject = x;
     4   setObjectState("bug602838", x);
     5 }
     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 }
    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 }

mercurial