dom/tests/mochitest/sessionstorage/test_sessionStorageReplace.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/sessionstorage/test_sessionStorageReplace.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     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 object doesn't leak
    1.10 +  in a window that changes its location. We do this by switching
    1.11 +  frame location inside of this window and then by changing location
    1.12 +  of a top level window.
    1.13 +-->
    1.14 +
    1.15 +<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.16 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.17 +
    1.18 +<script type="text/javascript">
    1.19 +
    1.20 +var shell;
    1.21 +var shellType;
    1.22 +var failureRegExp = new RegExp("^FAILURE");
    1.23 +
    1.24 +window.addEventListener("message", onMessageReceived, false);
    1.25 +
    1.26 +function onMessageReceived(event)
    1.27 +{
    1.28 +  //alert("onMessageReceived "+event.data);
    1.29 +  switch (event.data)
    1.30 +  {
    1.31 +    case "init_done":
    1.32 +      // This is frame with different origin in the same browsing context
    1.33 +      // as the first frame adding data to sessionStorage of the first origin.
    1.34 +      shell.location = "http://example.com/tests/dom/tests/mochitest/sessionstorage/frameReplace.html?check&" + shellType;
    1.35 +      break;
    1.36 +
    1.37 +    case "check_done":
    1.38 +      // Recheck and clean the sessionStorage of the first origin.
    1.39 +      shell.location = "http://example.org:80/tests/dom/tests/mochitest/sessionstorage/frameReplace.html?clean&" + shellType;
    1.40 +      break;
    1.41 +
    1.42 +    case "clean_done":
    1.43 +      switch (shellType)
    1.44 +      {
    1.45 +        case "frame":
    1.46 +          // We finished testing in a frame
    1.47 +          // proceed with test in a separate window
    1.48 +          shellType = "window";
    1.49 +          shell = window.open("http://example.org/tests/dom/tests/mochitest/sessionstorage/frameReplace.html?init&" + shellType);
    1.50 +          break;
    1.51 +
    1.52 +        case "window":
    1.53 +          shell.close();
    1.54 +          window.setTimeout(function() {SimpleTest.finish();}, 0);
    1.55 +          break;
    1.56 +      }
    1.57 +      break;
    1.58 +
    1.59 +    default:
    1.60 +      SimpleTest.ok(!event.data.match(failureRegExp), event.data);
    1.61 +      break;
    1.62 +  }
    1.63 +}
    1.64 +
    1.65 +function startTest()
    1.66 +{
    1.67 +  shellType = "frame";
    1.68 +  shell = frame;
    1.69 +  shell.location = "http://example.org/tests/dom/tests/mochitest/sessionstorage/frameReplace.html?init&" + shellType;
    1.70 +}
    1.71 +
    1.72 +SimpleTest.waitForExplicitFinish();
    1.73 +
    1.74 +</script>
    1.75 +
    1.76 +</head>
    1.77 +
    1.78 +<body onload="startTest();">
    1.79 +  <iframe src="" name="frame"></iframe>
    1.80 +</body>
    1.81 +</html>

mercurial