Unreviewed, rolling out r105376.
authorrolandsteiner@chromium.org <rolandsteiner@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2012 05:20:17 +0000 (05:20 +0000)
committerrolandsteiner@chromium.org <rolandsteiner@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2012 05:20:17 +0000 (05:20 +0000)
http://trac.webkit.org/changeset/105376
https://bugs.webkit.org/show_bug.cgi?id=76601

Roll 76493 back in after discussion with jsbell (Requested by
rolandsteiner on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-01-18

Source/WebCore:

* bindings/v8/IDBBindingUtilities.cpp:
(WebCore::injectIDBKeyIntoSerializedValue):

LayoutTests:

* storage/indexeddb/objectstore-autoincrement-expected.txt:
* storage/indexeddb/objectstore-autoincrement.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105378 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/objectstore-autoincrement-expected.txt
LayoutTests/storage/indexeddb/objectstore-autoincrement.html
Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/IDBBindingUtilities.cpp

index c6681e7..30a0d66 100644 (file)
@@ -1,5 +1,17 @@
 2012-01-18  Sheriff Bot  <webkit.review.bot@gmail.com>
 
+        Unreviewed, rolling out r105376.
+        http://trac.webkit.org/changeset/105376
+        https://bugs.webkit.org/show_bug.cgi?id=76601
+
+        Roll 76493 back in after discussion with jsbell (Requested by
+        rolandsteiner on #webkit).
+
+        * storage/indexeddb/objectstore-autoincrement-expected.txt:
+        * storage/indexeddb/objectstore-autoincrement.html:
+
+2012-01-18  Sheriff Bot  <webkit.review.bot@gmail.com>
+
         Unreviewed, rolling out r105331.
         http://trac.webkit.org/changeset/105331
         https://bugs.webkit.org/show_bug.cgi?id=76599
index 48b11bb..5e8489b 100644 (file)
@@ -15,13 +15,14 @@ createObjectStore():
 store = db.createObjectStore('StoreWithKeyPath', {keyPath: 'id', autoIncrement: true})
 db.createObjectStore('StoreWithAutoIncrement', {autoIncrement: true})
 db.createObjectStore('PlainOldStore', {autoIncrement: false})
+db.createObjectStore('StoreWithLongKeyPath', {keyPath: 'a.b.c.id', autoIncrement: true})
 storeNames = db.objectStoreNames
 PASS store.name is "StoreWithKeyPath"
 PASS store.keyPath is 'id'
 PASS storeNames.contains('StoreWithKeyPath') is true
 PASS storeNames.contains('StoreWithAutoIncrement') is true
 PASS storeNames.contains('PlainOldStore') is true
-PASS storeNames.length is 3
+PASS storeNames.length is 4
 setVersionCompleted():
 trans = db.transaction(['StoreWithKeyPath', 'StoreWithAutoIncrement', 'PlainOldStore'], webkitIDBTransaction.READ_WRITE)
 store = trans.objectStore('StoreWithKeyPath')
@@ -62,6 +63,27 @@ PASS code is webkitIDBDatabaseException.DATA_ERR
 store.add({name: 'Adam'}, 1)
 addAdamSuccess():
 PASS event.target.result is 1
+testLongKeyPath():
+trans = db.transaction('StoreWithLongKeyPath', webkitIDBTransaction.READ_WRITE)
+store = trans.objectStore('StoreWithLongKeyPath')
+store.add({foo: 'bar'})
+store.add({foo: 'bar', a: {}})
+store.add({foo: 'bar', a: {b: {}}})
+store.add({foo: 'bar', a: {b: {c: {}}}})
+store.openCursor()
+expected = null
+count = 0
+expected = cursor.value.a.b.c.id + 1
+PASS cursor.value.foo is 'bar'
+PASS cursor.value.a.b.c.id is expected
+expected = cursor.value.a.b.c.id + 1
+PASS cursor.value.foo is 'bar'
+PASS cursor.value.a.b.c.id is expected
+expected = cursor.value.a.b.c.id + 1
+PASS cursor.value.foo is 'bar'
+PASS cursor.value.a.b.c.id is expected
+expected = cursor.value.a.b.c.id + 1
+PASS count is 4
 PASS successfullyParsed is true
 
 TEST COMPLETE
index fb804cf..718e0e6 100644 (file)
@@ -43,6 +43,7 @@ function setVersionSuccess()
     window.store = evalAndLog("store = db.createObjectStore('StoreWithKeyPath', {keyPath: 'id', autoIncrement: true})");
     evalAndLog("db.createObjectStore('StoreWithAutoIncrement', {autoIncrement: true})");
     evalAndLog("db.createObjectStore('PlainOldStore', {autoIncrement: false})");
+    evalAndLog("db.createObjectStore('StoreWithLongKeyPath', {keyPath: 'a.b.c.id', autoIncrement: true})");
     var storeNames = evalAndLog("storeNames = db.objectStoreNames");
 
     shouldBeEqualToString("store.name", "StoreWithKeyPath");
@@ -50,7 +51,7 @@ function setVersionSuccess()
     shouldBe("storeNames.contains('StoreWithKeyPath')", "true");
     shouldBe("storeNames.contains('StoreWithAutoIncrement')", "true");
     shouldBe("storeNames.contains('PlainOldStore')", "true");
-    shouldBe("storeNames.length", "3");
+    shouldBe("storeNames.length", "4");
 
     // Let the setVersion transaction complete.
 }
@@ -61,7 +62,7 @@ function setVersionCompleted()
 
     window.trans = evalAndLog("trans = db.transaction(['StoreWithKeyPath', 'StoreWithAutoIncrement', 'PlainOldStore'], webkitIDBTransaction.READ_WRITE)");
     trans.onabort = unexpectedAbortCallback;
-    trans.oncomplete = done;
+    trans.oncomplete = testLongKeyPath;
 
     window.store = evalAndLog("store = trans.objectStore('StoreWithKeyPath')");
 
@@ -157,6 +158,45 @@ function addAdamSuccess()
     shouldBe("event.target.result", "1");
 }
 
