Commit 0888f443 authored by jorlow@chromium.org's avatar jorlow@chromium.org
Browse files

2009-08-10 Jeremy Orlow <jorlow@chromium.org>

        Reviewed by Brady Eidson.

        Change ___Storage.key() to match current spec behavior.
        https://bugs.webkit.org/show_bug.cgi?id=28112

        The current WebStorage spec says that ___Storage.key() should return null when
        the index is out of bounds, rather than an exception.  A bunch of logic can be
        simplified after this change.

        * bindings/js/JSStorageCustom.cpp:
        (WebCore::JSStorage::getPropertyNames):
        * bindings/v8/custom/V8StorageCustom.cpp:
        (WebCore::V8Custom::v8StorageNamedPropertyEnumerator):
        * storage/Storage.cpp:
        (WebCore::Storage::key):
        * storage/Storage.h:
        * storage/Storage.idl:
        * storage/StorageArea.h:
        * storage/StorageAreaImpl.cpp:
        (WebCore::StorageAreaImpl::key):
        * storage/StorageAreaImpl.h:
        * storage/StorageMap.cpp:
        (WebCore::StorageMap::key):
        * storage/StorageMap.h:

2009-08-10  Jeremy Orlow  <jorlow@chromium.org>

        Reviewed by Brady Eidson.

        ___Storage.key() changed to match new spec behavior; update layout tests.
        https://bugs.webkit.org/show_bug.cgi?id=28112

        The current WebStorage spec says that ___Storage.key() should return null when
        the index is out of bounds, rather than an exception.  Change the one layout
        test that verified this behavior.

        * storage/domstorage/localstorage/simple-usage-expected.txt:
        * storage/domstorage/localstorage/simple-usage.html:
        * storage/domstorage/sessionstorage/simple-usage-expected.txt:
        * storage/domstorage/sessionstorage/simple-usage.html:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47020 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 729d29e9
2009-08-10 Jeremy Orlow <jorlow@chromium.org>
Reviewed by Brady Eidson.
___Storage.key() changed to match new spec behavior; update layout tests.
https://bugs.webkit.org/show_bug.cgi?id=28112
The current WebStorage spec says that ___Storage.key() should return null when
the index is out of bounds, rather than an exception. Change the one layout
test that verified this behavior.
* storage/domstorage/localstorage/simple-usage-expected.txt:
* storage/domstorage/localstorage/simple-usage.html:
* storage/domstorage/sessionstorage/simple-usage-expected.txt:
* storage/domstorage/sessionstorage/simple-usage.html:
2009-08-07 Ryosuke Niwa <rniwa@webkit.org>
Reviewed by Justin Garcia.
......
......@@ -4,8 +4,8 @@ Value for FOO is null
Length is 1
Value for FOO is BAR
Key for index 0 is FOO
Correctly caught exception trying to access key at index 1
Error: INDEX_SIZE_ERR: DOM Exception 1
Key for index 1 is null
Key for index -1 is null
Length is 1
Value for FOO is BAZ
Length is 0
......
......@@ -26,12 +26,8 @@ function runTest()
log("Length is " + localStorage.length);
log("Value for FOO is " + localStorage.getItem("FOO"));
log("Key for index 0 is " + localStorage.key(0));
try {
localStorage.key(1);
} catch(e) {
log("Correctly caught exception trying to access key at index 1");
log(e);
}
log("Key for index 1 is " + localStorage.key(1));
log("Key for index -1 is " + localStorage.key(-1));
localStorage.setItem("FOO", "BAZ");
......
......@@ -4,8 +4,8 @@ Value for FOO is null
Length is 1
Value for FOO is BAR
Key for index 0 is FOO
Correctly caught exception trying to access key at index 1
Error: INDEX_SIZE_ERR: DOM Exception 1
Key for index 1 is null
Key for index -1 is null
Length is 1
Value for FOO is BAZ
Length is 0
......
......@@ -26,12 +26,8 @@ function runTest()
log("Length is " + window.sessionStorage.length);
log("Value for FOO is " + window.sessionStorage.getItem("FOO"));
log("Key for index 0 is " + window.sessionStorage.key(0));
try {
window.sessionStorage.key(1);
} catch(e) {
log("Correctly caught exception trying to access key at index 1");
log(e);
}
log("Key for index 1 is " + window.sessionStorage.key(1));
log("Key for index -1 is " + window.sessionStorage.key(-1));
window.sessionStorage.setItem("FOO", "BAZ");
......
2009-08-10 Jeremy Orlow <jorlow@chromium.org>
Reviewed by Brady Eidson.
Change ___Storage.key() to match current spec behavior.
https://bugs.webkit.org/show_bug.cgi?id=28112
The current WebStorage spec says that ___Storage.key() should return null when
the index is out of bounds, rather than an exception. A bunch of logic can be
simplified after this change.
* bindings/js/JSStorageCustom.cpp:
(WebCore::JSStorage::getPropertyNames):
* bindings/v8/custom/V8StorageCustom.cpp:
(WebCore::V8Custom::v8StorageNamedPropertyEnumerator):
* storage/Storage.cpp:
(WebCore::Storage::key):
* storage/Storage.h:
* storage/Storage.idl:
* storage/StorageArea.h:
* storage/StorageAreaImpl.cpp:
(WebCore::StorageAreaImpl::key):
* storage/StorageAreaImpl.h:
* storage/StorageMap.cpp:
(WebCore::StorageMap::key):
* storage/StorageMap.h:
2009-08-07 Michael Nordman <michaeln@google.com>
 
