1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly2.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 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 + 1.14 +var currentTest = 1; 1.15 + 1.16 +function doNextTest() 1.17 +{ 1.18 + slave = frame; 1.19 + 1.20 + switch (currentTest) 1.21 + { 1.22 + case 1: 1.23 + slaveOrigin = "http://example.com"; 1.24 + slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&A&success"; 1.25 + break; 1.26 + 1.27 + // In subdomain now set another key with length 500 bytes, i.e. 1.28 + // allocate 501 bytes 1.29 + case 2: 1.30 + slaveOrigin = "http://example.com"; 1.31 + slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&B&success"; 1.32 + break; 1.33 + 1.34 + // Try to set the same key value again to check we don't fail 1.35 + // even 1002 bytes has already been exhausted from the quota 1.36 + // We just change the value of an existing key. 1.37 + case 3: 1.38 + slaveOrigin = "http://example.com"; 1.39 + slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&B&success"; 1.40 + break; 1.41 + 1.42 + // Try to set the same key to a larger value that would lead to 1.43 + // quota reach and check that the value is still the old one 1.44 + case 4: 1.45 + slaveOrigin = "http://example.com"; 1.46 + slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add2&B&failure"; 1.47 + break; 1.48 + 1.49 + // Try to set a new 500 bytes key 1.50 + // and check we fail because we are over the quota 1.51 + case 5: 1.52 + slaveOrigin = "https://example.com"; 1.53 + slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&C&failure"; 1.54 + break; 1.55 + 1.56 + // Remove the key inherited from the non-session-only database 1.57 + case 6: 1.58 + slaveOrigin = "http://example.com"; 1.59 + slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?remove&A&success"; 1.60 + break; 1.61 + 1.62 + // Now try again to set 500 bytes key, it must succeed. 1.63 + case 7: 1.64 + slaveOrigin = "https://example.com"; 1.65 + slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&C&success"; 1.66 + break; 1.67 + 1.68 + case 8: 1.69 + // Do a clean up... 1.70 + slaveOrigin = "http://example.com"; 1.71 + slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?clear"; 1.72 + break; 1.73 + 1.74 + default: 1.75 + SimpleTest.finish(); 1.76 + } 1.77 + 1.78 + ++currentTest; 1.79 +} 1.80 + 1.81 +function doStep() 1.82 +{ 1.83 +} 1.84 + 1.85 +SimpleTest.waitForExplicitFinish(); 1.86 + 1.87 +function startTest() { 1.88 + // Initialy setup the quota to testing value of 1024B and 1.89 + // set a 500 bytes key with name length 1 (allocate 501 bytes) 1.90 + SpecialPowers.pushPrefEnv({"set": [["dom.storage.default_quota", 1], ["security.mixed_content.block_display_content", false], ["security.mixed_content.block_active_content", false]]}, function() { 1.91 + SpecialPowers.pushPermissions([{'type': 'cookie', 'allow': SpecialPowers.Ci.nsICookiePermission.ACCESS_SESSION, 'context': document}], doNextTest); 1.92 + }); 1.93 +} 1.94 +</script> 1.95 + 1.96 +</head> 1.97 + 1.98 +<body onload="startTest();"> 1.99 + <iframe src="" name="frame"></iframe> 1.100 +</body> 1.101 +</html>