blob: 4ff0d294c4a4462f6a38cd07bf3720f21965afe2 [file] [log] [blame]
Test dom storage with many different types of keys (as opposed to values)
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Testing sessionStorage
storage.clear()
PASS storage.length is 0
PASS storage.getItem('FOO') is null
storage.setItem('FOO', 'BAR')
PASS storage.length is 1
PASS storage.getItem('FOO') is "BAR"
PASS storage.getItem('foo') is null
PASS storage.foo is undefined.
PASS storage['foo'] is undefined.
storage.foo = 'x'
PASS storage.foo is "x"
PASS storage['foo'] is "x"
PASS storage.getItem('foo') is "x"
storage['foo'] = 'y'
PASS storage.foo is "y"
PASS storage['foo'] is "y"
PASS storage.getItem('foo') is "y"
storage.setItem('foo', 'z')
PASS storage.foo is "z"
PASS storage['foo'] is "z"
PASS storage.getItem('foo') is "z"
PASS storage.length is 2
Testing a null key
storage.setItem(null, 'asdf')
PASS storage.getItem('null') is "asdf"
PASS storage.getItem(null) is "asdf"
PASS storage['null'] is "asdf"
PASS storage[null] is "asdf"
PASS storage.length is 3
storage[null] = 1
PASS storage.getItem(null) is "1"
storage['null'] = 2
PASS storage.getItem(null) is "2"
storage.setItem('null', 3)
PASS storage.getItem(null) is "3"
PASS storage.length is 3
Testing an undefined key
storage[undefined] = 'xyz'
PASS storage.getItem('undefined') is "xyz"
PASS storage.getItem(undefined) is "xyz"
PASS storage['undefined'] is "xyz"
PASS storage[undefined] is "xyz"
PASS storage.length is 4
storage['undefined'] = 4
PASS storage.getItem(undefined) is "4"
storage.setItem(undefined, 5)
PASS storage.getItem(undefined) is "5"
storage.setItem('undefined', 6)
PASS storage.getItem(undefined) is "6"
PASS storage.length is 4
Testing a numeric key
storage['2'] = 'ppp'
PASS storage.getItem('2') is "ppp"
PASS storage.getItem(2) is "ppp"
PASS storage['2'] is "ppp"
PASS storage[2] is "ppp"
PASS storage.length is 5
storage[2] = 7
PASS storage.getItem(2) is "7"
storage.setItem(2, 8)
PASS storage.getItem(2) is "8"
storage.setItem('2', 9)
PASS storage.getItem(2) is "9"
PASS storage.length is 5
Setting a non-ascii string to foo
storage[k] = 'hello'
PASS storage.getItem(k) is "hello"
PASS storage[k] is "hello"
PASS storage.length is 6
Testing case differences
storage.foo1 = 'lower1'
storage.FOO1 = 'UPPER1'
storage['foo2'] = 'lower2'
storage['FOO2'] = 'UPPER2'
storage.setItem('foo3', 'lower3')
storage.setItem('FOO3', 'UPPER3')
PASS storage.foo1 is "lower1"
PASS storage.FOO1 is "UPPER1"
PASS storage['foo2'] is "lower2"
PASS storage['FOO2'] is "UPPER2"
PASS storage.getItem('foo3') is "lower3"
PASS storage.getItem('FOO3') is "UPPER3"
PASS storage.length is 12
Testing overriding length
PASS storage.length is 12
PASS storage['length'] is 12
PASS storage.getItem('length') is null
storage.length = 0
PASS storage.length is 12
PASS storage['length'] is 12
PASS storage.getItem('length') is null
storage['length'] = 0
PASS storage.length is 12
PASS storage['length'] is 12
PASS storage.getItem('length') is null
storage.setItem('length', 0)
PASS storage.length is 13
PASS storage['length'] is 13
PASS storage.getItem('length') is "0"
storage.removeItem('length')
PASS storage.length is 12
PASS storage['length'] is 12
PASS storage.getItem('length') is null
storage.setItem('length', 0)
PASS storage.length is 13
Testing localStorage
storage.clear()
PASS storage.length is 0
PASS storage.getItem('FOO') is null
storage.setItem('FOO', 'BAR')
PASS storage.length is 1
PASS storage.getItem('FOO') is "BAR"
PASS storage.getItem('foo') is null
PASS storage.foo is undefined.
PASS storage['foo'] is undefined.
storage.foo = 'x'
PASS storage.foo is "x"
PASS storage['foo'] is "x"
PASS storage.getItem('foo') is "x"
storage['foo'] = 'y'
PASS storage.foo is "y"
PASS storage['foo'] is "y"
PASS storage.getItem('foo') is "y"
storage.setItem('foo', 'z')
PASS storage.foo is "z"
PASS storage['foo'] is "z"
PASS storage.getItem('foo') is "z"
PASS storage.length is 2
Testing a null key
storage.setItem(null, 'asdf')
PASS storage.getItem('null') is "asdf"
PASS storage.getItem(null) is "asdf"
PASS storage['null'] is "asdf"
PASS storage[null] is "asdf"
PASS storage.length is 3
storage[null] = 1
PASS storage.getItem(null) is "1"
storage['null'] = 2
PASS storage.getItem(null) is "2"
storage.setItem('null', 3)
PASS storage.getItem(null) is "3"
PASS storage.length is 3
Testing an undefined key
storage[undefined] = 'xyz'
PASS storage.getItem('undefined') is "xyz"
PASS storage.getItem(undefined) is "xyz"
PASS storage['undefined'] is "xyz"
PASS storage[undefined] is "xyz"
PASS storage.length is 4
storage['undefined'] = 4
PASS storage.getItem(undefined) is "4"
storage.setItem(undefined, 5)
PASS storage.getItem(undefined) is "5"
storage.setItem('undefined', 6)
PASS storage.getItem(undefined) is "6"
PASS storage.length is 4
Testing a numeric key
storage['2'] = 'ppp'
PASS storage.getItem('2') is "ppp"
PASS storage.getItem(2) is "ppp"
PASS storage['2'] is "ppp"
PASS storage[2] is "ppp"
PASS storage.length is 5
storage[2] = 7
PASS storage.getItem(2) is "7"
storage.setItem(2, 8)
PASS storage.getItem(2) is "8"
storage.setItem('2', 9)
PASS storage.getItem(2) is "9"
PASS storage.length is 5
Setting a non-ascii string to foo
storage[k] = 'hello'
PASS storage.getItem(k) is "hello"
PASS storage[k] is "hello"
PASS storage.length is 6
Testing case differences
storage.foo1 = 'lower1'
storage.FOO1 = 'UPPER1'
storage['foo2'] = 'lower2'
storage['FOO2'] = 'UPPER2'
storage.setItem('foo3', 'lower3')
storage.setItem('FOO3', 'UPPER3')
PASS storage.foo1 is "lower1"
PASS storage.FOO1 is "UPPER1"
PASS storage['foo2'] is "lower2"
PASS storage['FOO2'] is "UPPER2"
PASS storage.getItem('foo3') is "lower3"
PASS storage.getItem('FOO3') is "UPPER3"
PASS storage.length is 12
Testing overriding length
PASS storage.length is 12
PASS storage['length'] is 12
PASS storage.getItem('length') is null
storage.length = 0
PASS storage.length is 12
PASS storage['length'] is 12
PASS storage.getItem('length') is null
storage['length'] = 0
PASS storage.length is 12
PASS storage['length'] is 12
PASS storage.getItem('length') is null
storage.setItem('length', 0)
PASS storage.length is 13
PASS storage['length'] is 13
PASS storage.getItem('length') is "0"
storage.removeItem('length')
PASS storage.length is 12
PASS storage['length'] is 12
PASS storage.getItem('length') is null
storage.setItem('length', 0)
PASS storage.length is 13
PASS successfullyParsed is true
TEST COMPLETE