summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/tabdialogs/loadDelayedReply.sjs
blob: cf046967bf0be8a551a388fafc114abb8fa4b7c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

function handleRequest(request, response) {
  response.processAsync();
  if (request.method === "POST") {
    getObjectState("wait", queryResponse => {
      if (!queryResponse) {
        throw new Error("Wrong call order");
      }
      queryResponse.finish();

      response.setStatusLine(request.httpVersion, 200);
      response.write("OK");
      response.finish();
    });
    return;
  }
  response.setStatusLine(request.httpVersion, 200);
  response.write("OK");
  setObjectState("wait", response);
}