dom/tests/mochitest/sessionstorage/test_sessionStorageClone.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/sessionstorage/test_sessionStorageClone.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,94 @@
     1.4 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.5 +<head>
     1.6 +<title>sessionStorage clone equal origins</title>
     1.7 +
     1.8 +<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +<script type="text/javascript" src="interOriginTest.js"></script>
    1.10 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.11 +
    1.12 +<script type="text/javascript">
    1.13 +
    1.14 +var currentTest = 1;
    1.15 +var currentStep = 1;
    1.16 +
    1.17 +/*
    1.18 +window.addEventListener("storage", onStorageEvent, false);
    1.19 +
    1.20 +function onStorageEvent(event)
    1.21 +{
    1.22 +}
    1.23 +*/
    1.24 +
    1.25 +function doNextTest()
    1.26 +{
    1.27 +  // We must perform the first step of the test
    1.28 +  // to prepare the land.
    1.29 +  currentStep = 1;
    1.30 +  doStep();
    1.31 +
    1.32 +  switch (currentTest)
    1.33 +  {
    1.34 +    case 1:
    1.35 +      // Open a window from the same origin and check data
    1.36 +      // are copied but not further modified on our side
    1.37 +      slaveOrigin = "http://mochi.test:8888";
    1.38 +      slave = window.open(slaveOrigin + slavePath + "frameEqual.html");
    1.39 +      break;
    1.40 +
    1.41 +    case 2:
    1.42 +      slave.close();
    1.43 +      // Open a window from a different origin and check data
    1.44 +      // are NOT copied and not modified on our side
    1.45 +      slaveOrigin = "http://example.com";
    1.46 +      slave = window.open(slaveOrigin + slavePath + "frameNotEqual.html");
    1.47 +      break;
    1.48 +
    1.49 +    case 3:
    1.50 +      slave.close();
    1.51 +      sessionStorage.clear();
    1.52 +      SimpleTest.finish();
    1.53 +      break;
    1.54 +  }
    1.55 +
    1.56 +  ++currentTest;
    1.57 +}
    1.58 +
    1.59 +function doStep()
    1.60 +{
    1.61 +  switch (currentStep)
    1.62 +  {
    1.63 +    case 1:
    1.64 +      sessionStorage.setItem("A", "1");
    1.65 +      sessionStorage.setItem("B", "2");
    1.66 +      is(sessionStorage.getItem("A"), "1", "A is 1 in the master");
    1.67 +      is(sessionStorage.getItem("B"), "2", "B is 2 in the master");
    1.68 +      is(sessionStorage.length, 2, "Num of items is 2");
    1.69 +      break;
    1.70 +
    1.71 +    case 3:
    1.72 +      is(sessionStorage.getItem("A"), "1", "A is 1 in the master");
    1.73 +      is(sessionStorage.getItem("B"), "2", "B is 2 in the master");
    1.74 +      is(sessionStorage.getItem("C"), null, "C is null in the master");
    1.75 +      is(sessionStorage.length, 2, "Num of items is 2");
    1.76 +
    1.77 +      sessionStorage.setItem("C", "4");
    1.78 +      is(sessionStorage.getItem("C"), "4", "C is 4 in the master");
    1.79 +      is(sessionStorage.length, 3, "Num of items is 3");
    1.80 +      break;
    1.81 +  }
    1.82 +
    1.83 +  ++currentStep;
    1.84 +  ++currentStep;
    1.85 +
    1.86 +  return true;
    1.87 +}
    1.88 +
    1.89 +SimpleTest.waitForExplicitFinish();
    1.90 +
    1.91 +</script>
    1.92 +
    1.93 +</head>
    1.94 +
    1.95 +<body onload="doNextTest();">
    1.96 +</body>
    1.97 +</html>

mercurial