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

function handleRequest(request, response) {
  if (request.queryString == "reset") {
    setState("cache_cookie", "0");
    response.setStatusLine(request.httpVersion, 200, "Ok");
    response.write("Reset");
    return;
  }

  let state = getState("cache_cookie");
  if (!state) {
    state = 0;
  }

  response.setStatusLine(request.httpVersion, 302, "Moved Temporarily");
  response.setHeader("Set-Cookie", `faviconCookie=${++state}`);
  response.setHeader(
    "Location",
    // eslint-disable-next-line @microsoft/sdl/no-insecure-url
    "http://example.com/browser/browser/base/content/test/favicons/moz.png"
  );
  setState("cache_cookie", `${state}`);
}