Reviewed by Darin Fisher.
......
......@@ -66,10 +66,9 @@ bool JSStorage::deleteProperty(ExecState* exec, const Identifier& propertyName)
void JSStorage::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
{
ExceptionCode ec;
unsigned length = m_impl->length();
for (unsigned i = 0; i < length; ++i)
propertyNames.add(Identifier(exec, m_impl->key(i, ec)));
propertyNames.add(Identifier(exec, m_impl->key(i)));
Base::getPropertyNames(exec, propertyNames);
}
......
......@@ -46,9 +46,8 @@ v8::Handle<v8::Array> V8Custom::v8StorageNamedPropertyEnumerator(const v8::Acces
unsigned int length = storage->length();
v8::Handle<v8::Array> properties = v8::Array::New(length);
for (unsigned int i = 0; i < length; ++i) {
ExceptionCode ec = 0;
String key = storage->key(i, ec);
ASSERT(!ec);
String key = storage->key(i);
ASSERT(!key.isNull());
String val = storage->getItem(key);
properties->Set(v8::Integer::New(i), v8String(key));
}
......
......@@ -59,13 +59,12 @@ unsigned Storage::length() const
return m_storageArea->length();
}
String Storage::key(unsigned index, ExceptionCode& ec) const
String Storage::key(unsigned index) const
{
ec = 0;
if (!m_frame)
return String();
return m_storageArea->key(index, ec);
return m_storageArea->key(index);
}
String Storage::getItem(const String& key) const
......
......@@ -45,7 +45,7 @@ namespace WebCore {
~Storage();
unsigned length() const;
String key(unsigned index, ExceptionCode&) const;
String key(unsigned index) const;
String getItem(const String&) const;
void setItem(const String& key, const String& value, ExceptionCode&);
void removeItem(const String&);
......
......@@ -34,8 +34,7 @@ module storage {
Conditional=DOM_STORAGE
] Storage {
readonly attribute [DontEnum] unsigned long length;
[DontEnum] DOMString key(in unsigned long index)
raises(DOMException);
[DontEnum, ConvertNullStringTo=Null] DOMString key(in unsigned long index);
[DontEnum, ConvertNullStringTo=Null] DOMString getItem(in DOMString key);
[DontEnum] void setItem(in DOMString key, in DOMString data)
raises(DOMException);
......
......@@ -48,7 +48,7 @@ namespace WebCore {
// The HTML5 DOM Storage API
virtual unsigned length() const = 0;
virtual String key(unsigned index, ExceptionCode& ec) const = 0;
virtual String key(unsigned index) const = 0;
virtual String getItem(const String& key) const = 0;
virtual void setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame) = 0;
virtual void removeItem(const String& key, Frame* sourceFrame) = 0;
......
......@@ -106,19 +106,11 @@ unsigned StorageAreaImpl::length() const
return m_storageMap->length();
}
String StorageAreaImpl::key(unsigned index, ExceptionCode& ec) const
String StorageAreaImpl::key(unsigned index) const
{
ASSERT(!m_isShutdown);
blockUntilImportComplete();
String key;
if (!m_storageMap->key(index, key)) {
ec = INDEX_SIZE_ERR;
return String();
}
return key;
return m_storageMap->key(index);
}
String StorageAreaImpl::getItem(const String& key) const
......
......@@ -45,7 +45,7 @@ namespace WebCore {
// The HTML5 DOM Storage API (and contains)
virtual unsigned length() const;
virtual String key(unsigned index, ExceptionCode& ec) const;
virtual String key(unsigned index) const;
virtual String getItem(const String& key) const;
virtual void setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame);
virtual void removeItem(const String& key, Frame* sourceFrame);
......
......@@ -82,15 +82,13 @@ unsigned StorageMap::length() const
return m_map.size();
}
bool StorageMap::key(unsigned index, String& key) const
String StorageMap::key(unsigned index) const
{
if (index >= length())
return false;
return String();
setIteratorToIndex(index);
key = m_iterator->first;
return true;
return m_iterator->first;
}
String StorageMap::getItem(const String& key) const
......
......@@ -42,7 +42,7 @@ namespace WebCore {
static PassRefPtr<StorageMap> create();
unsigned length() const;
bool key(unsigned index, String& key) const;
String key(unsigned index) const;
String getItem(const String&) const;
PassRefPtr<StorageMap> setItem(const String& key, const String& value, String& oldValue);
PassRefPtr<StorageMap> removeItem(const String&, String& oldValue);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment