- Revision
- 185604
- Author
- beid...@apple.com
- Date
- 2015-06-16 13:24:55 -0700 (Tue, 16 Jun 2015)
Log Message
[IndexedDB] array index keys are concatenated across cursor lifetime
<rdar://problem/19684902> and https://bugs.webkit.org/show_bug.cgi?id=138504
Reviewed by Brady Eidson, patch by Mark Dixon <m...@lowla.io>
Source/WebCore:
Tested by:
storage/indexeddb/keypath-arrays.html
IDBKeyData and IDBKeyPath need to clear any existing array values before calling
decodeObjects to update the value of an existing object.
* Modules/indexeddb/IDBKeyData.cpp:
(WebCore::IDBKeyData::decode):
* Modules/indexeddb/IDBKeyPath.cpp:
(WebCore::IDBKeyPath::decode):
LayoutTests:
* storage/indexeddb/keypath-arrays-expected.txt:
* storage/indexeddb/resources/keypath-arrays.js:
Verify that iterating cursors with array keypaths returns correct keys for all
records, not just the first.
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (185603 => 185604)
--- trunk/LayoutTests/ChangeLog 2015-06-16 19:50:59 UTC (rev 185603)
+++ trunk/LayoutTests/ChangeLog 2015-06-16 20:24:55 UTC (rev 185604)
@@ -1,3 +1,15 @@
+2015-06-16 Brady Eidson <beid...@apple.com>
+
+ [IndexedDB] array index keys are concatenated across cursor lifetime
+ <rdar://problem/19684902> and https://bugs.webkit.org/show_bug.cgi?id=138504
+
+ Reviewed by Brady Eidson, patch by Mark Dixon <m...@lowla.io>
+
+ * storage/indexeddb/keypath-arrays-expected.txt:
+ * storage/indexeddb/resources/keypath-arrays.js:
+ Verify that iterating cursors with array keypaths returns correct keys for all
+ records, not just the first.
+
2015-06-16 Said Abou-Hallawa <sabouhall...@apple.com>
Canvas dimensions should be limited to 4096x4096 pixels on iOS devices.
Modified: trunk/LayoutTests/storage/indexeddb/keypath-arrays-expected.txt (185603 => 185604)
--- trunk/LayoutTests/storage/indexeddb/keypath-arrays-expected.txt 2015-06-16 19:50:59 UTC (rev 185603)
+++ trunk/LayoutTests/storage/indexeddb/keypath-arrays-expected.txt 2015-06-16 20:24:55 UTC (rev 185604)
@@ -35,15 +35,23 @@
index = store.index('index')
request = store.put({a: 1, b: 2, c: 3, d: 4})
+request = store.put({a: 5, b: 6, c: 7, d: 8})
request = store.openCursor()
cursor = request.result
PASS cursor is non-null.
PASS JSON.stringify(cursor.key) is "[1,2]"
+cursor = request.result
+PASS cursor is non-null.
+PASS JSON.stringify(cursor.key) is "[5,6]"
request = index.openCursor()
cursor = request.result
PASS cursor is non-null.
PASS JSON.stringify(cursor.primaryKey) is "[1,2]"
PASS JSON.stringify(cursor.key) is "[3,4]"
+cursor = request.result
+PASS cursor is non-null.
+PASS JSON.stringify(cursor.primaryKey) is "[5,6]"
+PASS JSON.stringify(cursor.key) is "[7,8]"
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/storage/indexeddb/resources/keypath-arrays.js (185603 => 185604)
--- trunk/LayoutTests/storage/indexeddb/resources/keypath-arrays.js 2015-06-16 19:50:59 UTC (rev 185603)
+++ trunk/LayoutTests/storage/indexeddb/resources/keypath-arrays.js 2015-06-16 20:24:55 UTC (rev 185604)
@@ -35,6 +35,9 @@
debug("");
evalAndLog("request = store.put({a: 1, b: 2, c: 3, d: 4})");
request._onerror_ = unexpectedErrorCallback;
+ evalAndLog("request = store.put({a: 5, b: 6, c: 7, d: 8})");
+ request._onerror_ = unexpectedErrorCallback;
+ iteration = 0;
checkStore();
function checkStore() {
@@ -43,8 +46,15 @@
request._onsuccess_ = function () {
evalAndLog("cursor = request.result");
shouldBeNonNull("cursor");
- shouldBeEqualToString("JSON.stringify(cursor.key)", "[1,2]");
- checkIndex();
+ shouldBeEqualToString("JSON.stringify(cursor.key)", ["[1,2]", "[5,6]"][iteration]);
+ if (0 === iteration) {
+ ++iteration;
+ cursor.continue();
+ }
+ else {
+ iteration = 0;
+ checkIndex();
+ }
};
};
@@ -54,8 +64,12 @@
request._onsuccess_ = function () {
evalAndLog("cursor = request.result");
shouldBeNonNull("cursor");
- shouldBeEqualToString("JSON.stringify(cursor.primaryKey)", "[1,2]");
- shouldBeEqualToString("JSON.stringify(cursor.key)", "[3,4]");
+ shouldBeEqualToString("JSON.stringify(cursor.primaryKey)", ["[1,2]", "[5,6]"][iteration]);
+ shouldBeEqualToString("JSON.stringify(cursor.key)", ["[3,4]", "[7,8]"][iteration]);
+ if (0 === iteration) {
+ ++iteration;
+ cursor.continue();
+ }
};
};
Modified: trunk/Source/WebCore/ChangeLog (185603 => 185604)
--- trunk/Source/WebCore/ChangeLog 2015-06-16 19:50:59 UTC (rev 185603)
+++ trunk/Source/WebCore/ChangeLog 2015-06-16 20:24:55 UTC (rev 185604)
@@ -1,3 +1,21 @@
+2015-06-16 Brady Eidson <beid...@apple.com>
+
+ [IndexedDB] array index keys are concatenated across cursor lifetime
+ <rdar://problem/19684902> and https://bugs.webkit.org/show_bug.cgi?id=138504
+
+ Reviewed by Brady Eidson, patch by Mark Dixon <m...@lowla.io>
+
+ Tested by:
+ storage/indexeddb/keypath-arrays.html
+
+ IDBKeyData and IDBKeyPath need to clear any existing array values before calling
+ decodeObjects to update the value of an existing object.
+
+ * Modules/indexeddb/IDBKeyData.cpp:
+ (WebCore::IDBKeyData::decode):
+ * Modules/indexeddb/IDBKeyPath.cpp:
+ (WebCore::IDBKeyPath::decode):
+
2015-06-16 Said Abou-Hallawa <sabouhall...@apple.com>
Canvas dimensions should be limited to 4096x4096 pixels on iOS devices.
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp (185603 => 185604)
--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp 2015-06-16 19:50:59 UTC (rev 185603)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp 2015-06-16 20:24:55 UTC (rev 185604)
@@ -201,6 +201,8 @@
auto arrayFunction = [](KeyedDecoder& decoder, IDBKeyData& result) {
return decode(decoder, result);
};
+
+ result.arrayValue.clear();
return decoder.decodeObjects("array", result.arrayValue, arrayFunction);
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp (185603 => 185604)
--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp 2015-06-16 19:50:59 UTC (rev 185603)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp 2015-06-16 20:24:55 UTC (rev 185604)
@@ -300,6 +300,7 @@
return decoder.decodeString("string", result);
};
+ result.m_array.clear();
return decoder.decodeObjects("array", result.m_array, arrayFunction);
}