1 description("Test the DOM Storage quota code.");
3 function testQuota(storageString)
5 storage = eval(storageString);
7 testFailed(storageString + " DOES NOT exist");
11 debug("Testing " + storageString);
13 evalAndLog("storage.clear()");
14 shouldBe("storage.length", "0");
16 debug("Creating 'data' which contains 64K of data");
18 for (var i=0; i<16; i++)
20 shouldBe("data.length", "65536");
22 debug("Putting 'data' into 39 " + storageString + " buckets.");
23 for (var i=0; i<39; i++)
26 debug("Putting 'data' into another bucket.h");
29 testFailed("Did not hit quota error.");
31 testPassed("Hit exception as expected");
34 debug("Verify that data was never inserted.");
35 shouldBeNull("storage.getItem(39)");
37 debug("Removing bucket 38.");
38 storage.removeItem('38');
40 debug("Adding 'Hello!' into a new bucket.");
42 storage['foo'] = "Hello!";
43 testPassed("Insertion worked.");
45 testFailed("Exception: " + e);
49 function testNoQuota(storageString)
51 storage = eval(storageString);
53 testFailed(storageString + " DOES NOT exist");
57 debug("Testing " + storageString);
59 evalAndLog("storage.clear()");
60 shouldBe("storage.length", "0");
62 debug("Creating 'data' which contains 64K of data");
64 for (var i=0; i<16; i++)
66 shouldBe("data.length", "65536");
68 debug("Putting 'data' into 39 " + storageString + " buckets.");
69 for (var i=0; i<39; i++)
72 debug("Putting 'data' into another bucket.h");
75 testPassed("Insertion worked.");
77 testFailed("Exception: " + e);
81 testNoQuota("sessionStorage");
84 testQuota("localStorage");
86 window.successfullyParsed = true;
87 isSuccessfullyParsed();