summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webstorage/storage_in.html
blob: 8b336047c8a04986e8db91022b1f23c910edf23e (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
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>WebStorage Test: Storage - in operator</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
["localStorage", "sessionStorage"].forEach(function(name) {
    test(function() {
        var storage = window[name];
        storage.clear();

        assert_false("name" in storage);
        storage["name"] = "user1";
        assert_true("name" in storage);
    }, "The in operator in " + name + ": property access");

    test(function() {
        var storage = window[name];
        storage.clear();

        assert_false("name" in storage);
        storage.setItem("name", "user1");
        assert_true("name" in storage);
        assert_equals(storage.name, "user1");
        storage.removeItem("name");
        assert_false("name" in storage);
    }, "The in operator in " + name + ": method access");
});
</script>