summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/sessionstorage/test_sessionStorageHttpHttps.html
blob: e145ee16ba870dd5652183e67ef7e8b144eb555b (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
56
57
58
59
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>sessionStorage replace test</title>

<!--
  This test checks that sessionStorage values set in an https page
  are not readable from a non-https page from the same domain.
-->

<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />

<script type="text/javascript">

window.addEventListener("message", onMessageReceived, false);

var messages = [];

function onMessageReceived(event)
{
  if (event.data == "the end") {
    is(messages.length, 4, "Wrong number of messages.");
    is(messages[0], "insecure", "Wrong message from insecure page");
    is(messages[1], "secure", "Wrong message from secure page");
    is(messages[2], "insecure", "Wrong second message from insecure page");
    is(messages[3], null, "Insecure page got secure message?");

    SimpleTest.finish();

    return;
  }

  messages.push(event.data);

  if (event.data == "insecure" && messages.length == 1) {
    window.httpsframe.location = "https://test1.example.com/tests/dom/tests/mochitest/sessionstorage/file_https.html";
  }

  if (event.data == "secure") {
    window.httpframe.postMessage("check", "http://test1.example.com");
  }
}

function startTest()
{
  window.httpframe.location = "http://test1.example.com/tests/dom/tests/mochitest/sessionstorage/file_http.html";
}

SimpleTest.waitForExplicitFinish();

</script>

</head>

<body onload="startTest();">
  <iframe src="" name="httpframe"></iframe>
  <iframe src="" name="httpsframe"></iframe>
</body>
</html>