+function testLongKeyPath()
+{
+    debug("testLongKeyPath():");
+    trans = evalAndLog("trans = db.transaction('StoreWithLongKeyPath', webkitIDBTransaction.READ_WRITE)");
+    trans.onabort = unexpectedAbortCallback;
+    trans.oncomplete = done;
+
+    store = evalAndLog("store = trans.objectStore('StoreWithLongKeyPath')");
+    request = evalAndLog("store.add({foo: 'bar'})");
+    request.onerror = unexpectedErrorCallback;
+    request = evalAndLog("store.add({foo: 'bar', a: {}})");
+    request.onerror = unexpectedErrorCallback;
+    request = evalAndLog("store.add({foo: 'bar', a: {b: {}}})");
+    request.onerror = unexpectedErrorCallback;
+    request = evalAndLog("store.add({foo: 'bar', a: {b: {c: {}}}})");
+    request.onerror = unexpectedErrorCallback;
+    cursorRequest = evalAndLog("store.openCursor()");
+    cursorRequest.onerror = unexpectedErrorCallback;
+    evalAndLog("expected = null");
+    evalAndLog("count = 0");
+    cursorRequest.onsuccess = function () {
+        cursor = cursorRequest.result;
+        if (!cursor) {
+            shouldBe("count", "4");
+            return;
+        }
+        if (expected === null) {
+            evalAndLog("expected = cursor.value.a.b.c.id + 1");
+        } else {
+            shouldBe("cursor.value.foo", "'bar'");
+            shouldBe("cursor.value.a.b.c.id", "expected");
+            evalAndLog("expected = cursor.value.a.b.c.id + 1");
+        }
+        count++;
+        cursor.continue();
+    };
+}
+
+
 test();
 
 
index 13852d2..bd74335 100644 (file)
@@ -1,3 +1,15 @@
+2012-01-18  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r105376.
+        http://trac.webkit.org/changeset/105376
+        https://bugs.webkit.org/show_bug.cgi?id=76601
+
+        Roll 76493 back in after discussion with jsbell (Requested by
+        rolandsteiner on #webkit).
+
+        * bindings/v8/IDBBindingUtilities.cpp:
+        (WebCore::injectIDBKeyIntoSerializedValue):
+
 2012-01-18  Ian Vollick  <vollick@chromium.org>
 
         [chromium] Create a base-class CCAnimation to represent compositor animations
index dba15e3..d0fb1ce 100644 (file)
@@ -125,6 +125,25 @@ v8::Handle<v8::Value> getNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, con
     return currentValue;
 }
 
+v8::Handle<v8::Value> ensureNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index)
+{
+    v8::Handle<v8::Value> currentValue(rootValue);
+
+    ASSERT(index <= keyPathElements.size());
+    for (size_t i = 0; i < index; ++i) {
+        v8::Handle<v8::Value> parentValue(currentValue);
+        const String& keyPathElement = keyPathElements[i];
+        if (!get(currentValue, keyPathElement)) {
+            v8::Handle<v8::Object> object = v8::Object::New();
+            if (!set(parentValue, keyPathElement, object))
+                return v8::Handle<v8::Value>();
+            currentValue = object;
+        }
+    }
+
+    return currentValue;
+}
+
 } // anonymous namespace
 
 PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> value, const Vector<String>& keyPath)
@@ -144,7 +163,7 @@ PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDB
         return 0;
 
     v8::Handle<v8::Value> v8Value(value->deserialize());
-    v8::Handle<v8::Value> parent(getNthValueOnKeyPath(v8Value, keyPath, keyPath.size() - 1));
+    v8::Handle<v8::Value> parent(ensureNthValueOnKeyPath(v8Value, keyPath, keyPath.size() - 1));
     if (parent.IsEmpty())
         return 0;