summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webstorage/storage_indexing.window.js
blob: 685b6b67fb9fd112747af779abdd49623bf627b1 (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
["localStorage", "sessionStorage"].forEach(function(name) {
    test(function() {
        var storage = window[name];
        storage.clear();
        storage["name"] = "user1";
        storage["age"] = "42";

        test(function() {
            assert_equals(storage[-1], undefined);
            assert_equals(storage[0], undefined);
            assert_equals(storage[1], undefined);
            assert_equals(storage[2], undefined);
        }, "Getting number properties on " + name);

        test(function() {
            assert_equals(storage["-1"], undefined);
            assert_equals(storage["0"], undefined);
            assert_equals(storage["1"], undefined);
            assert_equals(storage["2"], undefined);
        }, "Getting number-valued string properties on " + name);

        test(function() {
            storage.setItem(1, "number");
            assert_equals(storage[1], "number");
            assert_equals(storage["1"], "number");
        }, "Getting existing number-valued properties on " + name);
    }, "Indexed getter on " + name);
});