summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/referrer/file_referrer_policyserver.sjs
blob: 6695d417f4a92cdbc06a9d658013efd9dca4b2de (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
 * Renders a link with the provided referrer policy.
 * Used in browser_referrer_*.js, bug 1113431.
 * Arguments: ?scheme=http://&policy=origin&rel=noreferrer
 */
function handleRequest(request, response) {
  Cu.importGlobalProperties(["URLSearchParams"]);
  let query = new URLSearchParams(request.queryString);

  let scheme = query.get("scheme");
  let policy = query.get("policy");
  let rel = query.get("rel");
  let cross = query.get("cross");

  let host = cross ? "example.com" : "test1.example.com";
  let linkUrl =
    scheme +
    host +
    "/browser/browser/base/content/test/referrer/" +
    "file_referrer_testserver.sjs";
  let metaReferrerTag = policy
    ? `<meta name='referrer' content='${policy}'>`
    : "";

  let html = `<!DOCTYPE HTML>
              <html>
              <head>
              <meta charset='utf-8'>
              ${metaReferrerTag}
              <title>Test referrer</title>
              </head>
              <body>
              <a id='testlink' href='${linkUrl}' ${rel ? ` rel='${rel}'` : ""}>
              referrer test link</a>
              </body>
              </html>`;

  response.setHeader("Cache-Control", "no-cache", false);
  response.setHeader("Content-Type", "text/html", false);
  response.write(html);
}