dom/tests/mochitest/sessionstorage/frameReplace.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <html xmlns="http://www.w3.org/1999/xhtml">
     2 <head>
     3 <title>sessionStorage replace frame</title>
     5 <script type="text/javascript">
     7 var shell;
     9 function ok(a, message)
    10 {
    11   if (!a)
    12     shell.postMessage("FAILURE: " + message, "http://mochi.test:8888");
    13   else
    14     shell.postMessage(message, "http://mochi.test:8888");
    15 }
    17 function is(a, b, message)
    18 {
    19   if (a != b)
    20     shell.postMessage("FAILURE: " + message + ", expected "+b+" got "+a, "http://mochi.test:8888");
    21   else
    22     shell.postMessage(message + ", expected "+b+" got "+a, "http://mochi.test:8888");
    23 }
    25 function doTest()
    26 {
    27   var query = location.search.substring(1);
    28   var queries = query.split("&");
    30   var action = queries[0];
    31   shell = queries[1];
    32   switch (shell)
    33   {
    34     case "frame":
    35       shell = parent;
    36       break;
    37     case "window":
    38       shell = opener;
    39       break;
    40   }
    42   switch (action)
    43   {
    44     case "init":
    45       sessionStorage.setItem("A", "1");
    46       sessionStorage.setItem("B", "2");
    47       sessionStorage.setItem("C", "3");
    48       is(sessionStorage.getItem("A"), "1", "'A' is '1'");
    49       is(sessionStorage.getItem("B"), "2", "'A' is '2'");
    50       is(sessionStorage.getItem("C"), "3", "'A' is '3'");
    51       break;
    53     case "check":
    54       is(sessionStorage.getItem("A"), null, "'A' is null");
    55       is(sessionStorage.getItem("B"), null, "'A' is null");
    56       is(sessionStorage.getItem("C"), null, "'A' is null");
    57       break;
    59     case "clean":
    60       is(sessionStorage.getItem("A"), "1", "'A' is '1'");
    61       is(sessionStorage.getItem("B"), "2", "'A' is '2'");
    62       is(sessionStorage.getItem("C"), "3", "'A' is '3'");
    63       sessionStorage.clear();
    64       break;
    65   }
    67   shell.postMessage(action + "_done", "http://mochi.test:8888");
    68 }
    70 </script>
    72 </head>
    73 <body onload="doTest();">
    74 </body>
    75 </html>

mercurial