dom/tests/mochitest/localstorage/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

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

mercurial