1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/localstorage/test_localStorageQuota.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,111 @@ 1.4 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.5 +<head> 1.6 +<title>localStorage and DOM quota test</title> 1.7 + 1.8 +<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 +<script type="text/javascript" src="interOriginTest.js"></script> 1.10 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.11 + 1.12 +<script type="text/javascript"> 1.13 +//Note: this test is currently giving failures when running standalone, see bug 914865 1.14 + 1.15 +var currentTest = 1; 1.16 + 1.17 +function doNextTest() 1.18 +{ 1.19 + slave = frame; 1.20 + 1.21 + switch (currentTest) 1.22 + { 1.23 + case 1: 1.24 + slaveOrigin = "http://example.com"; 1.25 + slave.location = slaveOrigin + slavePath + "frameQuota.html?add&A&success"; 1.26 + break; 1.27 + 1.28 + // In subdomain now set another key with length 500 bytes, i.e. 1.29 + // allocate 501 bytes 1.30 + case 2: 1.31 + slaveOrigin = "http://test1.example.com"; 1.32 + slave.location = slaveOrigin + slavePath + "frameQuota.html?add&B&success"; 1.33 + break; 1.34 + 1.35 + // Try to set the same key value again to check we don't fail 1.36 + // even 1002 bytes has already been exhausted from the quota 1.37 + // We just change the value of an existing key. 1.38 + case 3: 1.39 + slaveOrigin = "http://test1.example.com"; 1.40 + slave.location = slaveOrigin + slavePath + "frameQuota.html?add&B&success"; 1.41 + break; 1.42 + 1.43 + // Try to set the same key to a larger value that would lead to 1.44 + // quota reach and check that the value is still the old one 1.45 + case 4: 1.46 + slaveOrigin = "http://test1.example.com"; 1.47 + slave.location = slaveOrigin + slavePath + "frameQuota.html?add2&B&failure"; 1.48 + break; 1.49 + 1.50 + // In a different subdomain try to set a new 500 bytes key 1.51 + // and check we fail because we are over the quota 1.52 + case 5: 1.53 + slaveOrigin = "https://test2.example.com"; 1.54 + slave.location = slaveOrigin + slavePath + "frameQuota.html?add&C&failure"; 1.55 + break; 1.56 + 1.57 + // Remove from the second subdomain the second key, it must not fail 1.58 + // This should release the allocated space of the quota assigned to 1.59 + // example.com. 1.60 + case 6: 1.61 + slaveOrigin = "http://test1.example.com"; 1.62 + slave.location = slaveOrigin + slavePath + "frameQuota.html?remove&B&success"; 1.63 + break; 1.64 + 1.65 + // Now try again to set 500 bytes key, it must succeed. 1.66 + case 7: 1.67 + slaveOrigin = "https://test2.example.com"; 1.68 + slave.location = slaveOrigin + slavePath + "frameQuota.html?add&C&success"; 1.69 + break; 1.70 + 1.71 + case 8: 1.72 + // Do a clean up... 1.73 + slaveOrigin = "http://example.com"; 1.74 + slave.location = slaveOrigin + slavePath + "frameQuota.html?clear"; 1.75 + break; 1.76 + 1.77 + case 9: 1.78 + // Do a clean up... 1.79 + slaveOrigin = "http://test1.example.com"; 1.80 + slave.location = slaveOrigin + slavePath + "frameQuota.html?clear"; 1.81 + break; 1.82 + 1.83 + case 10: 1.84 + // Do a clean up... 1.85 + slaveOrigin = "https://test2.example.com"; 1.86 + slave.location = slaveOrigin + slavePath + "frameQuota.html?clear"; 1.87 + break; 1.88 + 1.89 + default: // end 1.90 + SimpleTest.finish(); 1.91 + } 1.92 + 1.93 + ++currentTest; 1.94 +} 1.95 + 1.96 +function doStep() 1.97 +{ 1.98 +} 1.99 + 1.100 +SimpleTest.waitForExplicitFinish(); 1.101 + 1.102 +function startTest() { 1.103 + // Initialy setup the quota to testing value of 1024B and 1.104 + // set a 500 bytes key with name length 1 (allocate 501 bytes) 1.105 + SpecialPowers.pushPrefEnv({"set": [["dom.storage.default_quota", 1], ["security.mixed_content.block_display_content", false], ["security.mixed_content.block_active_content", false]]}, doNextTest); 1.106 +} 1.107 +</script> 1.108 + 1.109 +</head> 1.110 + 1.111 +<body onload="startTest();"> 1.112 + <iframe src="" name="frame"></iframe> 1.113 +</body> 1.114 +</html>