1 description("Test .removeItem within DOM Storage."); 2 3 function test(storageString) 4 { 5 storage = eval(storageString); 6 if (!storage) { 7 testFailed(storageString + " DOES NOT exist"); 8 return; 9 } 10 11 debug("Testing " + storageString); 12 13 evalAndLog("storage.clear()"); 14 shouldBe("storage.length", "0"); 15 16 debug(""); 17 shouldBeUndefined("storage.foo1"); 18 evalAndLog("storage.foo1 = 'bar'"); 19 shouldBeEqualToString("storage.foo1", "bar"); 20 evalAndLog("storage.removeItem('foo1')"); 21 shouldBeUndefined("storage.foo1"); 22 evalAndLog("storage.removeItem('foo1')"); 23 shouldBeUndefined("storage.foo1"); 24 25 debug(""); 26 shouldBeUndefined("storage['foo2']"); 27 evalAndLog("storage['foo2'] = 'bar'"); 28 shouldBeEqualToString("storage['foo2']", "bar"); 29 evalAndLog("storage.removeItem('foo2')"); 30 shouldBeUndefined("storage['foo2']"); 31 evalAndLog("storage.removeItem('foo2')"); 32 shouldBeUndefined("storage['foo2']"); 33 34 debug(""); 35 shouldBeNull("storage.getItem('foo3')"); 36 evalAndLog("storage.setItem('foo3', 'bar')"); 37 shouldBeEqualToString("storage.getItem('foo3')", "bar"); 38 evalAndLog("storage.removeItem('foo3')"); 39 shouldBeNull("storage.getItem('foo3')"); 40 evalAndLog("storage.removeItem('foo3')"); 41 shouldBeNull("storage.getItem('foo3')"); 42 } 43 44 test("sessionStorage"); 45 debug(""); 46 debug(""); 47 test("localStorage"); 48 49 window.successfullyParsed = true; 50 isSuccessfullyParsed(); 51