dom/tests/mochitest/localstorage/test_localStorageReplace.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/localstorage/test_localStorageReplace.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     1.4 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.5 +<head>
     1.6 +<title>localStorage replace test</title>
     1.7 +
     1.8 +<!--
     1.9 +  This test checks that localStorage 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 +  switch (event.data)
    1.29 +  {
    1.30 +    case "init_done":
    1.31 +      // This is frame with different origin in the same browsing context
    1.32 +      // as the first frame adding data to localStorage of the first origin.
    1.33 +      shell.location = "http://example.com:80/tests/dom/tests/mochitest/localstorage/frameReplace.html?check&" + shellType;
    1.34 +      break;
    1.35 +
    1.36 +    case "check_done":
    1.37 +      // Clean the localStorage of the first origin.
    1.38 +      shell.location = "http://example.org:80/tests/dom/tests/mochitest/localstorage/frameReplace.html?clean&" + shellType;
    1.39 +      break;
    1.40 +
    1.41 +    case "clean_done":
    1.42 +      switch (shellType)
    1.43 +      {
    1.44 +        case "frame":
    1.45 +          // We finished testing in a frame
    1.46 +          // proceed with test in a separate window
    1.47 +          shellType = "window";
    1.48 +          shell = window.open("http://example.org:80/tests/dom/tests/mochitest/localstorage/frameReplace.html?init&" + shellType);
    1.49 +          break;
    1.50 +
    1.51 +        case "window":
    1.52 +          shell.close();
    1.53 +          window.setTimeout(function() {SimpleTest.finish();}, 0);
    1.54 +          break;
    1.55 +      }
    1.56 +      break;
    1.57 +
    1.58 +    default:
    1.59 +      SimpleTest.ok(!event.data.match(failureRegExp), event.data);
    1.60 +      break;
    1.61 +  }
    1.62 +}
    1.63 +
    1.64 +function startTest() {
    1.65 +  SpecialPowers.pushPrefEnv({"set": [["security.mixed_content.block_display_content", false], ["security.mixed_content.block_active_content", false]]}, test1);
    1.66 +}
    1.67 +
    1.68 +function test1() {
    1.69 +  shellType = "frame";
    1.70 +  shell = frame;
    1.71 +  shell.location = "http://example.org:80/tests/dom/tests/mochitest/localstorage/frameReplace.html?init&" + shellType;
    1.72 +}
    1.73 +
    1.74 +SimpleTest.waitForExplicitFinish();
    1.75 +
    1.76 +</script>
    1.77 +
    1.78 +</head>
    1.79 +
    1.80 +<body onload="startTest();">
    1.81 +  <iframe src="" name="frame"></iframe>
    1.82 +</body>
    1.83 +</html>

mercurial