Title: [243348] trunk
Revision
243348
Author
[email protected]
Date
2019-03-21 17:03:31 -0700 (Thu, 21 Mar 2019)

Log Message

Fix key path extraction code in IndexedDB to check own property
https://bugs.webkit.org/show_bug.cgi?id=196099

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Updated test expectations to PASS.

* web-platform-tests/IndexedDB/key-conversion-exceptions-expected.txt:
* web-platform-tests/IndexedDB/keygenerator-inject-expected.txt:
* web-platform-tests/IndexedDB/keypath-exceptions-expected.txt: Added.
* web-platform-tests/IndexedDB/wasm-module-value-expected.txt:

Source/WebCore:

Covered by existing tests.

* Modules/indexeddb/IDBFactory.cpp:
(WebCore::IDBFactory::cmp):
We don't need to check the second parameters if the first is already invalid.

* Modules/indexeddb/IDBKeyRange.cpp:
(WebCore::IDBKeyRange::bound):
Ditto.

* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::putOrAdd):
we should not clear the exception during serialization because the execeptions may be explicitly thrown by parameters.

* bindings/js/IDBBindingUtilities.cpp:
(WebCore::get):
Fix implementation according to https://www.w3.org/TR/IndexedDB-2/#extract-key-from-value.

(WebCore::canInjectNthValueOnKeyPath):
Check the last identifier.

LayoutTests:

Rebaseline the tests because we will have same exception but different exception messages after the patch.

* storage/indexeddb/clone-exception-expected.txt:
* storage/indexeddb/clone-exception-private-expected.txt:
* storage/indexeddb/exceptions-expected.txt:
* storage/indexeddb/exceptions-private-expected.txt:
* storage/indexeddb/objectstore-basics-expected.txt:
* storage/indexeddb/objectstore-basics-private-expected.txt:
* storage/indexeddb/objectstore-basics-workers-expected.txt:
* storage/indexeddb/structured-clone-expected.txt:
* storage/indexeddb/structured-clone-private-expected.txt:
* storage/indexeddb/wasm-exceptions-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (243347 => 243348)


--- trunk/LayoutTests/ChangeLog	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/ChangeLog	2019-03-22 00:03:31 UTC (rev 243348)
@@ -1,3 +1,23 @@
+2019-03-21  Sihui Liu  <[email protected]>
+
+        Fix key path extraction code in IndexedDB to check own property
+        https://bugs.webkit.org/show_bug.cgi?id=196099
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline the tests because we will have same exception but different exception messages after the patch.
+
+        * storage/indexeddb/clone-exception-expected.txt:
+        * storage/indexeddb/clone-exception-private-expected.txt:
+        * storage/indexeddb/exceptions-expected.txt:
+        * storage/indexeddb/exceptions-private-expected.txt:
+        * storage/indexeddb/objectstore-basics-expected.txt:
+        * storage/indexeddb/objectstore-basics-private-expected.txt:
+        * storage/indexeddb/objectstore-basics-workers-expected.txt:
+        * storage/indexeddb/structured-clone-expected.txt:
+        * storage/indexeddb/structured-clone-private-expected.txt:
+        * storage/indexeddb/wasm-exceptions-expected.txt:
+
 2019-03-21  Simon Fraser  <[email protected]>
 
         [iOS WK2] Turn on async overflow scrolling by default

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (243347 => 243348)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2019-03-22 00:03:31 UTC (rev 243348)
@@ -1,3 +1,30 @@
+2019-03-21  Sihui Liu  <[email protected]>
+
+        Fix key path extraction code in IndexedDB to check own property
+        https://bugs.webkit.org/show_bug.cgi?id=196099
+
+        Reviewed by Ryosuke Niwa.
+
+        Updated test expectations to PASS.
+
+        * web-platform-tests/IndexedDB/key-conversion-exceptions-expected.txt:
+        * web-platform-tests/IndexedDB/keygenerator-inject-expected.txt:
+        * web-platform-tests/IndexedDB/keypath-exceptions-expected.txt: Added.
+        * web-platform-tests/IndexedDB/wasm-module-value-expected.txt:
+
+2019-03-21  Sihui Liu  <[email protected]>
+
+        Fix three IDB WPT tests
+        https://bugs.webkit.org/show_bug.cgi?id=196099
+
+        Reviewed by Ryosuke Niwa.
+
+        Updated test expectations to PASS.
+
+        * web-platform-tests/IndexedDB/key-conversion-exceptions-expected.txt:
+        * web-platform-tests/IndexedDB/keygenerator-inject-expected.txt:
+        * web-platform-tests/IndexedDB/keypath-exceptions-expected.txt: Added.
+
 2019-03-21  Youenn Fablet  <[email protected]>
 
         Fix one of RTCRtpTransceiver-stop.html test title

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/key-conversion-exceptions-expected.txt (243347 => 243348)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/key-conversion-exceptions-expected.txt	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/key-conversion-exceptions-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -1,7 +1,5 @@
 
