Home | History | Annotate | Download | only in domstorage
      1 Test dom storage with many different types of keys (as opposed to values)
      2 
      3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
      4 
      5 
      6 Testing sessionStorage
      7 storage.clear()
      8 PASS storage.length is 0
      9 
     10 PASS storage.getItem('FOO') is null
     11 storage.setItem('FOO', 'BAR')
     12 PASS storage.length is 1
     13 PASS storage.getItem('FOO') is "BAR"
     14 PASS storage.getItem('foo') is null
     15 PASS storage.foo is undefined.
     16 PASS storage['foo'] is undefined.
     17 storage.foo = 'x'
     18 PASS storage.foo is "x"
     19 PASS storage['foo'] is "x"
     20 PASS storage.getItem('foo') is "x"
     21 storage['foo'] = 'y'
     22 PASS storage.foo is "y"
     23 PASS storage['foo'] is "y"
     24 PASS storage.getItem('foo') is "y"
     25 storage.setItem('foo', 'z')
     26 PASS storage.foo is "z"
     27 PASS storage['foo'] is "z"
     28 PASS storage.getItem('foo') is "z"
     29 PASS storage.length is 2
     30 
     31 Testing a null key
     32 storage.setItem(null, 'asdf')
     33 PASS storage.getItem('null') is "asdf"
     34 PASS storage.getItem(null) is "asdf"
     35 PASS storage['null'] is "asdf"
     36 PASS storage[null] is "asdf"
     37 PASS storage.length is 3
     38 storage[null] = 1
     39 PASS storage.getItem(null) is "1"
     40 storage['null'] = 2
     41 PASS storage.getItem(null) is "2"
     42 storage.setItem('null', 3)
     43 PASS storage.getItem(null) is "3"
     44 PASS storage.length is 3
     45 
     46 Testing an undefined key
     47 storage[undefined] = 'xyz'
     48 PASS storage.getItem('undefined') is "xyz"
     49 PASS storage.getItem(undefined) is "xyz"
     50 PASS storage['undefined'] is "xyz"
     51 PASS storage[undefined] is "xyz"
     52 PASS storage.length is 4
     53 storage['undefined'] = 4
     54 PASS storage.getItem(undefined) is "4"
     55 storage.setItem(undefined, 5)
     56 PASS storage.getItem(undefined) is "5"
     57 storage.setItem('undefined', 6)
     58 PASS storage.getItem(undefined) is "6"
     59 PASS storage.length is 4
     60 
     61 Testing a numeric key
     62 storage['2'] = 'ppp'
     63 PASS storage.getItem('2') is "ppp"
     64 PASS storage.getItem(2) is "ppp"
     65 PASS storage['2'] is "ppp"
     66 PASS storage[2] is "ppp"
     67 PASS storage.length is 5
     68 storage[2] = 7
     69 PASS storage.getItem(2) is "7"
     70 storage.setItem(2, 8)
     71 PASS storage.getItem(2) is "8"
     72 storage.setItem('2', 9)
     73 PASS storage.getItem(2) is "9"
     74 PASS storage.length is 5
     75 
     76 Setting a non-ascii string to foo
     77 storage[k] = 'hello'
     78 PASS storage.getItem(k) is "hello"
     79 PASS storage[k] is "hello"
     80 PASS storage.length is 6
     81 
     82 Testing case differences
     83 storage.foo1 = 'lower1'
     84 storage.FOO1 = 'UPPER1'
     85 storage['foo2'] = 'lower2'
     86 storage['FOO2'] = 'UPPER2'
     87 storage.setItem('foo3', 'lower3')
     88 storage.setItem('FOO3', 'UPPER3')
     89 PASS storage.foo1 is "lower1"
     90 PASS storage.FOO1 is "UPPER1"
     91 PASS storage['foo2'] is "lower2"
     92 PASS storage['FOO2'] is "UPPER2"
     93 PASS storage.getItem('foo3') is "lower3"
     94 PASS storage.getItem('FOO3') is "UPPER3"
     95 PASS storage.length is 12
     96 
     97 Testing overriding length
     98 PASS storage.length is 12
     99 PASS storage['length'] is 12
    100 PASS storage.getItem('length') is null
    101 storage.length = 0
    102 PASS storage.length is 12
    103 PASS storage['length'] is 12
    104 PASS storage.getItem('length') is null
    105 storage['length'] = 0
    106 PASS storage.length is 12
    107 PASS storage['length'] is 12
    108 PASS storage.getItem('length') is null
    109 storage.setItem('length', 0)
    110 PASS storage.length is 13
    111 PASS storage['length'] is 13
    112 PASS storage.getItem('length') is "0"
    113 storage.removeItem('length')
    114 PASS storage.length is 12
    115 PASS storage['length'] is 12
    116 PASS storage.getItem('length') is null
    117 storage.setItem('length', 0)
    118 PASS storage.length is 13
    119 
    120 
    121 Testing localStorage
    122 storage.clear()
    123 PASS storage.length is 0
    124 
    125 PASS storage.getItem('FOO') is null
    126 storage.setItem('FOO', 'BAR')
    127 PASS storage.length is 1
    128 PASS storage.getItem('FOO') is "BAR"
    129 PASS storage.getItem('foo') is null
    130 PASS storage.foo is undefined.
    131 PASS storage['foo'] is undefined.
    132 storage.foo = 'x'
    133 PASS storage.foo is "x"
    134 PASS storage['foo'] is "x"
    135 PASS storage.getItem('foo') is "x"
    136 storage['foo'] = 'y'
    137 PASS storage.foo is "y"
    138 PASS storage['foo'] is "y"
    139 PASS storage.getItem('foo') is "y"
    140 storage.setItem('foo', 'z')
    141 PASS storage.foo is "z"
    142 PASS storage['foo'] is "z"
    143 PASS storage.getItem('foo') is "z"
    144 PASS storage.length is 2
    145 
    146 Testing a null key
    147 storage.setItem(null, 'asdf')
    148 PASS storage.getItem('null') is "asdf"
    149 PASS storage.getItem(null) is "asdf"
    150 PASS storage['null'] is "asdf"
    151 PASS storage[null] is "asdf"
    152 PASS storage.length is 3
    153 storage[null] = 1
    154 PASS storage.getItem(null) is "1"
    155 storage['null'] = 2
    156 PASS storage.getItem(null) is "2"
    157 storage.setItem('null', 3)
    158 PASS storage.getItem(null) is "3"
    159 PASS storage.length is 3
    160 
    161 Testing an undefined key
    162 storage[undefined] = 'xyz'
    163 PASS storage.getItem('undefined') is "xyz"
    164 PASS storage.getItem(undefined) is "xyz"
    165 PASS storage['undefined'] is "xyz"
    166 PASS storage[undefined] is "xyz"
    167 PASS storage.length is 4
    168 storage['undefined'] = 4
    169 PASS storage.getItem(undefined) is "4"
    170 storage.setItem(undefined, 5)
    171 PASS storage.getItem(undefined) is "5"
    172 storage.setItem('undefined', 6)
    173 PASS storage.getItem(undefined) is "6"
    174 PASS storage.length is 4
    175 
    176 Testing a numeric key
    177 storage['2'] = 'ppp'
    178 PASS storage.getItem('2') is "ppp"
    179 PASS storage.getItem(2) is "ppp"
    180 PASS storage['2'] is "ppp"
    181 PASS storage[2] is "ppp"
    182 PASS storage.length is 5
    183 storage[2] = 7
    184 PASS storage.getItem(2) is "7"
    185 storage.setItem(2, 8)
    186 PASS storage.getItem(2) is "8"
    187 storage.setItem('2', 9)
    188 PASS storage.getItem(2) is "9"
    189 PASS storage.length is 5
    190 
    191 Setting a non-ascii string to foo
    192 storage[k] = 'hello'
    193 PASS storage.getItem(k) is "hello"
    194 PASS storage[k] is "hello"
    195 PASS storage.length is 6
    196 
    197 Testing case differences
    198 storage.foo1 = 'lower1'
    199 storage.FOO1 = 'UPPER1'
    200 storage['foo2'] = 'lower2'
    201 storage['FOO2'] = 'UPPER2'
    202 storage.setItem('foo3', 'lower3')
    203 storage.setItem('FOO3', 'UPPER3')
    204 PASS storage.foo1 is "lower1"
    205 PASS storage.FOO1 is "UPPER1"
    206 PASS storage['foo2'] is "lower2"
    207 PASS storage['FOO2'] is "UPPER2"
    208 PASS storage.getItem('foo3') is "lower3"
    209 PASS storage.getItem('FOO3') is "UPPER3"
    210 PASS storage.length is 12
    211 
    212 Testing overriding length
    213 PASS storage.length is 12
    214 PASS storage['length'] is 12
    215 PASS storage.getItem('length') is null
    216 storage.length = 0
    217 PASS storage.length is 12
    218 PASS storage['length'] is 12
    219 PASS storage.getItem('length') is null
    220 storage['length'] = 0
    221 PASS storage.length is 12
    222 PASS storage['length'] is 12
    223 PASS storage.getItem('length') is null
    224 storage.setItem('length', 0)
    225 PASS storage.length is 13
    226 PASS storage['length'] is 13
    227 PASS storage.getItem('length') is "0"
    228 storage.removeItem('length')
    229 PASS storage.length is 12
    230 PASS storage['length'] is 12
    231 PASS storage.getItem('length') is null
    232 storage.setItem('length', 0)
    233 PASS storage.length is 13
    234 PASS successfullyParsed is true
    235 
    236 TEST COMPLETE
    237 
    238