dom/tests/mochitest/sessionstorage/test_sessionStorageHttpHttps.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/sessionstorage/test_sessionStorageHttpHttps.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     1.4 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.5 +<head>
     1.6 +<title>sessionStorage replace test</title>
     1.7 +
     1.8 +<!--
     1.9 +  This test checks that sessionStorage values set in an https page
    1.10 +  are not readable from a non-https page from the same domain.
    1.11 +-->
    1.12 +
    1.13 +<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.14 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.15 +
    1.16 +<script type="text/javascript">
    1.17 +
    1.18 +window.addEventListener("message", onMessageReceived, false);
    1.19 +
    1.20 +var messages = [];
    1.21 +
    1.22 +function onMessageReceived(event)
    1.23 +{
    1.24 +  if (event.data == "the end") {
    1.25 +    is(messages.length, 4, "Wrong number of messages.");
    1.26 +    is(messages[0], "insecure", "Wrong message from insecure page");
    1.27 +    is(messages[1], "secure", "Wrong message from secure page");
    1.28 +    is(messages[2], "insecure", "Wrong second message from insecure page");
    1.29 +    is(messages[3], null, "Insecure page got secure message?");
    1.30 +
    1.31 +    SimpleTest.finish();
    1.32 +
    1.33 +    return;
    1.34 +  }
    1.35 +
    1.36 +  messages.push(event.data);
    1.37 +
    1.38 +  if (event.data == "insecure" && messages.length == 1) {
    1.39 +    window.httpsframe.location = "https://test1.example.com/tests/dom/tests/mochitest/sessionstorage/file_https.html";
    1.40 +  }
    1.41 +
    1.42 +  if (event.data == "secure") {
    1.43 +    window.httpframe.postMessage("check", "http://test1.example.com");
    1.44 +  }
    1.45 +}
    1.46 +
    1.47 +function startTest()
    1.48 +{
    1.49 +  window.httpframe.location = "http://test1.example.com/tests/dom/tests/mochitest/sessionstorage/file_http.html";
    1.50 +}
    1.51 +
    1.52 +SimpleTest.waitForExplicitFinish();
    1.53 +
    1.54 +</script>
    1.55 +
    1.56 +</head>
    1.57 +
    1.58 +<body onload="startTest();">
    1.59 +  <iframe src="" name="httpframe"></iframe>
    1.60 +  <iframe src="" name="httpsframe"></iframe>
    1.61 +</body>
    1.62 +</html>

mercurial