-FAIL IDBFactory cmp() static with throwing/invalid keys assert_throws: first key conversion with invalid key should throw DataError function "() => {
-            receiver[method](invalid_key, throwing_key('getter 2'));
-        }" threw object "getter 2: throwing from getter" that is not a DOMException DataError: property "code" is equal to undefined, expected 0
+PASS IDBFactory cmp() static with throwing/invalid keys 
 PASS IDBCursor continue() method with throwing/invalid keys 
 PASS IndexedDB: Exceptions thrown during key conversion 
 PASS IDBCursor update() method with throwing/invalid keys 
@@ -8,15 +6,9 @@
 PASS IDBKeyRange only() static with throwing/invalid keys 
 PASS IDBKeyRange lowerBound() static with throwing/invalid keys 
 PASS IDBKeyRange upperBound() static with throwing/invalid keys 
-FAIL IDBKeyRange bound() static with throwing/invalid keys assert_throws: first key conversion with invalid key should throw DataError function "() => {
-            receiver[method](invalid_key, throwing_key('getter 2'));
-        }" threw object "getter 2: throwing from getter" that is not a DOMException DataError: property "code" is equal to undefined, expected 0
-FAIL IDBObjectStore add() method with throwing/invalid keys assert_throws: key conversion with throwing getter should rethrow function "() => {
-            out_of_line[method]('value', throwing_key('getter'));
-        }" threw object "DataCloneError: Failed to store record in an IDBObjectStore: An object could not be cloned." ("DataCloneError") expected object "[object Object]" ("getter")
-FAIL IDBObjectStore put() method with throwing/invalid keys assert_throws: key conversion with throwing getter should rethrow function "() => {
-            out_of_line[method]('value', throwing_key('getter'));
-        }" threw object "DataCloneError: Failed to store record in an IDBObjectStore: An object could not be cloned." ("DataCloneError") expected object "[object Object]" ("getter")
+PASS IDBKeyRange bound() static with throwing/invalid keys 
+PASS IDBObjectStore add() method with throwing/invalid keys 
+PASS IDBObjectStore put() method with throwing/invalid keys 
 PASS IDBObjectStore delete() method with throwing/invalid keys 
 PASS IDBObjectStore get() method with throwing/invalid keys 
 PASS IDBObjectStore getKey() method with throwing/invalid keys 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/keygenerator-inject-expected.txt (243347 => 243348)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/keygenerator-inject-expected.txt	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/keygenerator-inject-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -3,7 +3,5 @@
 PASS Key is injected into value - multi-segment path 
 PASS Key is injected into value - multi-segment path, partially populated 
 PASS put() throws if key cannot be injected - single segment path 
-FAIL put() throws if key cannot be injected - multi-segment path assert_throws: Key path should be checked against value function "() => {
-      store.put({a: {b: 123} });
-    }" did not throw
+PASS put() throws if key cannot be injected - multi-segment path 
 

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/keypath-exceptions-expected.txt (0 => 243348)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/keypath-exceptions-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/keypath-exceptions-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -0,0 +1,8 @@
+
+PASS The last element of keypath is validated 
+PASS Key path evaluation: Exceptions from non-enumerable getters 
+PASS Key path evaluation: Exceptions from enumerable getters 
+PASS Key path evaluation: Exceptions from non-enumerable getters on prototype 
+PASS Key path evaluation: Exceptions from enumerable getters on prototype 
+PASS Array key conversion should not invoke prototype getters 
+

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/wasm-module-value-expected.txt (243347 => 243348)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/wasm-module-value-expected.txt	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/wasm-module-value-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -1,5 +1,5 @@
 
-FAIL WebAssembly module as an IndexedDB value Failed to store record in an IDBObjectStore: An object could not be cloned.
-FAIL WebAssembly module in a _javascript_ object IndexedDB value Failed to store record in an IDBObjectStore: An object could not be cloned.
-FAIL WebAssembly module in an IndexedDB value with an inline key Failed to store record in an IDBObjectStore: An object could not be cloned.
+FAIL WebAssembly module as an IndexedDB value The object can not be cloned.
+FAIL WebAssembly module in a _javascript_ object IndexedDB value The object can not be cloned.
+FAIL WebAssembly module in an IndexedDB value with an inline key The object can not be cloned.
 

