summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/referrer_policy/referrer-policy-start.html
blob: 7cdc0502abc21c80ea05fa8f800858dee22cdcbe (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<head>
<script>
function run() {
  var kPolicy = 1;
  var kPort = 2;
  var kSslPort = 3;
  var kRedirect = 4;
  var kLink = 5;
  var kTarget = 6;
  var re = new RegExp("policy=(.*)&port=(.*)&ssl_port=(.*)&redirect=(.*)&" +
                      "link=(.*)&target=(.*)");
  var matches = re.exec(document.location.search);

  if (matches == null) {
    document.body.innerText = "Could not parse parameters!";
    return;
  }

  var meta = document.createElement("meta");
  meta.name = "referrer";
  meta.content = matches[kPolicy];
  document.head.appendChild(meta);

  var destination;

  if (matches[kRedirect] == "false") {
    destination = "http://127.0.0.1:" + matches[kPort] +
        "/files/referrer-policy-log.html";
  } else if (matches[kRedirect] == "http") {
    destination = "http://127.0.0.1:" + matches[kPort] +
      "/server-redirect?http://127.0.0.1:" + matches[kPort] +
      "/files/referrer-policy-log.html";
  } else {
    destination = "https://127.0.0.1:" + matches[kSslPort] +
      "/server-redirect?http://127.0.0.1:" + matches[kPort] +
      "/files/referrer-policy-log.html";
  }

  if (matches[kLink] == "true") {
    var link = document.createElement("a");
    link.innerText = "link";
    link.target = matches[kTarget];
    link.href = destination;
    document.body.appendChild(link);
  } else {
    document.location = destination;
  }
}
</script>
</head>
<body onload="run()">
</body>
</html>