summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webstorage/storage_length.window.js
blob: 9648e48c8d881b40cfcc25dd7ba6ff845336d8ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
["localStorage", "sessionStorage"].forEach(function(name) {
    test(function() {
        var storage = window[name];
        storage.clear();
        assert_equals(storage.length, 0, "storage.length")

        storage["name"] = "user1";
        storage["age"] = "20";

        assert_equals(storage.length, 2, "storage.length")
    }, name + ".length (method access)");

    test(function() {
        var storage = window[name];
        storage.clear();
        assert_equals(storage.length, 0, "storage.length")

        storage.setItem("name", "user1");
        storage.setItem("age", "20");

        assert_equals(storage.length, 2, "storage.length")
    }, name + ".length (proprty access)");
});