1 description("Test some corner case DOM Storage values.");
3 function testKeyValue(key, value)
5 keyString = "storage['" + key + "']";
6 shouldBeEqualToString("typeof " + keyString, "string");
7 shouldBeEqualToString(keyString, value);
9 keyString = "storage." + key;
10 shouldBeEqualToString("typeof " + keyString, "string");
11 shouldBeEqualToString(keyString, value);
13 keyString = "storage.getItem('" + key + "')";
14 shouldBeEqualToString("typeof " + keyString, "string");
15 shouldBeEqualToString(keyString, value);
18 function test(storageString)
20 storage = eval(storageString);
22 testFailed(storageString + " DOES NOT exist");
26 debug("Testing " + storageString);
28 evalAndLog("storage.clear()");
29 shouldBe("storage.length", "0");
32 shouldBeEqualToString("typeof storage['foo']", "undefined");
33 shouldBeUndefined("storage['foo']");
34 shouldBeEqualToString("typeof storage.foo", "undefined");
35 shouldBeUndefined("storage.foo");
36 shouldBeEqualToString("typeof storage.getItem('foo')", "object");
37 shouldBeNull("storage.getItem('foo')");
40 evalAndLog("storage.foo1 = null");
41 testKeyValue("foo1", "null");
42 evalAndLog("storage['foo2'] = null");
43 testKeyValue("foo2", "null");
44 evalAndLog("storage.setItem('foo3', null)");
45 testKeyValue("foo3", "null");
48 evalAndLog("storage.foo4 = undefined");
49 testKeyValue("foo4", "undefined");
50 evalAndLog("storage['foo5'] = undefined");
51 testKeyValue("foo5", "undefined");
52 evalAndLog("storage.setItem('foo6', undefined)");
53 testKeyValue("foo6", "undefined");
56 evalAndLog("storage.foo7 = 2");
57 testKeyValue("foo7", "2");
58 evalAndLog("storage['foo8'] = 2");
59 testKeyValue("foo8", "2");
60 evalAndLog("storage.setItem('foo9', 2)");
61 testKeyValue("foo9", "2");
64 k = String.fromCharCode(255425) + String.fromCharCode(255) + String.fromCharCode(2554252321) + String.fromCharCode(0) + 'hello';
65 evalAndLog("storage.foo10 = k");
66 testKeyValue("foo10", k);
67 evalAndLog("storage['foo11'] = k");
68 testKeyValue("foo11", k);
69 evalAndLog("storage.setItem('foo12', k)");
70 testKeyValue("foo12", k);
73 test("sessionStorage");
78 window.successfullyParsed = true;
79 isSuccessfullyParsed();