content/base/test/script_bug602838.sjs

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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