Modified: trunk/LayoutTests/storage/indexeddb/clone-exception-expected.txt (243347 => 243348)


--- trunk/LayoutTests/storage/indexeddb/clone-exception-expected.txt	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/storage/indexeddb/clone-exception-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -12,7 +12,7 @@
 PASS Exception was thrown.
 PASS code is 25
 PASS ename is 'DataCloneError'
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 
 doSecondOpen():
 indexedDB.open(dbname + '2')
@@ -22,7 +22,7 @@
 PASS Exception was thrown.
 PASS code is 25
 PASS ename is 'DataCloneError'
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 
 doThirdOpen():
 indexedDB.open(dbname + '3')
@@ -32,7 +32,7 @@
 PASS Exception was thrown.
 PASS code is 25
 PASS ename is 'DataCloneError'
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/storage/indexeddb/clone-exception-private-expected.txt (243347 => 243348)


--- trunk/LayoutTests/storage/indexeddb/clone-exception-private-expected.txt	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/storage/indexeddb/clone-exception-private-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -12,7 +12,7 @@
 PASS Exception was thrown.
 PASS code is 25
 PASS ename is 'DataCloneError'
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 
 doSecondOpen():
 indexedDB.open(dbname + '2')
@@ -22,7 +22,7 @@
 PASS Exception was thrown.
 PASS code is 25
 PASS ename is 'DataCloneError'
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 
 doThirdOpen():
 indexedDB.open(dbname + '3')
@@ -32,7 +32,7 @@
 PASS Exception was thrown.
 PASS code is 25
 PASS ename is 'DataCloneError'
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/storage/indexeddb/exceptions-expected.txt (243347 => 243348)


--- trunk/LayoutTests/storage/indexeddb/exceptions-expected.txt	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/storage/indexeddb/exceptions-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -159,7 +159,7 @@
 Expecting exception from store.add(self, 0)
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 
 IDBObjectStore.clear()
 This method throws a DOMException of type ReadOnlyError if the transaction which this IDBObjectStore belongs to is has its mode set to "readonly".
@@ -272,7 +272,7 @@
 Expecting exception from store.put(self, 0)
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 db.close()
 ro_transaction._oncomplete_ = transactionComplete
 rw_transaction._oncomplete_ = transactionComplete
@@ -504,7 +504,7 @@
 Expecting exception from cursor.update(self)
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 The transaction this IDBCursor belongs to is not active.
 Expecting exception from cursorFromInactiveTransaction.update({})
 PASS Exception was thrown.

Modified: trunk/LayoutTests/storage/indexeddb/exceptions-private-expected.txt (243347 => 243348)


--- trunk/LayoutTests/storage/indexeddb/exceptions-private-expected.txt	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/storage/indexeddb/exceptions-private-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -159,7 +159,7 @@
 Expecting exception from store.add(self, 0)
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 
 IDBObjectStore.clear()
 This method throws a DOMException of type ReadOnlyError if the transaction which this IDBObjectStore belongs to is has its mode set to "readonly".
@@ -272,7 +272,7 @@
 Expecting exception from store.put(self, 0)
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 db.close()
 ro_transaction._oncomplete_ = transactionComplete
 rw_transaction._oncomplete_ = transactionComplete
@@ -504,7 +504,7 @@
 Expecting exception from cursor.update(self)
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 The transaction this IDBCursor belongs to is not active.
 Expecting exception from cursorFromInactiveTransaction.update({})
 PASS Exception was thrown.

Modified: trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt (243347 => 243348)


--- trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -94,7 +94,7 @@
 Expecting exception from store.add({x: 'bar', y: self}, 'bar')
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 Try to insert data where key path yields a Date key:
 store.add({x: testDateB, y: 'value'}, 'key')
 addSuccess():

Modified: trunk/LayoutTests/storage/indexeddb/objectstore-basics-private-expected.txt (243347 => 243348)


--- trunk/LayoutTests/storage/indexeddb/objectstore-basics-private-expected.txt	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/storage/indexeddb/objectstore-basics-private-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -94,7 +94,7 @@
 Expecting exception from store.add({x: 'bar', y: self}, 'bar')
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 Try to insert data where key path yields a Date key:
 store.add({x: testDateB, y: 'value'}, 'key')
 addSuccess():

Modified: trunk/LayoutTests/storage/indexeddb/objectstore-basics-workers-expected.txt (243347 => 243348)


