summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage/domstorage/localstorage/simple-usage.html
blob: 37592d0e201527aecb9ad87f0488854f600ec123 (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
<html>
<head>
<script src="resources/clearLocalStorage.js"></script>
<script>

if (window.layoutTestController)
    layoutTestController.dumpAsText();

function log(a)
{
    document.getElementById("logger").innerHTML += a + "<br>";
}

function runTest()
{
    if (!window.localStorage) {
        log("window.localStorage DOES NOT exist");
        return;
    }
    
    log("Length is " + localStorage.length);
    log("Value for FOO is " + localStorage.getItem("FOO"));

    localStorage.setItem("FOO", "BAR");
    
    log("Length is " + localStorage.length);
    log("Value for FOO is " + localStorage.getItem("FOO"));
    log("Key for index 0 is " + localStorage.key(0));
    log("Key for index 1 is " + localStorage.key(1));
    log("Key for index -1 is " + localStorage.key(-1));
    
    localStorage.setItem("FOO", "BAZ");
    
    log("Length is " + localStorage.length);
    log("Value for FOO is " + localStorage.getItem("FOO"));
    
    localStorage.removeItem("FOO");
    
    log("Length is " + localStorage.length);
    log("Value for FOO is " + localStorage.getItem("FOO"));
}

</script>
</head>
<body onload="runTest();">
This test tries simple operations on localStorage<br>
<div id="logger"></div>
</body>
</html>