dom/tests/mochitest/localstorage/frameReplace.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/localstorage/frameReplace.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.5 +<head>
     1.6 +<title>localStorage replace frame</title>
     1.7 +
     1.8 +<script type="text/javascript">
     1.9 +
    1.10 +var shell;
    1.11 +
    1.12 +function ok(a, message)
    1.13 +{
    1.14 +  if (!a)
    1.15 +    shell.postMessage("FAILURE: " + message, "http://mochi.test:8888");
    1.16 +  else
    1.17 +    shell.postMessage(message, "http://mochi.test:8888");
    1.18 +}
    1.19 +
    1.20 +function is(a, b, message)
    1.21 +{
    1.22 +  if (a != b)
    1.23 +    shell.postMessage("FAILURE: " + message + ", expected "+b+" got "+a, "http://mochi.test:8888");
    1.24 +  else
    1.25 +    shell.postMessage(message + ", expected "+b+" got "+a, "http://mochi.test:8888");
    1.26 +}
    1.27 +
    1.28 +function doTest()
    1.29 +{
    1.30 +  var query = location.search.substring(1);
    1.31 +  var queries = query.split("&");
    1.32 +
    1.33 +  var action = queries[0];
    1.34 +  shell = queries[1];
    1.35 +  switch (shell)
    1.36 +  {
    1.37 +    case "frame":
    1.38 +      shell = parent;
    1.39 +      break;
    1.40 +    case "window":
    1.41 +      shell = opener;
    1.42 +      break;
    1.43 +  }
    1.44 +
    1.45 +  switch (action)
    1.46 +  {
    1.47 +    case "init":
    1.48 +      localStorage.setItem("A", "1");
    1.49 +      localStorage.setItem("B", "2");
    1.50 +      localStorage.setItem("C", "3");
    1.51 +      is(localStorage.getItem("A"), "1", "'A' is '1'");
    1.52 +      is(localStorage.getItem("B"), "2", "'A' is '2'");
    1.53 +      is(localStorage.getItem("C"), "3", "'A' is '3'");
    1.54 +      break;
    1.55 +
    1.56 +    case "check":
    1.57 +      is(localStorage.getItem("A"), null, "'A' is null");
    1.58 +      is(localStorage.getItem("B"), null, "'A' is null");
    1.59 +      is(localStorage.getItem("C"), null, "'A' is null");
    1.60 +      break;
    1.61 +
    1.62 +    case "clean":
    1.63 +      localStorage.clear();
    1.64 +      break;
    1.65 +  }
    1.66 +
    1.67 +  shell.postMessage(action + "_done", "http://mochi.test:8888");
    1.68 +}
    1.69 +
    1.70 +</script>
    1.71 +
    1.72 +</head>
    1.73 +<body onload="doTest();">
    1.74 +</body>
    1.75 +</html>

mercurial