--- trunk/LayoutTests/storage/indexeddb/objectstore-basics-workers-expected.txt	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/storage/indexeddb/objectstore-basics-workers-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -95,7 +95,7 @@
 [Worker] Expecting exception from store.add({x: 'bar', y: self}, 'bar')
 PASS [Worker] Exception was thrown.
 PASS [Worker] code is DOMException.DATA_CLONE_ERR
-[Worker] Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+[Worker] Exception message: The object can not be cloned.
 [Worker] Try to insert data where key path yields a Date key:
 [Worker] store.add({x: testDateB, y: 'value'}, 'key')
 [Worker] addSuccess():

Modified: trunk/LayoutTests/storage/indexeddb/structured-clone-expected.txt (243347 => 243348)


--- trunk/LayoutTests/storage/indexeddb/structured-clone-expected.txt	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/storage/indexeddb/structured-clone-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -782,25 +782,25 @@
 Expecting exception from store.put(new Error, 'key')
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 Expecting exception from store.put(new Function, 'key')
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 
 Other host object types:
 Expecting exception from store.put(self, 'key')
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 Expecting exception from store.put(document, 'key')
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 Expecting exception from store.put(document.body, 'key')
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/storage/indexeddb/structured-clone-private-expected.txt (243347 => 243348)


--- trunk/LayoutTests/storage/indexeddb/structured-clone-private-expected.txt	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/storage/indexeddb/structured-clone-private-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -782,25 +782,25 @@
 Expecting exception from store.put(new Error, 'key')
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 Expecting exception from store.put(new Function, 'key')
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 
 Other host object types:
 Expecting exception from store.put(self, 'key')
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 Expecting exception from store.put(document, 'key')
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 Expecting exception from store.put(document.body, 'key')
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/storage/indexeddb/wasm-exceptions-expected.txt (243347 => 243348)


--- trunk/LayoutTests/storage/indexeddb/wasm-exceptions-expected.txt	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/LayoutTests/storage/indexeddb/wasm-exceptions-expected.txt	2019-03-22 00:03:31 UTC (rev 243348)
@@ -11,7 +11,7 @@
 Expecting exception from store.add(module, 'key')
 PASS Exception was thrown.
 PASS code is DOMException.DATA_CLONE_ERR
-Exception message: Failed to store record in an IDBObjectStore: An object could not be cloned.
+Exception message: The object can not be cloned.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/Source/WebCore/ChangeLog (243347 => 243348)


--- trunk/Source/WebCore/ChangeLog	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/Source/WebCore/ChangeLog	2019-03-22 00:03:31 UTC (rev 243348)
@@ -1,3 +1,31 @@
+2019-03-21  Sihui Liu  <[email protected]>
+
+        Fix key path extraction code in IndexedDB to check own property
+        https://bugs.webkit.org/show_bug.cgi?id=196099
+
+        Reviewed by Ryosuke Niwa.
+
+        Covered by existing tests.
+
+        * Modules/indexeddb/IDBFactory.cpp:
+        (WebCore::IDBFactory::cmp):
+        We don't need to check the second parameters if the first is already invalid.
+
+        * Modules/indexeddb/IDBKeyRange.cpp:
+        (WebCore::IDBKeyRange::bound):
+        Ditto.
+
+        * Modules/indexeddb/IDBObjectStore.cpp:
+        (WebCore::IDBObjectStore::putOrAdd):
+        we should not clear the exception during serialization because the execeptions may be explicitly thrown by parameters.
+
+        * bindings/js/IDBBindingUtilities.cpp:
+        (WebCore::get):
+        Fix implementation according to https://www.w3.org/TR/IndexedDB-2/#extract-key-from-value.
+
+        (WebCore::canInjectNthValueOnKeyPath):
+        Check the last identifier.
+
 2019-03-21  Antoine Quint  <[email protected]>
 
         [Web Animations] JS wrapper may be deleted while animation is yet to dispatch its finish event

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp (243347 => 243348)


