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

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

function log(a)
{
    document.getElementById('logger').appendChild(document.createTextNode(a));
    document.getElementById('logger').appendChild(document.createElement("br"));
}

function runTest()
{
    if (!window.localStorage) {
        log("window.localStorage DOES NOT exist");
        return;
    }
    
    log("foo (before anything) is: " + localStorage.foo);
    localStorage.foo = "bar";
    log("foo (after a named property settter set) is: " + localStorage.foo);
    delete localStorage.foo;
    log("foo (after a delete) is: " + localStorage.foo);
    localStorage["foo"] = "bar";
    log("foo (after an indexed setter set) is: " + localStorage.foo);
    delete localStorage.FOO;
    log("foo (after deleting FOO (not foo)) is: " + localStorage.foo);
    delete localStorage.foo;
    log("foo (after a delete) is: " + localStorage.foo);
    localStorage.setItem("foo", "bar");
    log("foo (after calling setItem) is: " + localStorage.foo);
    delete localStorage.foo;
    log("foo (after a delete) is: " + localStorage.foo);
    delete localStorage.foo;
    log("foo (after a redundant delete) is: " + localStorage.foo);
    localStorage.foo = "bar";
    log("foo (after an implicit settter set) is: " + localStorage.foo);
    delete localStorage["foo"];
    log("foo (after an indexed delete) is: " + localStorage.foo);
}

</script>
</head>
<body onload="runTest();">
This test makes sure that using the syntax `delete localStorage.keyName` works as an alias to `localStorage.removeItem(keyName).`<br><hr>
<div id="logger"></div>
</body>
</html>