gecko/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly2.html
Bobby Holley 5af5a73d3d Bug 792036 - Automated fixups. r=mccr8
find /files/mozilla/build/d/_tests/testing/mochitest/tests/ | egrep "\.(xhtml|html|xml|js)$" | grep -v SimpleTest | grep -vi mochikit | grep -v simpleThread | grep -v test_ipc_messagemanager_blob.html | grep -v "indexedDB/test" | xargs grep -l Components |  xargs grep -L enablePrivilege | perl -pe 's#.*mochitest/tests/##' | xargs perl -p -i.bakkk -e 's/Components\.interfaces(\s|;|\.|\[)/SpecialPowers\.Ci$1/g, s/SpecialPowers\.wrap\(Components\)\.(.)(lasses|tils|nterfaces|esults)/SpecialPowers.C$1/g, s/(?<![\.a-zA-Z])Components/SpecialPowers\.Components/g, s/window\.Components/window\.SpecialPowers\.Components/g'
2012-09-24 14:46:29 +02:00

117 lines
3.5 KiB
HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>localStorage and DOM quota test</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="interOriginTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript">
const Cc = SpecialPowers.Cc;
var currentTest = 1;
var prefs = Cc["@mozilla.org/preferences-service;1"]
.getService(SpecialPowers.Ci.nsIPrefBranch);
var io = Cc["@mozilla.org/network/io-service;1"]
.getService(SpecialPowers.Ci.nsIIOService);
var uri = io.newURI(window.location, "", null);
var cp = Cc["@mozilla.org/cookie/permission;1"]
.getService(SpecialPowers.Ci.nsICookiePermission);
var quota;
function doNextTest()
{
slave = frame;
switch (currentTest)
{
// Initialy setup the quota to testing value of 1024B and
// set a 500 bytes key with name length 1 (allocate 501 bytes)
case 1:
try {
quota = prefs.getIntPref("dom.storage.default_quota");
} catch (ex) {
quota = 5*1024;
}
prefs.setIntPref("dom.storage.default_quota", 1);
slaveOrigin = "http://example.com";
slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&A&success";
break;
// In subdomain now set another key with length 500 bytes, i.e.
// allocate 501 bytes
case 2:
cp.setAccess(uri, SpecialPowers.Ci.nsICookiePermission.ACCESS_SESSION);
slaveOrigin = "http://example.com";
slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&B&success";
break;
// Try to set the same key value again to check we don't fail
// even 1002 bytes has already been exhausted from the quota
// We just change the value of an existing key.
case 3:
slaveOrigin = "http://example.com";
slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&B&success";
break;
// Try to set the same key to a larger value that would lead to
// quota reach and check that the value is still the old one
case 4:
slaveOrigin = "http://example.com";
slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add2&B&failure";
break;
// Try to set a new 500 bytes key
// and check we fail because we are over the quota
case 5:
slaveOrigin = "https://example.com";
slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&C&failure";
break;
// Remove the key inherited from the non-session-only database
case 6:
slaveOrigin = "http://example.com";
slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?remove&A&success";
break;
// Now try again to set 500 bytes key, it must succeed.
case 7:
slaveOrigin = "https://example.com";
slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&C&success";
break;
case 8:
// Do a clean up...
slaveOrigin = "http://example.com";
slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?clear";
cp.setAccess(uri, SpecialPowers.Ci.nsICookiePermission.ACCESS_DEFAULT);
break;
default:
prefs.setIntPref("dom.storage.default_quota", quota);
cp.setAccess(uri, SpecialPowers.Ci.nsICookiePermission.ACCESS_DEFAULT);
SimpleTest.finish();
}
++currentTest;
}
function doStep()
{
}
SimpleTest.waitForExplicitFinish();
</script>
</head>
<body onload="doNextTest();">
<iframe src="" name="frame"></iframe>
</body>
</html>