test_localStorageQuotaSessionOnly2.html (3142B)
1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 <head> 3 <title>localStorage and DOM quota test</title> 4 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <script type="text/javascript" src="interOriginTest.js"></script> 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 8 9 <script type="text/javascript"> 10 11 var currentTest = 1; 12 13 function doNextTest() 14 { 15 slave = frame; 16 17 switch (currentTest) 18 { 19 case 1: 20 slaveOrigin = "http://example.com"; 21 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&A&success"; 22 break; 23 24 // In subdomain now set another key with length 500 bytes, i.e. 25 // allocate 501 bytes 26 case 2: 27 slaveOrigin = "http://example.com"; 28 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&B&success"; 29 break; 30 31 // Try to set the same key value again to check we don't fail 32 // even 1002 bytes has already been exhausted from the quota 33 // We just change the value of an existing key. 34 case 3: 35 slaveOrigin = "http://example.com"; 36 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&B&success"; 37 break; 38 39 // Try to set the same key to a larger value that would lead to 40 // quota reach and check that the value is still the old one 41 case 4: 42 slaveOrigin = "http://example.com"; 43 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add2&B&failure"; 44 break; 45 46 // Try to set a new 500 bytes key 47 // and check we fail because we are over the quota 48 case 5: 49 slaveOrigin = "https://example.com"; 50 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&C&failure"; 51 break; 52 53 // Remove the key inherited from the non-session-only database 54 case 6: 55 slaveOrigin = "http://example.com"; 56 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?remove&A&success"; 57 break; 58 59 // Now try again to set 500 bytes key, it must succeed. 60 case 7: 61 slaveOrigin = "https://example.com"; 62 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&C&success"; 63 break; 64 65 case 8: 66 // Do a clean up... 67 slaveOrigin = "http://example.com"; 68 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?clear"; 69 break; 70 71 default: 72 SimpleTest.finish(); 73 } 74 75 ++currentTest; 76 } 77 78 function doStep() 79 { 80 } 81 82 SimpleTest.waitForExplicitFinish(); 83 84 function startTest() { 85 // Initialy setup the quota to testing value of 1024B and 86 // set a 500 bytes key with name length 1 (allocate 501 bytes) 87 SpecialPowers.pushPrefEnv({"set": [["dom.storage.default_quota", 1], ["dom.storage.default_site_quota", 1], ["security.mixed_content.block_display_content", false], ["security.mixed_content.block_active_content", false]]}, function() { 88 SpecialPowers.pushPermissions([{'type': 'cookie', 'allow': SpecialPowers.Ci.nsICookiePermission.ACCESS_SESSION, 'context': document}], doNextTest); 89 }); 90 } 91 </script> 92 93 </head> 94 95 <body onload="startTest();"> 96 <iframe src="" name="frame"></iframe> 97 </body> 98 </html>