2 * Adapted from https://searchfox.org/mozilla-central/source/layout/reftests/backgrounds/delay-image-response.sjs
7 // Source: https://commons.wikimedia.org/wiki/File:1x1.png (Public Domain)
9 "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAA" +
10 "ACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII="
16 function handleRequest(request, response) {
18 request.queryString.split("&").forEach(function (val) {
19 const [name, value] = val.split("=");
20 query[name] = unescape(value);
23 response.setStatusLine(request.httpVersion, 200, "OK");
24 response.setHeader("Content-Type", "image/png", false);
26 // If there is no delay, we write the image and leave.
27 if (!("delay" in query)) {
28 response.write(IMAGE);
32 // If there is a delay, we create a timer which, when it fires, will write
34 response.processAsync();
35 const nsITimer = Ci.nsITimer;
37 timer = Cc["@mozilla.org/timer;1"].createInstance(nsITimer);
38 timer.initWithCallback(
40 response.write(IMAGE);
44 nsITimer.TYPE_ONE_SHOT