--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp	2019-03-22 00:03:31 UTC (rev 243348)
@@ -123,9 +123,11 @@
 ExceptionOr<short> IDBFactory::cmp(ExecState& execState, JSValue firstValue, JSValue secondValue)
 {
     auto first = scriptValueToIDBKey(execState, firstValue);
+    if (!first->isValid())
+        return Exception { DataError, "Failed to execute 'cmp' on 'IDBFactory': The parameter is not a valid key."_s };
+
     auto second = scriptValueToIDBKey(execState, secondValue);
-
-    if (!first->isValid() || !second->isValid())
+    if (!second->isValid())
         return Exception { DataError, "Failed to execute 'cmp' on 'IDBFactory': The parameter is not a valid key."_s };
 
     return first->compare(second.get());

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.cpp (243347 => 243348)


--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.cpp	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.cpp	2019-03-22 00:03:31 UTC (rev 243348)
@@ -92,9 +92,10 @@
 ExceptionOr<Ref<IDBKeyRange>> IDBKeyRange::bound(ExecState& state, JSValue lowerValue, JSValue upperValue, bool lowerOpen, bool upperOpen)
 {
     auto lower = scriptValueToIDBKey(state, lowerValue);
+    if (!lower->isValid())
+        return Exception { DataError };
     auto upper = scriptValueToIDBKey(state, upperValue);
-
-    if (!lower->isValid() || !upper->isValid())
+    if (!upper->isValid())
         return Exception { DataError };
     if (upper->isLessThan(lower.get()))
         return Exception { DataError };

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp (243347 => 243348)


--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp	2019-03-22 00:03:31 UTC (rev 243348)
@@ -340,12 +340,8 @@
         return Exception { ReadonlyError, "Failed to store record in an IDBObjectStore: The transaction is read-only."_s };
 
     auto serializedValue = SerializedScriptValue::create(state, value);
-    if (UNLIKELY(scope.exception())) {
-        // Clear the DOM exception from the serializer so we can give a more targeted exception.
-        scope.clearException();
-
+    if (UNLIKELY(scope.exception()))
         return Exception { DataCloneError, "Failed to store record in an IDBObjectStore: An object could not be cloned."_s };
-    }
 
     bool privateBrowsingEnabled = false;
     if (is<Document>(*context)) {

Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp (243347 => 243348)


--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp	2019-03-21 23:55:39 UTC (rev 243347)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp	2019-03-22 00:03:31 UTC (rev 243348)
@@ -37,9 +37,11 @@
 #include "IDBKeyPath.h"
 #include "IDBValue.h"
 #include "IndexKey.h"
+#include "JSBlob.h"
 #include "JSDOMBinding.h"
 #include "JSDOMConvertDate.h"
 #include "JSDOMConvertNullable.h"
+#include "JSFile.h"
 #include "Logging.h"
 #include "MessagePort.h"
 #include "ScriptExecutionContext.h"
@@ -61,10 +63,46 @@
     }
     if (!object.isObject())
         return false;
+
+    auto* obj = asObject(object);
     Identifier identifier = Identifier::fromString(&exec.vm(), keyPathElement);
-    if (!asObject(object)->hasProperty(&exec, identifier))
+    auto& vm = exec.vm();
+    if (obj->inherits<JSArray>(vm) && keyPathElement == "length") {
+        result = obj->get(&exec, identifier);
+        return true;
+    }
+    if (obj->inherits<JSBlob>(vm) && (keyPathElement == "size" || keyPathElement == "type")) {
+        if (keyPathElement == "size") {
+            result = jsNumber(jsCast<JSBlob*>(obj)->wrapped().size());
+            return true;
+        }
+        if (keyPathElement == "type") {
+            result = jsString(&vm, jsCast<JSBlob*>(obj)->wrapped().type());
+            return true;
+        }
+    }
+    if (obj->inherits<JSFile>(vm)) {
+        if (keyPathElement == "name") {
+            result = jsString(&vm, jsCast<JSFile*>(obj)->wrapped().name());
+            return true;
+        }
+        if (keyPathElement == "lastModified") {
+            result = jsNumber(jsCast<JSFile*>(obj)->wrapped().lastModified());
+            return true;
+        }
+        if (keyPathElement == "lastModifiedDate") {
+            result = jsDate(exec, jsCast<JSFile*>(obj)->wrapped().lastModified());
+            return true;
+        }
+    }
+
+    PropertyDescriptor descriptor;
+    if (!obj->getOwnPropertyDescriptor(&exec, identifier, descriptor))
         return false;
-    result = asObject(object)->get(&exec, identifier);
+    if (!descriptor.enumerable())
+        return false;
+
+    result = obj->get(&exec, identifier);
     return true;
 }
 
@@ -255,7 +293,7 @@
     JSValue currentValue(rootValue);
 
     ASSERT(index <= keyPathElements.size());
-    for (size_t i = 0; i < index; ++i) {
+    for (size_t i = 0; i <= index; ++i) {
         JSValue parentValue(currentValue);
         const String& keyPathElement = keyPathElements[i];
         if (!get(exec, parentValue, keyPathElement, currentValue))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to