summaryrefslogtreecommitdiffstats
path: root/dom/security/test/mixedcontentblocker/test_redirect.html
blob: 3fdd4e2e7b15e1b1f89a517c5522dfce2f35174e (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
<!DOCTYPE HTML>
<html>
<head>
  <title>Bug1402363: Test mixed content redirects</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>

<body onload='startTest()'>
<iframe style="width:100%;height:300px;" id="testframe"></iframe>

<script class="testbody" type="text/javascript">

SimpleTest.waitForExplicitFinish();

const PATH = "https://example.com/tests/dom/security/test/mixedcontentblocker/";
let testcounter = 0;

window.addEventListener("message", receiveMessage);
function receiveMessage(event) {
  if (event.data === "https-to-https-loaded") {
    ok(true, "https to https fetch redirect should be allowed");
  }
  else if (event.data === "https-to-http-blocked") {
    ok(true, "https to http fetch redirect should be blocked");
  }
  else {
    ok(false, "sanity: we should never enter that branch (" + event.data + ")");
  }
  testcounter++;
  if (testcounter < 2) {
    return;
  }
  window.removeEventListener("message", receiveMessage);
  SimpleTest.finish();
}

function startTest() {
  let testframe = document.getElementById("testframe");
  testframe.src = PATH + "file_redirect.html";
}

</script>
</body>
</html>