summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webstorage/storage_string_conversion.html
blob: c76eddfec3e62414ba6a1bce4921b62e266ff416 (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
<!DOCTYPE HTML>
<html>
<head>
<title>WebStorage Test: Storage only store strings</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script>
["localStorage", "sessionStorage"].forEach(function(name) {
    test(function() {
        assert_true(name in window, name + " exist");

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

        assert_equals(storage.length, 0);

        storage.a = null;
        assert_equals(storage.a, "null");
        storage.b = 0;
        assert_equals(storage.b, "0");
        storage.c = function(){};
        assert_equals(storage.c, "function(){}");

        storage.setItem('d', null);
        assert_equals(storage.d, "null");
        storage.setItem('e', 0);
        assert_equals(storage.e, "0");
        storage.setItem('f', function(){});
        assert_equals(storage.f, "function(){}");

        storage['g'] = null;
        assert_equals(storage.g, "null");
        storage['h'] = 0;
        assert_equals(storage.h, "0");
        storage['i'] = function(){};
        assert_equals(storage.f, "function(){}");

    }, name + " only stores strings");
});

</script>
</body>
</html>