summaryrefslogtreecommitdiffstats
path: root/toolkit/components/antitracking/test/browser/file_saveAsImage.sjs
blob: 2afb7d435f0e1fc4b30a297a7ed2544fbfe28823 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// small red image
const IMAGE = atob(
  "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12" +
    "P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
);

function handleRequest(aRequest, aResponse) {
  aResponse.setStatusLine(aRequest.httpVersion, 200);

  if (aRequest.queryString.includes("result")) {
    aResponse.write(getState("hints") || 0);
    setState("hints", "0");
  } else {
    let hints = parseInt(getState("hints") || 0) + 1;
    setState("hints", hints.toString());

    aResponse.setHeader("Content-Type", "image/png", false);
    aResponse.write(IMAGE);
  }
}