summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webstorage/storage_clear.html
blob: 1d81f53917437ef0fc9acd5dff77e6866c2144f8 (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
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>WebStorage Test: Storage - clear()</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();

        storage.setItem("name", "user1");
        assert_equals(storage.getItem("name"), "user1");
        assert_equals(storage.name, "user1");
        assert_equals(storage.length, 1);

        storage.clear();
        assert_equals(storage.getItem("name"), null, "storage.getItem('name')");
        assert_equals(storage.name, undefined, "storage.name");
        assert_equals(storage.length, 0, "storage.length");
    }, "Clear in " + name);
});
</script>