blob: 1026f51a41a0e1994b1a5f09b958062e587feb7b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<html>
<head>
<script src="resources/clearLocalStorage.js"></script>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
function log(a)
{
document.getElementById("logger").innerHTML += a + "<br>";
}
function finish()
{
if (window.layoutTestController)
layoutTestController.notifyDone()
}
function runTest()
{
if (!window.localStorage) {
log("window.localStorage DOES NOT exist");
finish();
return;
}
log("Setting FOO using the index setter.");
localStorage["FOO"] = "BAR";
log("Reading FOO:");
log(localStorage.FOO);
log(localStorage["FOO"]);
log(localStorage.getItem("FOO"));
log("");
log("Setting FOO again, using setItem.");
localStorage.setItem("FOO", "BAZ");
log("Reading FOO:");
log(localStorage.FOO);
log(localStorage["FOO"]);
log(localStorage.getItem("FOO"));
log("");
log("Setting FOO again, using the index setter.");
localStorage["FOO"] = "BAT";
log("Reading FOO:");
log(localStorage.FOO);
log(localStorage["FOO"]);
log(localStorage.getItem("FOO"));
log("");
log("Setting FOO again, using property-slot syntax");
localStorage.FOO = "BATMAN";
log("Reading FOO:");
log(localStorage.FOO);
log(localStorage["FOO"]);
log(localStorage.getItem("FOO"));
log("");
log("Removing FOO, then trying to read it");
localStorage.removeItem("FOO");
log("Reading FOO:");
log(localStorage.FOO);
log(localStorage["FOO"]);
log(localStorage.getItem("FOO"));
log("");
finish();
}
</script>
</head>
<body onload="runTest();">
This is a test to make sure you can get and set values in localStorage by index.<br>
<div id="logger"></div>
</body>
</html>
|