Bug 510849 - Support the empty string as a key for web storage (localStorage/sessionStorage); r=mayhemer
authorMs2ger <ms2ger@gmail.com>
Fri, 18 May 2012 10:29:40 +0200
changeset 94328 6d219f7754f0cd4d94fe338c8f92decd5cc11830
parent 94327 01d962e8982e90fc9ca79176362e91c9df2d0e34
child 94329 3be25330d617651f37d4ca8e7451667e6c80edf2
push id22706
push userMs2ger@gmail.com
push dateFri, 18 May 2012 08:31:47 +0000
treeherdermozilla-central@4b74c82dd5ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs510849
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 510849 - Support the empty string as a key for web storage (localStorage/sessionStorage); r=mayhemer
dom/imptests/webapps.json
dom/src/storage/nsDOMStorage.cpp
--- a/dom/imptests/webapps.json
+++ b/dom/imptests/webapps.json
@@ -14,43 +14,31 @@
   "webapps/WebStorage/tests/submissions/Infraware/test_storage_local_security.html": {
     "storage local security test": true
   },
 
   "webapps/WebStorage/tests/submissions/Ms2ger/test_event_constructor_js.html": {
     "StorageEvent constructor and nulls": true
   },
 
-  "webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_getitem_js.html": {
-    "All 3 items should be added.": true,
-    "array access should be correct": true,
-    "getItem should be correct": true
-  },
-
   "webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_in_js.html": {
     "Web Storage 1": true
   },
 
   "webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_index_js.html": {
     "Web Storage 1": true,
     "Web Storage 2": true,
     "Web Storage 3": true
   },
 
   "webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_removeitem_js.html": {
     "Web Storage 2": true,
     "Web Storage 3": true
   },
 
-  "webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_getitem_js.html": {
-    "All 3 items should be added.": true,
-    "array access should be correct": true,
-    "getItem should be correct": true
-  },
-
   "webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_in_js.html": {
     "Web Storage 1": true
   },
 
   "webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_index_js.html": {
     "Web Storage 1": true,
     "Web Storage 2": true,
     "Web Storage 3": true
--- a/dom/src/storage/nsDOMStorage.cpp
+++ b/dom/src/storage/nsDOMStorage.cpp
@@ -1175,19 +1175,16 @@ DOMStorageImpl::GetValue(bool aCallerSec
   }
   return item;
 }
 
 nsresult
 DOMStorageImpl::SetValue(bool aIsCallerSecure, const nsAString& aKey,
                          const nsAString& aData, nsAString& aOldValue)
 {
-  if (aKey.IsEmpty())
-    return NS_OK;
-
   nsresult rv;
   nsString oldValue;
   SetDOMStringToNull(oldValue);
 
   // First store the value to the database, we need to do this before we update
   // the mItems cache.  SetDBValue is using the old cached value to decide
   // on quota checking.
   if (UseDB()) {
@@ -1514,19 +1511,16 @@ nsIDOMStorageItem*
 nsDOMStorage::GetNamedItem(const nsAString& aKey, nsresult* aResult)
 {
   if (!CacheStoragePermissions()) {
     *aResult = NS_ERROR_DOM_SECURITY_ERR;
     return nsnull;
   }
 
   *aResult = NS_OK;
-  if (aKey.IsEmpty())
-    return nsnull;
-  
   return mStorageImpl->GetValue(IsCallerSecure(), aKey, aResult);
 }
 
 nsresult
 nsDOMStorage::GetItem(const nsAString& aKey, nsAString &aData)
 {
   nsresult rv;
 
@@ -1612,19 +1606,16 @@ nsDOMStorage::SetItem(const nsAString& a
   return NS_OK;
 }
 
 NS_IMETHODIMP nsDOMStorage::RemoveItem(const nsAString& aKey)
 {
   if (!CacheStoragePermissions())
     return NS_ERROR_DOM_SECURITY_ERR;
 
-  if (aKey.IsEmpty())
-    return NS_OK;
-
   nsString oldValue;
   nsresult rv = mStorageImpl->RemoveValue(IsCallerSecure(), aKey, oldValue);
   if (rv == NS_ERROR_DOM_NOT_FOUND_ERR)
     return NS_OK;
   if (NS_FAILED(rv))
     return rv;
 
   if (!oldValue.IsEmpty() && mEventBroadcaster) {