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

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

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

function startTest()
{
    if (!window.localStorage) {
        log("window.localStorage DOES NOT exist");
        return;
    }

    Storage.prototype.prototypeTestKey = "prototypeTestValue";
    localStorage.foo = "bar";
    localStorage.fu = "baz";
    localStorage.batman = "bin suparman";
    localStorage.bar = "foo";
    localStorage.alpha = "beta";
    localStorage.zeta = "gamma";
    
    // Enumerate localStorage, appending each key onto an array
    var enumeratedArray = new Array();
    for (var n in localStorage)
        enumeratedArray.push(n);

    // Sort the array, since the storage order isn't guaranteed
    enumeratedArray.sort();
    
    for (var n in enumeratedArray)
        log(enumeratedArray[n]);
}

</script>
</head>
<body onload="startTest();">
This test checks to see that you can enumerate a Storage object and get only the keys as a result.  The built-in properties of the Storage object should be ignored.  The test operates on the localStorage object.<br>
<div id="logger"></div>
</body>
</html>