summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage/domstorage/sessionstorage/string-conversion.html
blob: 64a4e14eed0e392882ed2c037cbca92b6cbd2e01 (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
47
48
49
50
51
52
53
54
<html>
<head>
<script src="resources/clearSessionStorage.js"></script>
<script>

if (window.layoutTestController)
    layoutTestController.dumpAsText();

function log(a)
{
    document.getElementById("logger").innerHTML += a + "<br>";
}

function runTest()
{
    if (!window.sessionStorage) {
        log("window.sessionStorage DOES NOT exist");
        return;
    }

    log("Length is " + sessionStorage.length);

    log("Testing implicit setters");
    sessionStorage.a = null;
    log("Type/value for null is " + typeof sessionStorage.a + "/" + sessionStorage.a);
    sessionStorage.b = 0;
    log("Type/value for 0 is " + typeof sessionStorage.b + "/" + sessionStorage.b);
    sessionStorage.c = function(){};
    log("Type/value for function(){} is " + typeof sessionStorage.c + "/" + sessionStorage.c);

    log("Testing explicit setters");
    sessionStorage.setItem('d', null);
    log("Type/value for null is " + typeof sessionStorage.d + "/" + sessionStorage.d);
    sessionStorage.setItem('e', 0);
    log("Type/value for 0 is " + typeof sessionStorage.e + "/" + sessionStorage.e);
    sessionStorage.setItem('f', function(){});
    log("Type/value for function(){} is " + typeof sessionStorage.f + "/" + sessionStorage.f);

    log("Testing index setters");
    sessionStorage['g'] = null;
    log("Type/value for null is " + typeof sessionStorage.g + "/" + sessionStorage.g);
    sessionStorage['h'] = 0;
    log("Type/value for 0 is " + typeof sessionStorage.h + "/" + sessionStorage.h);
    sessionStorage['i'] = function(){};
    log("Type/value for function(){} is " + typeof sessionStorage.i + "/" + sessionStorage.i);
}

</script>
</head>
<body onload="runTest();">
This test case verifies that session storage only stores strings.
<div id="logger"></div>
</body>
</html>