mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 1482194. Throw the right exception when localStorage/sessionStorage quota is reached. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D3034 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
85db10cfb9
commit
951bba6efd
@ -98,7 +98,6 @@ DOM_MSG_DEF(NS_ERROR_DOM_PROP_ACCESS_DENIED, "Access to property denied")
|
||||
DOM_MSG_DEF(NS_ERROR_DOM_XPCONNECT_ACCESS_DENIED, "Access to XPConnect service denied")
|
||||
DOM_MSG_DEF(NS_ERROR_DOM_BAD_URI, "Access to restricted URI denied")
|
||||
DOM_MSG_DEF(NS_ERROR_DOM_RETVAL_UNDEFINED, "Return value is undefined")
|
||||
DOM_MSG_DEF(NS_ERROR_DOM_QUOTA_REACHED, "Persistent storage maximum size reached")
|
||||
|
||||
DOM4_MSG_DEF(NotFoundError, "File was not found", NS_ERROR_DOM_FILE_NOT_FOUND_ERR)
|
||||
DOM4_MSG_DEF(NotReadableError, "File could not be read", NS_ERROR_DOM_FILE_NOT_READABLE_ERR)
|
||||
|
@ -424,7 +424,7 @@ LocalStorageCache::SetItem(const LocalStorage* aStorage, const nsAString& aKey,
|
||||
static_cast<int64_t>(aOld.Length());
|
||||
|
||||
if (!ProcessUsageDelta(aStorage, delta, aSource)) {
|
||||
return NS_ERROR_DOM_QUOTA_REACHED;
|
||||
return NS_ERROR_DOM_QUOTA_EXCEEDED_ERR;
|
||||
}
|
||||
|
||||
if (aValue == aOld && DOMStringIsNull(aValue) == DOMStringIsNull(aOld)) {
|
||||
|
@ -104,7 +104,7 @@ SessionStorageCache::SetItem(DataSetType aDataSetType, const nsAString& aKey,
|
||||
}
|
||||
|
||||
if (!dataSet->ProcessUsageDelta(delta)) {
|
||||
return NS_ERROR_DOM_QUOTA_REACHED;
|
||||
return NS_ERROR_DOM_QUOTA_EXCEEDED_ERR;
|
||||
}
|
||||
|
||||
dataSet->mKeys.Put(aKey, nsString(aValue));
|
||||
|
@ -5,7 +5,7 @@
|
||||
<script type="text/javascript" src="interOriginFrame.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
const DOM_QUOTA_REACHED = 2152924150;
|
||||
const DOM_QUOTA_EXCEEDED_ERR = 0x80530016;
|
||||
|
||||
function checkException(func, exc)
|
||||
{
|
||||
@ -61,10 +61,10 @@ function doStep()
|
||||
{
|
||||
case "add":
|
||||
// Attempt to store 500 bytes long string that doens't
|
||||
// fit the quota, have to throw DOM_QUOTA_REACHED exception
|
||||
// fit the quota, have to throw DOM_QUOTA_EXCEEDED_ERR exception
|
||||
checkException(function() {
|
||||
localStorage.setItem(keyName, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
|
||||
}, DOM_QUOTA_REACHED);
|
||||
}, DOM_QUOTA_EXCEEDED_ERR);
|
||||
is(localStorage.getItem(keyName), null, "500 bytes key "+keyName+" is NOT stored");
|
||||
break;
|
||||
|
||||
@ -73,7 +73,7 @@ function doStep()
|
||||
// check it fails and the old key value is still present.
|
||||
checkException(function() {
|
||||
localStorage.setItem(keyName, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
|
||||
}, DOM_QUOTA_REACHED);
|
||||
}, DOM_QUOTA_EXCEEDED_ERR);
|
||||
is(localStorage.getItem(keyName), "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", "Key "+keyName+" left unchanged");
|
||||
break;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<script type="text/javascript" src="interOriginFrame.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
const DOM_QUOTA_REACHED = 2152924150;
|
||||
const DOM_QUOTA_EXCEEDED_ERR = 0x80530016;
|
||||
|
||||
function checkException(func, exc)
|
||||
{
|
||||
@ -61,10 +61,10 @@ function doStep()
|
||||
{
|
||||
case "add":
|
||||
// Attempt to store 500 bytes long string that doens't
|
||||
// fit the quota, have to throw DOM_QUOTA_REACHED exception
|
||||
// fit the quota, have to throw DOM_QUOTA_EXCEEDED_ERR exception
|
||||
checkException(function() {
|
||||
localStorage.setItem(keyName, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
|
||||
}, DOM_QUOTA_REACHED);
|
||||
}, DOM_QUOTA_EXCEEDED_ERR);
|
||||
is(localStorage.getItem(keyName), null, "500 bytes key "+keyName+" is NOT stored");
|
||||
break;
|
||||
|
||||
@ -73,7 +73,7 @@ function doStep()
|
||||
// check it fails and the old key value is still present.
|
||||
checkException(function() {
|
||||
localStorage.setItem(keyName, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
|
||||
}, DOM_QUOTA_REACHED);
|
||||
}, DOM_QUOTA_EXCEEDED_ERR);
|
||||
is(localStorage.getItem(keyName), "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", "Key "+keyName+" left unchanged");
|
||||
break;
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
[storage_local_setitem_quotaexceedederr.html]
|
||||
expected: TIMEOUT
|
||||
disabled: true
|
||||
[Web Storage]
|
||||
expected: FAIL
|
||||
|
@ -1,3 +0,0 @@
|
||||
[storage_session_setitem_quotaexceedederr.html]
|
||||
expected: TIMEOUT
|
||||
disabled: true
|
@ -639,7 +639,6 @@ with modules["DOM"]:
|
||||
errors["NS_ERROR_DOM_XPCONNECT_ACCESS_DENIED"] = FAILURE(1011)
|
||||
errors["NS_ERROR_DOM_BAD_URI"] = FAILURE(1012)
|
||||
errors["NS_ERROR_DOM_RETVAL_UNDEFINED"] = FAILURE(1013)
|
||||
errors["NS_ERROR_DOM_QUOTA_REACHED"] = FAILURE(1014)
|
||||
|
||||
# A way to represent uncatchable exceptions
|
||||
errors["NS_ERROR_UNCATCHABLE_EXCEPTION"] = FAILURE(1015)
|
||||
|
Loading…
Reference in New Issue
Block a user