summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/urlbar/slow-page.sjs
blob: f428d66e48d391d5b07d48e553e4ad52303f59d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"use strict";

const Cc = Components.classes;
const Ci = Components.interfaces;

let timer;

const DELAY_MS = 5000;
function handleRequest(request, response) {
  if (request.queryString.endsWith("faster")) {
    response.setHeader("Content-Type", "text/html", false);
    response.write("<body>Not so slow!</body>");
    return;
  }
  response.processAsync();
  timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
  timer.init(() => {
    response.setHeader("Content-Type", "text/html", false);
    response.write("<body>This was the slow load. You should never see this.</body>");
    response.finish();
  }, DELAY_MS, Ci.nsITimer.TYPE_ONE_SHOT);
}