Changeset 243039 in webkit
- Timestamp:
- Mar 16, 2019 1:57:22 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r242818 r243039 1 2019-03-16 Sihui Liu <sihui_liu@apple.com> 2 3 Layout tests imported/w3c/web-platform-tests/IndexedDB/*-exception-order.html are failing 4 https://bugs.webkit.org/show_bug.cgi?id=195650 5 6 Reviewed by Ryosuke Niwa. 7 8 Updated test expectations to PASS. 9 10 * web-platform-tests/IndexedDB/idbdatabase-createObjectStore-exception-order-expected.txt: 11 * web-platform-tests/IndexedDB/idbdatabase-transaction-exception-order-expected.txt: 12 * web-platform-tests/IndexedDB/idbindex-query-exception-order-expected.txt: 13 * web-platform-tests/IndexedDB/idbobjectstore-delete-exception-order-expected.txt: 14 * web-platform-tests/IndexedDB/idbobjectstore-query-exception-order-expected.txt: 15 1 16 2019-03-12 Sihui Liu <sihui_liu@apple.com> 2 17 -
trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbdatabase-createObjectStore-exception-order-expected.txt
r219663 r243039 2 2 PASS IDBDatabase.createObjectStore exception order: InvalidStateError vs. TransactionInactiveError 3 3 PASS IDBDatabase.createObjectStore exception order: TransactionInactiveError vs. SyntaxError 4 FAIL IDBDatabase.createObjectStore exception order: SyntaxError vs. ConstraintError assert_throws: "Invalid key path" check (SyntaxError) should precede "duplicate store name" check (ConstraintError) function "() => { 5 db.createObjectStore('s', {keyPath: 'not a valid key path'}); 6 }" threw object "ConstraintError: Failed to execute 'createObjectStore' on 'IDBDatabase': An object store with the specified name already exists." that is not a DOMException SyntaxError: property "code" is equal to 0, expected 12 4 PASS IDBDatabase.createObjectStore exception order: SyntaxError vs. ConstraintError 7 5 PASS IDBDatabase.createObjectStore exception order: ConstraintError vs. InvalidAccessError 8 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbdatabase-transaction-exception-order-expected.txt
r215164 r243039 2 2 PASS IDBDatabase.transaction exception order: InvalidStateError vs. NotFoundError 3 3 PASS IDBDatabase.transaction exception order: InvalidStateError vs. InvalidAccessError 4 FAIL IDBDatabase.transaction exception order: NotFoundError vs. TypeError assert_throws: "No such store" check (NotFoundError) should precede "invalid mode" check (TypeError) function "() => { 5 db.transaction('no-such-store', 'versionchange'); 6 }" threw object "TypeError: Type error" that is not a DOMException NotFoundError: property "code" is equal to undefined, expected 8 4 PASS IDBDatabase.transaction exception order: NotFoundError vs. TypeError 7 5 -
trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbindex-query-exception-order-expected.txt
r219663 r243039 1 1 2 2 PASS IDBIndex.get exception order: InvalidStateError vs. TransactionInactiveError 3 FAIL IDBIndex.get exception order: TransactionInactiveError vs. DataError assert_throws: "not active" check (TransactionInactiveError) should precede query check (DataError) function "() => { index[method]({}); }" threw object "DataError: Failed to execute 'get' on 'IDBIndex': The parameter is not a valid key." that is not a DOMException TransactionInactiveError: property "name" is equal to "DataError", expected "TransactionInactiveError" 3 PASS IDBIndex.get exception order: TransactionInactiveError vs. DataError 4 4 PASS IDBIndex.getAll exception order: InvalidStateError vs. TransactionInactiveError 5 FAIL IDBIndex.getAll exception order: TransactionInactiveError vs. DataError assert_throws: "not active" check (TransactionInactiveError) should precede query check (DataError) function "() => { index[method]({}); }" threw object "DataError: Failed to execute 'getAll' on 'IDBIndex': The parameter is not a valid key." that is not a DOMException TransactionInactiveError: property "name" is equal to "DataError", expected "TransactionInactiveError" 5 PASS IDBIndex.getAll exception order: TransactionInactiveError vs. DataError 6 6 PASS IDBIndex.getAllKeys exception order: InvalidStateError vs. TransactionInactiveError 7 FAIL IDBIndex.getAllKeys exception order: TransactionInactiveError vs. DataError assert_throws: "not active" check (TransactionInactiveError) should precede query check (DataError) function "() => { index[method]({}); }" threw object "DataError: Failed to execute 'getAllKeys' on 'IDBIndex': The parameter is not a valid key." that is not a DOMException TransactionInactiveError: property "name" is equal to "DataError", expected "TransactionInactiveError" 7 PASS IDBIndex.getAllKeys exception order: TransactionInactiveError vs. DataError 8 8 PASS IDBIndex.count exception order: InvalidStateError vs. TransactionInactiveError 9 FAIL IDBIndex.count exception order: TransactionInactiveError vs. DataError assert_throws: "not active" check (TransactionInactiveError) should precede query check (DataError) function "() => { index[method]({}); }" threw object "DataError: Failed to execute 'count' on 'IDBIndex': The parameter is not a valid key." that is not a DOMException TransactionInactiveError: property "name" is equal to "DataError", expected "TransactionInactiveError" 9 PASS IDBIndex.count exception order: TransactionInactiveError vs. DataError 10 10 PASS IDBIndex.openCursor exception order: InvalidStateError vs. TransactionInactiveError 11 FAIL IDBIndex.openCursor exception order: TransactionInactiveError vs. DataError assert_throws: "not active" check (TransactionInactiveError) should precede query check (DataError) function "() => { index[method]({}); }" threw object "DataError: Failed to execute 'openCursor' on 'IDBIndex': The parameter is not a valid key." that is not a DOMException TransactionInactiveError: property "name" is equal to "DataError", expected "TransactionInactiveError" 11 PASS IDBIndex.openCursor exception order: TransactionInactiveError vs. DataError 12 12 PASS IDBIndex.openKeyCursor exception order: InvalidStateError vs. TransactionInactiveError 13 FAIL IDBIndex.openKeyCursor exception order: TransactionInactiveError vs. DataError assert_throws: "not active" check (TransactionInactiveError) should precede query check (DataError) function "() => { index[method]({}); }" threw object "DataError: Failed to execute 'openKeyCursor' on 'IDBIndex': The parameter is not a valid key." that is not a DOMException TransactionInactiveError: property "name" is equal to "DataError", expected "TransactionInactiveError" 13 PASS IDBIndex.openKeyCursor exception order: TransactionInactiveError vs. DataError 14 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-delete-exception-order-expected.txt
r219663 r243039 2 2 PASS IDBObjectStore.delete exception order: InvalidStateError vs. TransactionInactiveError 3 3 PASS IDBObjectStore.delete exception order: TransactionInactiveError vs. ReadOnlyError 4 FAIL IDBObjectStore.delete exception order: ReadOnlyError vs. DataError assert_throws: "read only" check (ReadOnlyError) should precede key/data check (DataError) function "() => { store.delete({}); }" threw object "DataError: Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key." that is not a DOMException ReadOnlyError: property "name" is equal to "DataError", expected "ReadOnlyError" 4 PASS IDBObjectStore.delete exception order: ReadOnlyError vs. DataError 5 5 -
trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-query-exception-order-expected.txt
r219663 r243039 3 3 PASS IDBObjectStore.get exception order: TransactionInactiveError vs. DataError 4 4 PASS IDBObjectStore.getAll exception order: InvalidStateError vs. TransactionInactiveError 5 FAIL IDBObjectStore.getAll exception order: TransactionInactiveError vs. DataError assert_throws: "not active" check (TransactionInactiveError) should precede query check (DataError) function "() => { store[method]({}); }" threw object "DataError: Failed to execute 'getAll' on 'IDBObjectStore': The parameter is not a valid key." that is not a DOMException TransactionInactiveError: property "name" is equal to "DataError", expected "TransactionInactiveError" 5 PASS IDBObjectStore.getAll exception order: TransactionInactiveError vs. DataError 6 6 PASS IDBObjectStore.getAllKeys exception order: InvalidStateError vs. TransactionInactiveError 7 FAIL IDBObjectStore.getAllKeys exception order: TransactionInactiveError vs. DataError assert_throws: "not active" check (TransactionInactiveError) should precede query check (DataError) function "() => { store[method]({}); }" threw object "DataError: Failed to execute 'getAllKeys' on 'IDBObjectStore': The parameter is not a valid key." that is not a DOMException TransactionInactiveError: property "name" is equal to "DataError", expected "TransactionInactiveError" 7 PASS IDBObjectStore.getAllKeys exception order: TransactionInactiveError vs. DataError 8 8 PASS IDBObjectStore.count exception order: InvalidStateError vs. TransactionInactiveError 9 FAIL IDBObjectStore.count exception order: TransactionInactiveError vs. DataError assert_throws: "not active" check (TransactionInactiveError) should precede query check (DataError) function "() => { store[method]({}); }" threw object "DataError: Failed to execute 'count' on 'IDBObjectStore': The parameter is not a valid key." that is not a DOMException TransactionInactiveError: property "name" is equal to "DataError", expected "TransactionInactiveError" 9 PASS IDBObjectStore.count exception order: TransactionInactiveError vs. DataError 10 10 PASS IDBObjectStore.openCursor exception order: InvalidStateError vs. TransactionInactiveError 11 FAIL IDBObjectStore.openCursor exception order: TransactionInactiveError vs. DataError assert_throws: "not active" check (TransactionInactiveError) should precede query check (DataError) function "() => { store[method]({}); }" threw object "DataError: Failed to execute 'openCursor' on 'IDBObjectStore': The parameter is not a valid key." that is not a DOMException TransactionInactiveError: property "name" is equal to "DataError", expected "TransactionInactiveError" 11 PASS IDBObjectStore.openCursor exception order: TransactionInactiveError vs. DataError 12 12 PASS IDBObjectStore.openKeyCursor exception order: InvalidStateError vs. TransactionInactiveError 13 FAIL IDBObjectStore.openKeyCursor exception order: TransactionInactiveError vs. DataError assert_throws: "not active" check (TransactionInactiveError) should precede query check (DataError) function "() => { store[method]({}); }" threw object "DataError: Failed to execute 'openKeyCursor' on 'IDBObjectStore': The parameter is not a valid key or key range." that is not a DOMException TransactionInactiveError: property "name" is equal to "DataError", expected "TransactionInactiveError" 13 PASS IDBObjectStore.openKeyCursor exception order: TransactionInactiveError vs. DataError 14 14 -
trunk/Source/WebCore/ChangeLog
r243037 r243039 1 2019-03-16 Sihui Liu <sihui_liu@apple.com> 2 3 Layout tests imported/w3c/web-platform-tests/IndexedDB/*-exception-order.html are failing 4 https://bugs.webkit.org/show_bug.cgi?id=195650 5 6 Reviewed by Ryosuke Niwa. 7 8 Fix some exception orders in IDB. 9 10 * Modules/indexeddb/IDBDatabase.cpp: 11 (WebCore::IDBDatabase::createObjectStore): 12 Step 6 of https://www.w3.org/TR/IndexedDB-2/#dom-idbdatabase-createobjectstore. 13 14 (WebCore::IDBDatabase::transaction): 15 Step 1 of https://www.w3.org/TR/IndexedDB-2/#dom-idbdatabase-transaction. 16 17 * Modules/indexeddb/IDBIndex.cpp: 18 (WebCore::IDBIndex::doOpenCursor): 19 (WebCore::IDBIndex::openCursor): 20 Step 5 of https://www.w3.org/TR/IndexedDB-2/#dom-idbindex-opencursor. 21 22 (WebCore::IDBIndex::doOpenKeyCursor): 23 (WebCore::IDBIndex::openKeyCursor): 24 Step 5 of https://www.w3.org/TR/IndexedDB-2/#dom-idbindex-openkeycursor. 25 26 (WebCore::IDBIndex::count): 27 Step 5 of https://www.w3.org/TR/IndexedDB-2/#dom-idbindex-count. 28 29 (WebCore::IDBIndex::doCount): 30 (WebCore::IDBIndex::get): 31 Step 5 of https://www.w3.org/TR/IndexedDB-2/#dom-idbindex-get. 32 33 (WebCore::IDBIndex::doGet): 34 (WebCore::IDBIndex::getKey): 35 Step 5 of https://www.w3.org/TR/IndexedDB-2/#dom-idbindex-getkey. 36 37 (WebCore::IDBIndex::doGetKey): 38 (WebCore::IDBIndex::doGetAll): 39 (WebCore::IDBIndex::getAll): 40 Step 5 of https://www.w3.org/TR/IndexedDB-2/#dom-idbindex-getkey. 41 (WebCore::IDBIndex::doGetAllKeys): 42 (WebCore::IDBIndex::getAllKeys): 43 Step 5 of https://www.w3.org/TR/IndexedDB-2/#dom-idbindex-getallkeys. 44 45 * Modules/indexeddb/IDBIndex.h: 46 * Modules/indexeddb/IDBObjectStore.cpp: 47 (WebCore::IDBObjectStore::doOpenCursor): 48 (WebCore::IDBObjectStore::openCursor): 49 Step 5 of https://www.w3.org/TR/IndexedDB-2/#dom-idbobjectstore-opencursor. 50 51 (WebCore::IDBObjectStore::doOpenKeyCursor): 52 (WebCore::IDBObjectStore::openKeyCursor): 53 Step 5 of https://www.w3.org/TR/IndexedDB-2/#dom-idbobjectstore-openkeycursor. 54 55 (WebCore::IDBObjectStore::deleteFunction): 56 (WebCore::IDBObjectStore::doDelete): 57 (WebCore::IDBObjectStore::count): 58 Step 5 of https://www.w3.org/TR/IndexedDB-2/#dom-idbobjectstore-count. 59 60 (WebCore::IDBObjectStore::doCount): 61 (WebCore::IDBObjectStore::doGetAll): 62 (WebCore::IDBObjectStore::getAll): 63 Step 5 of https://www.w3.org/TR/IndexedDB-2/#dom-idbobjectstore-getall. 64 65 (WebCore::IDBObjectStore::doGetAllKeys): 66 (WebCore::IDBObjectStore::getAllKeys): 67 Step 5 of https://www.w3.org/TR/IndexedDB-2/#dom-idbobjectstore-getallkeys. 68 * Modules/indexeddb/IDBObjectStore.h: 69 1 70 2019-03-16 Ryosuke Niwa <rniwa@webkit.org> 2 71 -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
r242110 r243039 145 145 return Exception { TransactionInactiveError }; 146 146 147 if (m_info.hasObjectStore(name))148 return Exception { ConstraintError, "Failed to execute 'createObjectStore' on 'IDBDatabase': An object store with the specified name already exists."_s };149 150 147 auto& keyPath = parameters.keyPath; 151 148 if (keyPath && !isIDBKeyPathValid(keyPath.value())) 152 149 return Exception { SyntaxError, "Failed to execute 'createObjectStore' on 'IDBDatabase': The keyPath option is not a valid key path."_s }; 153 150 151 if (m_info.hasObjectStore(name)) 152 return Exception { ConstraintError, "Failed to execute 'createObjectStore' on 'IDBDatabase': An object store with the specified name already exists."_s }; 153 154 154 if (keyPath && parameters.autoIncrement && ((WTF::holds_alternative<String>(keyPath.value()) && WTF::get<String>(keyPath.value()).isEmpty()) || WTF::holds_alternative<Vector<String>>(keyPath.value()))) 155 155 return Exception { InvalidAccessError, "Failed to execute 'createObjectStore' on 'IDBDatabase': The autoIncrement option was set but the keyPath option was empty or an array."_s }; … … 167 167 168 168 ASSERT(&originThread() == &Thread::current()); 169 170 if (m_versionChangeTransaction && !m_versionChangeTransaction->isFinishedOrFinishing()) 171 return Exception { InvalidStateError, "Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running."_s }; 169 172 170 173 if (m_closePending) … … 177 180 objectStores.append(WTFMove(WTF::get<String>(storeNames))); 178 181 179 if (objectStores.isEmpty())180 return Exception { InvalidAccessError, "Failed to execute 'transaction' on 'IDBDatabase': The storeNames parameter was empty."_s };181 182 if (mode != IDBTransactionMode::Readonly && mode != IDBTransactionMode::Readwrite)183 return Exception { TypeError };184 185 if (m_versionChangeTransaction && !m_versionChangeTransaction->isFinishedOrFinishing())186 return Exception { InvalidStateError, "Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running."_s };187 188 182 // It is valid for javascript to pass in a list of object store names with the same name listed twice, 189 183 // so we need to put them all in a set to get a unique list. … … 199 193 return Exception { NotFoundError, "Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found."_s }; 200 194 } 195 196 if (objectStores.isEmpty()) 197 return Exception { InvalidAccessError, "Failed to execute 'transaction' on 'IDBDatabase': The storeNames parameter was empty."_s }; 198 199 if (mode != IDBTransactionMode::Readonly && mode != IDBTransactionMode::Readwrite) 200 return Exception { TypeError }; 201 201 202 202 auto info = IDBTransactionInfo::clientTransaction(m_connectionProxy.get(), objectStores, mode); -
trunk/Source/WebCore/Modules/indexeddb/IDBIndex.cpp
r239427 r243039 149 149 } 150 150 151 ExceptionOr<Ref<IDBRequest>> IDBIndex:: openCursor(ExecState& execState, IDBKeyRange* range, IDBCursorDirection direction)151 ExceptionOr<Ref<IDBRequest>> IDBIndex::doOpenCursor(ExecState& execState, IDBCursorDirection direction, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function) 152 152 { 153 153 LOG(IndexedDB, "IDBIndex::openCursor"); … … 160 160 return Exception { TransactionInactiveError, "Failed to execute 'openCursor' on 'IDBIndex': The transaction is inactive or finished."_s }; 161 161 162 IDBKeyRangeData rangeData = range; 162 auto keyRange = function(); 163 if (keyRange.hasException()) 164 return keyRange.releaseException(); 165 166 IDBKeyRangeData rangeData = keyRange.returnValue() ? keyRange.releaseReturnValue().get() : nullptr; 163 167 if (rangeData.lowerKey.isNull()) 164 168 rangeData.lowerKey = IDBKeyData::minimum(); … … 170 174 } 171 175 176 ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(ExecState& execState, RefPtr<IDBKeyRange>&& range, IDBCursorDirection direction) 177 { 178 return doOpenCursor(execState, direction, [range=WTFMove(range)]() { 179 return range; 180 }); 181 } 182 172 183 ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(ExecState& execState, JSValue key, IDBCursorDirection direction) 173 184 { 174 LOG(IndexedDB, "IDBIndex::openCursor"); 175 ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current()); 176 177 auto keyRange = IDBKeyRange::only(execState, key); 178 if (keyRange.hasException()) 179 return Exception { DataError, "Failed to execute 'openCursor' on 'IDBIndex': The parameter is not a valid key."_s }; 180 181 return openCursor(execState, keyRange.releaseReturnValue().ptr(), direction); 182 } 183 184 ExceptionOr<Ref<IDBRequest>> IDBIndex::openKeyCursor(ExecState& execState, IDBKeyRange* range, IDBCursorDirection direction) 185 return doOpenCursor(execState, direction, [state=&execState, key]() { 186 auto onlyResult = IDBKeyRange::only(*state, key); 187 if (onlyResult.hasException()) 188 return ExceptionOr<RefPtr<IDBKeyRange>>{ Exception(DataError, "Failed to execute 'openCursor' on 'IDBIndex': The parameter is not a valid key."_s) }; 189 190 return ExceptionOr<RefPtr<IDBKeyRange>> { onlyResult.releaseReturnValue() }; 191 }); 192 } 193 194 ExceptionOr<Ref<IDBRequest>> IDBIndex::doOpenKeyCursor(ExecState& execState, IDBCursorDirection direction, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function) 185 195 { 186 196 LOG(IndexedDB, "IDBIndex::openKeyCursor"); … … 193 203 return Exception { TransactionInactiveError, "Failed to execute 'openKeyCursor' on 'IDBIndex': The transaction is inactive or finished."_s }; 194 204 195 auto info = IDBCursorInfo::indexCursor(m_objectStore.transaction(), m_objectStore.info().identifier(), m_info.identifier(), range, direction, IndexedDB::CursorType::KeyOnly); 205 auto keyRange = function(); 206 if (keyRange.hasException()) 207 return keyRange.releaseException(); 208 209 auto* keyRangePointer = keyRange.returnValue() ? keyRange.releaseReturnValue().get() : nullptr; 210 auto info = IDBCursorInfo::indexCursor(m_objectStore.transaction(), m_objectStore.info().identifier(), m_info.identifier(), keyRangePointer, direction, IndexedDB::CursorType::KeyOnly); 196 211 return m_objectStore.transaction().requestOpenCursor(execState, *this, info); 197 212 } 198 213 214 ExceptionOr<Ref<IDBRequest>> IDBIndex::openKeyCursor(ExecState& execState, RefPtr<IDBKeyRange>&& range, IDBCursorDirection direction) 215 { 216 return doOpenKeyCursor(execState, direction, [range=WTFMove(range)]() { 217 return range; 218 }); 219 } 220 199 221 ExceptionOr<Ref<IDBRequest>> IDBIndex::openKeyCursor(ExecState& execState, JSValue key, IDBCursorDirection direction) 200 222 { 201 LOG(IndexedDB, "IDBIndex::openKeyCursor"); 202 203 auto keyRange = IDBKeyRange::only(execState, key); 204 if (keyRange.hasException()) 205 return Exception { DataError, "Failed to execute 'openKeyCursor' on 'IDBIndex': The parameter is not a valid key."_s }; 206 return openKeyCursor(execState, keyRange.releaseReturnValue().ptr(), direction); 223 return doOpenKeyCursor(execState, direction, [state=&execState, key]() { 224 auto onlyResult = IDBKeyRange::only(*state, key); 225 if (onlyResult.hasException()) 226 return ExceptionOr<RefPtr<IDBKeyRange>>{ Exception(DataError, "Failed to execute 'openKeyCursor' on 'IDBIndex': The parameter is not a valid key."_s) }; 227 228 return ExceptionOr<RefPtr<IDBKeyRange>> { onlyResult.releaseReturnValue() }; 229 }); 207 230 } 208 231 … … 219 242 220 243 auto idbKey = scriptValueToIDBKey(execState, key); 221 if (!idbKey->isValid()) 222 return Exception { DataError, "Failed to execute 'count' on 'IDBIndex': The parameter is not a valid key."_s }; 223 224 return doCount(execState, IDBKeyRangeData(idbKey.ptr())); 244 auto* idbKeyPointer = idbKey->isValid() ? idbKey.ptr() : nullptr; 245 246 return doCount(execState, IDBKeyRangeData(idbKeyPointer)); 225 247 } 226 248 … … 231 253 if (m_deleted || m_objectStore.isDeleted()) 232 254 return Exception { InvalidStateError, "Failed to execute 'count' on 'IDBIndex': The index or its object store has been deleted."_s }; 233 234 if (!range.isValid())235 return Exception { DataError };236 255 237 256 auto& transaction = m_objectStore.transaction(); … … 239 258 return Exception { TransactionInactiveError, "Failed to execute 'count' on 'IDBIndex': The transaction is inactive or finished."_s }; 240 259 260 if (!range.isValid()) 261 return Exception { DataError, "Failed to execute 'count' on 'IDBIndex': The parameter is not a valid key."_s }; 262 241 263 return transaction.requestCount(execState, *this, range); 242 264 } … … 255 277 auto idbKey = scriptValueToIDBKey(execState, key); 256 278 if (!idbKey->isValid()) 257 return Exception { DataError, "Failed to execute 'get' on 'IDBIndex': The parameter is not a valid key."_s };279 return doGet(execState, Exception(DataError, "Failed to execute 'get' on 'IDBIndex': The parameter is not a valid key."_s)); 258 280 259 281 return doGet(execState, IDBKeyRangeData(idbKey.ptr())); 260 282 } 261 283 262 ExceptionOr<Ref<IDBRequest>> IDBIndex::doGet(ExecState& execState, const IDBKeyRangeData&range)284 ExceptionOr<Ref<IDBRequest>> IDBIndex::doGet(ExecState& execState, ExceptionOr<IDBKeyRangeData> range) 263 285 { 264 286 ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current()); … … 266 288 if (m_deleted || m_objectStore.isDeleted()) 267 289 return Exception { InvalidStateError, "Failed to execute 'get' on 'IDBIndex': The index or its object store has been deleted."_s }; 268 269 if (range.isNull)270 return Exception { DataError };271 290 272 291 auto& transaction = m_objectStore.transaction(); … … 274 293 return Exception { TransactionInactiveError, "Failed to execute 'get' on 'IDBIndex': The transaction is inactive or finished."_s }; 275 294 276 return transaction.requestGetValue(execState, *this, range); 295 if (range.hasException()) 296 return range.releaseException(); 297 auto keyRange = range.releaseReturnValue(); 298 299 if (keyRange.isNull) 300 return Exception { DataError }; 301 302 return transaction.requestGetValue(execState, *this, keyRange); 277 303 } 278 304 … … 290 316 auto idbKey = scriptValueToIDBKey(execState, key); 291 317 if (!idbKey->isValid()) 292 return Exception { DataError, "Failed to execute 'getKey' on 'IDBIndex': The parameter is not a valid key."_s };318 return doGetKey(execState, Exception(DataError, "Failed to execute 'getKey' on 'IDBIndex': The parameter is not a valid key."_s)); 293 319 294 320 return doGetKey(execState, IDBKeyRangeData(idbKey.ptr())); 295 321 } 296 322 297 ExceptionOr<Ref<IDBRequest>> IDBIndex::doGetKey(ExecState& execState, const IDBKeyRangeData&range)323 ExceptionOr<Ref<IDBRequest>> IDBIndex::doGetKey(ExecState& execState, ExceptionOr<IDBKeyRangeData> range) 298 324 { 299 325 ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current()); … … 301 327 if (m_deleted || m_objectStore.isDeleted()) 302 328 return Exception { InvalidStateError, "Failed to execute 'getKey' on 'IDBIndex': The index or its object store has been deleted."_s }; 303 304 if (range.isNull)305 return Exception { DataError };306 329 307 330 auto& transaction = m_objectStore.transaction(); … … 309 332 return Exception { TransactionInactiveError, "Failed to execute 'getKey' on 'IDBIndex': The transaction is inactive or finished."_s }; 310 333 311 return transaction.requestGetKey(execState, *this, range); 312 } 313 314 ExceptionOr<Ref<IDBRequest>> IDBIndex::getAll(ExecState& execState, RefPtr<IDBKeyRange> range, Optional<uint32_t> count) 334 if (range.hasException()) 335 return range.releaseException(); 336 auto keyRange = range.releaseReturnValue(); 337 338 if (keyRange.isNull) 339 return Exception { DataError }; 340 341 return transaction.requestGetKey(execState, *this, keyRange); 342 } 343 344 ExceptionOr<Ref<IDBRequest>> IDBIndex::doGetAll(ExecState& execState, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function) 315 345 { 316 346 LOG(IndexedDB, "IDBIndex::getAll"); … … 323 353 return Exception { TransactionInactiveError, "Failed to execute 'getAll' on 'IDBIndex': The transaction is inactive or finished."_s }; 324 354 325 return m_objectStore.transaction().requestGetAllIndexRecords(execState, *this, range.get(), IndexedDB::GetAllType::Values, count); 355 auto keyRange = function(); 356 if (keyRange.hasException()) 357 return keyRange.releaseException(); 358 359 auto* keyRangePointer = keyRange.returnValue() ? keyRange.releaseReturnValue().get() : nullptr; 360 return m_objectStore.transaction().requestGetAllIndexRecords(execState, *this, keyRangePointer, IndexedDB::GetAllType::Values, count); 361 } 362 363 ExceptionOr<Ref<IDBRequest>> IDBIndex::getAll(ExecState& execState, RefPtr<IDBKeyRange>&& range, Optional<uint32_t> count) 364 { 365 return doGetAll(execState, count, [range = WTFMove(range)]() { 366 return range; 367 }); 326 368 } 327 369 328 370 ExceptionOr<Ref<IDBRequest>> IDBIndex::getAll(ExecState& execState, JSValue key, Optional<uint32_t> count) 329 371 { 330 auto onlyResult = IDBKeyRange::only(execState, key); 331 if (onlyResult.hasException()) 332 return Exception { DataError, "Failed to execute 'getAll' on 'IDBIndex': The parameter is not a valid key."_s }; 333 334 return getAll(execState, onlyResult.releaseReturnValue(), count); 335 } 336 337 ExceptionOr<Ref<IDBRequest>> IDBIndex::getAllKeys(ExecState& execState, RefPtr<IDBKeyRange> range, Optional<uint32_t> count) 372 return doGetAll(execState, count, [state=&execState, key]() { 373 auto onlyResult = IDBKeyRange::only(*state, key); 374 if (onlyResult.hasException()) 375 return ExceptionOr<RefPtr<IDBKeyRange>>{ Exception(DataError, "Failed to execute 'getAll' on 'IDBIndex': The parameter is not a valid key."_s) }; 376 377 return ExceptionOr<RefPtr<IDBKeyRange>> { onlyResult.releaseReturnValue() }; 378 }); 379 } 380 381 ExceptionOr<Ref<IDBRequest>> IDBIndex::doGetAllKeys(ExecState& execState, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function) 338 382 { 339 383 LOG(IndexedDB, "IDBIndex::getAllKeys"); … … 346 390 return Exception { TransactionInactiveError, "Failed to execute 'getAllKeys' on 'IDBIndex': The transaction is inactive or finished."_s }; 347 391 348 return m_objectStore.transaction().requestGetAllIndexRecords(execState, *this, range.get(), IndexedDB::GetAllType::Keys, count); 392 auto keyRange = function(); 393 if (keyRange.hasException()) 394 return keyRange.releaseException(); 395 396 auto* keyRangePointer = keyRange.returnValue() ? keyRange.releaseReturnValue().get() : nullptr; 397 return m_objectStore.transaction().requestGetAllIndexRecords(execState, *this, keyRangePointer, IndexedDB::GetAllType::Keys, count); 398 } 399 400 ExceptionOr<Ref<IDBRequest>> IDBIndex::getAllKeys(ExecState& execState, RefPtr<IDBKeyRange>&& range, Optional<uint32_t> count) 401 { 402 return doGetAllKeys(execState, count, [range = WTFMove(range)]() { 403 return range; 404 }); 349 405 } 350 406 351 407 ExceptionOr<Ref<IDBRequest>> IDBIndex::getAllKeys(ExecState& execState, JSValue key, Optional<uint32_t> count) 352 408 { 353 auto onlyResult = IDBKeyRange::only(execState, key); 354 if (onlyResult.hasException()) 355 return Exception { DataError, "Failed to execute 'getAllKeys' on 'IDBIndex': The parameter is not a valid key."_s }; 356 357 return getAllKeys(execState, onlyResult.releaseReturnValue(), count); 409 return doGetAllKeys(execState, count, [state=&execState, key]() { 410 auto onlyResult = IDBKeyRange::only(*state, key); 411 if (onlyResult.hasException()) 412 return ExceptionOr<RefPtr<IDBKeyRange>>{ Exception(DataError, "Failed to execute 'getAllKeys' on 'IDBIndex': The parameter is not a valid key."_s) }; 413 414 return ExceptionOr<RefPtr<IDBKeyRange>> { onlyResult.releaseReturnValue() }; 415 }); 358 416 } 359 417 -
trunk/Source/WebCore/Modules/indexeddb/IDBIndex.h
r239427 r243039 59 59 void rollbackInfoForVersionChangeAbort(); 60 60 61 ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, IDBKeyRange*, IDBCursorDirection);61 ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, RefPtr<IDBKeyRange>&&, IDBCursorDirection); 62 62 ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, JSC::JSValue key, IDBCursorDirection); 63 ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, IDBKeyRange*, IDBCursorDirection);63 ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, RefPtr<IDBKeyRange>&&, IDBCursorDirection); 64 64 ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, JSC::JSValue key, IDBCursorDirection); 65 65 … … 72 72 ExceptionOr<Ref<IDBRequest>> getKey(JSC::ExecState&, JSC::JSValue key); 73 73 74 ExceptionOr<Ref<IDBRequest>> getAll(JSC::ExecState&, RefPtr<IDBKeyRange> , Optional<uint32_t> count);74 ExceptionOr<Ref<IDBRequest>> getAll(JSC::ExecState&, RefPtr<IDBKeyRange>&&, Optional<uint32_t> count); 75 75 ExceptionOr<Ref<IDBRequest>> getAll(JSC::ExecState&, JSC::JSValue key, Optional<uint32_t> count); 76 ExceptionOr<Ref<IDBRequest>> getAllKeys(JSC::ExecState&, RefPtr<IDBKeyRange> , Optional<uint32_t> count);76 ExceptionOr<Ref<IDBRequest>> getAllKeys(JSC::ExecState&, RefPtr<IDBKeyRange>&&, Optional<uint32_t> count); 77 77 ExceptionOr<Ref<IDBRequest>> getAllKeys(JSC::ExecState&, JSC::JSValue key, Optional<uint32_t> count); 78 78 … … 89 89 private: 90 90 ExceptionOr<Ref<IDBRequest>> doCount(JSC::ExecState&, const IDBKeyRangeData&); 91 ExceptionOr<Ref<IDBRequest>> doGet(JSC::ExecState&, const IDBKeyRangeData&); 92 ExceptionOr<Ref<IDBRequest>> doGetKey(JSC::ExecState&, const IDBKeyRangeData&); 91 ExceptionOr<Ref<IDBRequest>> doGet(JSC::ExecState&, ExceptionOr<IDBKeyRangeData>); 92 ExceptionOr<Ref<IDBRequest>> doGetKey(JSC::ExecState&, ExceptionOr<IDBKeyRangeData>); 93 ExceptionOr<Ref<IDBRequest>> doOpenCursor(JSC::ExecState&, IDBCursorDirection, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()> &&); 94 ExceptionOr<Ref<IDBRequest>> doOpenKeyCursor(JSC::ExecState&, IDBCursorDirection, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()> &&); 95 ExceptionOr<Ref<IDBRequest>> doGetAll(JSC::ExecState&, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()> &&); 96 ExceptionOr<Ref<IDBRequest>> doGetAllKeys(JSC::ExecState&, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()> &&); 93 97 94 98 const char* activeDOMObjectName() const final; -
trunk/Source/WebCore/Modules/indexeddb/IDBKey.h
r236007 r243039 86 86 } 87 87 } 88 Ref<IDBKey>idbKey = adoptRef(*new IDBKey(result, sizeEstimate));88 auto idbKey = adoptRef(*new IDBKey(result, sizeEstimate)); 89 89 ASSERT(idbKey->isValid()); 90 90 return idbKey; -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
r241196 r243039 150 150 } 151 151 152 ExceptionOr<Ref<IDBRequest>> IDBObjectStore:: openCursor(ExecState& execState, RefPtr<IDBKeyRange> range, IDBCursorDirection direction)152 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doOpenCursor(ExecState& execState, IDBCursorDirection direction, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function) 153 153 { 154 154 LOG(IndexedDB, "IDBObjectStore::openCursor"); … … 161 161 return Exception { TransactionInactiveError, "Failed to execute 'openCursor' on 'IDBObjectStore': The transaction is inactive or finished."_s }; 162 162 163 auto info = IDBCursorInfo::objectStoreCursor(m_transaction, m_info.identifier(), range.get(), direction, IndexedDB::CursorType::KeyAndValue); 163 auto keyRange = function(); 164 if (keyRange.hasException()) 165 return keyRange.releaseException(); 166 auto* keyRangePointer = keyRange.returnValue() ? keyRange.releaseReturnValue().get() : nullptr; 167 168 auto info = IDBCursorInfo::objectStoreCursor(m_transaction, m_info.identifier(), keyRangePointer, direction, IndexedDB::CursorType::KeyAndValue); 164 169 return m_transaction.requestOpenCursor(execState, *this, info); 165 170 } 166 171 172 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openCursor(ExecState& execState, RefPtr<IDBKeyRange>&& range, IDBCursorDirection direction) 173 { 174 return doOpenCursor(execState, direction, [range = WTFMove(range)]() { 175 return range; 176 }); 177 } 178 167 179 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openCursor(ExecState& execState, JSValue key, IDBCursorDirection direction) 168 180 { 169 auto onlyResult = IDBKeyRange::only(execState, key); 170 if (onlyResult.hasException()) 171 return Exception { DataError, "Failed to execute 'openCursor' on 'IDBObjectStore': The parameter is not a valid key."_s }; 172 173 return openCursor(execState, onlyResult.releaseReturnValue(), direction); 174 } 175 176 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openKeyCursor(ExecState& execState, RefPtr<IDBKeyRange> range, IDBCursorDirection direction) 177 { 178 LOG(IndexedDB, "IDBObjectStore::openCursor"); 181 return doOpenCursor(execState, direction, [state=&execState, key]() { 182 auto onlyResult = IDBKeyRange::only(*state, key); 183 if (onlyResult.hasException()) 184 return ExceptionOr<RefPtr<IDBKeyRange>>{ Exception(DataError, "Failed to execute 'openCursor' on 'IDBObjectStore': The parameter is not a valid key."_s) }; 185 186 return ExceptionOr<RefPtr<IDBKeyRange>> { onlyResult.releaseReturnValue() }; 187 }); 188 } 189 190 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doOpenKeyCursor(ExecState& execState, IDBCursorDirection direction, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function) 191 { 192 LOG(IndexedDB, "IDBObjectStore::openKeyCursor"); 179 193 ASSERT(&m_transaction.database().originThread() == &Thread::current()); 180 194 … … 185 199 return Exception { TransactionInactiveError, "Failed to execute 'openKeyCursor' on 'IDBObjectStore': The transaction is inactive or finished."_s }; 186 200 187 auto info = IDBCursorInfo::objectStoreCursor(m_transaction, m_info.identifier(), range.get(), direction, IndexedDB::CursorType::KeyOnly); 201 auto keyRange = function(); 202 if (keyRange.hasException()) 203 return keyRange.releaseException(); 204 205 auto* keyRangePointer = keyRange.returnValue() ? keyRange.releaseReturnValue().get() : nullptr; 206 auto info = IDBCursorInfo::objectStoreCursor(m_transaction, m_info.identifier(), keyRangePointer, direction, IndexedDB::CursorType::KeyOnly); 188 207 return m_transaction.requestOpenCursor(execState, *this, info); 189 208 } 190 209 210 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openKeyCursor(ExecState& execState, RefPtr<IDBKeyRange>&& range, IDBCursorDirection direction) 211 { 212 return doOpenKeyCursor(execState, direction, [range = WTFMove(range)]() { 213 return range; 214 }); 215 } 216 191 217 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openKeyCursor(ExecState& execState, JSValue key, IDBCursorDirection direction) 192 218 { 193 auto onlyResult = IDBKeyRange::only(execState, key); 194 if (onlyResult.hasException()) 195 return Exception { DataError, "Failed to execute 'openKeyCursor' on 'IDBObjectStore': The parameter is not a valid key or key range."_s }; 196 197 return openKeyCursor(execState, onlyResult.releaseReturnValue(), direction); 219 return doOpenCursor(execState, direction, [state=&execState, key]() { 220 auto onlyResult = IDBKeyRange::only(*state, key); 221 if (onlyResult.hasException()) 222 return ExceptionOr<RefPtr<IDBKeyRange>>{ Exception(DataError, "Failed to execute 'openKeyCursor' on 'IDBObjectStore': The parameter is not a valid key."_s) }; 223 224 return ExceptionOr<RefPtr<IDBKeyRange>> { onlyResult.releaseReturnValue() }; 225 }); 198 226 } 199 227 … … 363 391 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::deleteFunction(ExecState& execState, IDBKeyRange* keyRange) 364 392 { 365 return doDelete(execState, keyRange); 366 } 367 368 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doDelete(ExecState& execState, IDBKeyRange* keyRange) 393 return doDelete(execState, [keyRange]() { 394 return makeRefPtr(keyRange); 395 }); 396 } 397 398 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doDelete(ExecState& execState, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function) 369 399 { 370 400 LOG(IndexedDB, "IDBObjectStore::deleteFunction"); … … 385 415 return Exception { ReadonlyError, "Failed to execute 'delete' on 'IDBObjectStore': The transaction is read-only."_s }; 386 416 387 IDBKeyRangeData keyRangeData(keyRange); 417 auto keyRange = function(); 418 if (keyRange.hasException()) 419 return keyRange.releaseException(); 420 421 IDBKeyRangeData keyRangeData = keyRange.returnValue() ? keyRange.releaseReturnValue().get() : nullptr; 388 422 if (!keyRangeData.isValid()) 389 423 return Exception { DataError, "Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key range."_s }; … … 394 428 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::deleteFunction(ExecState& execState, JSValue key) 395 429 { 396 Ref<IDBKey> idbKey = scriptValueToIDBKey(execState, key); 397 if (!idbKey->isValid()) 398 return Exception { DataError, "Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key."_s }; 399 return doDelete(execState, IDBKeyRange::create(WTFMove(idbKey)).ptr()); 430 return doDelete(execState, [state=&execState, key]() { 431 auto idbKey = scriptValueToIDBKey(*state, key); 432 if (!idbKey->isValid()) 433 return ExceptionOr<RefPtr<IDBKeyRange>>{ Exception(DataError, "Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key."_s) }; 434 return ExceptionOr<RefPtr<IDBKeyRange>> { (IDBKeyRange::create(WTFMove(idbKey))).ptr() }; 435 }); 400 436 } 401 437 … … 536 572 LOG(IndexedDB, "IDBObjectStore::count"); 537 573 538 Ref<IDBKey> idbKey = scriptValueToIDBKey(execState, key); 539 if (!idbKey->isValid()) 540 return Exception { DataError, "Failed to execute 'count' on 'IDBObjectStore': The parameter is not a valid key."_s }; 541 542 return doCount(execState, IDBKeyRangeData(idbKey.ptr())); 574 auto idbKey = scriptValueToIDBKey(execState, key); 575 576 return doCount(execState, IDBKeyRangeData(idbKey->isValid() ? idbKey.ptr() : nullptr)); 543 577 } 544 578 … … 566 600 567 601 if (!range.isValid()) 568 return Exception { DataError };602 return Exception { DataError, "Failed to execute 'count' on 'IDBObjectStore': The parameter is not a valid key."_s }; 569 603 570 604 return m_transaction.requestCount(execState, *this, range); 571 605 } 572 606 573 ExceptionOr<Ref<IDBRequest>> IDBObjectStore:: getAll(ExecState& execState, RefPtr<IDBKeyRange> range, Optional<uint32_t> count)607 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doGetAll(ExecState& execState, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function) 574 608 { 575 609 LOG(IndexedDB, "IDBObjectStore::getAll"); … … 582 616 return Exception { TransactionInactiveError, "Failed to execute 'getAll' on 'IDBObjectStore': The transaction is inactive or finished."_s }; 583 617 584 return m_transaction.requestGetAllObjectStoreRecords(execState, *this, range.get(), IndexedDB::GetAllType::Values, count); 618 auto keyRange = function(); 619 if (keyRange.hasException()) 620 return keyRange.releaseException(); 621 622 auto* keyRangePointer = keyRange.returnValue() ? keyRange.releaseReturnValue().get() : nullptr; 623 return m_transaction.requestGetAllObjectStoreRecords(execState, *this, keyRangePointer, IndexedDB::GetAllType::Values, count); 624 } 625 626 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getAll(ExecState& execState, RefPtr<IDBKeyRange>&& range, Optional<uint32_t> count) 627 { 628 return doGetAll(execState, count, [range = WTFMove(range)]() { 629 return range; 630 }); 585 631 } 586 632 587 633 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getAll(ExecState& execState, JSValue key, Optional<uint32_t> count) 588 634 { 589 auto onlyResult = IDBKeyRange::only(execState, key); 590 if (onlyResult.hasException()) 591 return Exception { DataError, "Failed to execute 'getAll' on 'IDBObjectStore': The parameter is not a valid key."_s }; 592 593 return getAll(execState, onlyResult.releaseReturnValue(), count); 594 } 595 596 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getAllKeys(ExecState& execState, RefPtr<IDBKeyRange> range, Optional<uint32_t> count) 635 return doGetAll(execState, count, [state=&execState, key]() { 636 auto onlyResult = IDBKeyRange::only(*state, key); 637 if (onlyResult.hasException()) 638 return ExceptionOr<RefPtr<IDBKeyRange>>{ Exception(DataError, "Failed to execute 'getAll' on 'IDBObjectStore': The parameter is not a valid key."_s) }; 639 640 return ExceptionOr<RefPtr<IDBKeyRange>> { onlyResult.releaseReturnValue() }; 641 }); 642 } 643 644 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doGetAllKeys(ExecState& execState, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function) 597 645 { 598 646 LOG(IndexedDB, "IDBObjectStore::getAllKeys"); … … 605 653 return Exception { TransactionInactiveError, "Failed to execute 'getAllKeys' on 'IDBObjectStore': The transaction is inactive or finished."_s }; 606 654 607 return m_transaction.requestGetAllObjectStoreRecords(execState, *this, range.get(), IndexedDB::GetAllType::Keys, count); 655 auto keyRange = function(); 656 if (keyRange.hasException()) 657 return keyRange.releaseException(); 658 659 auto* keyRangePointer = keyRange.returnValue() ? keyRange.releaseReturnValue().get() : nullptr; 660 return m_transaction.requestGetAllObjectStoreRecords(execState, *this, keyRangePointer, IndexedDB::GetAllType::Keys, count); 661 } 662 663 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getAllKeys(ExecState& execState, RefPtr<IDBKeyRange>&& range, Optional<uint32_t> count) 664 { 665 return doGetAllKeys(execState, count, [range = WTFMove(range)]() { 666 return range; 667 }); 608 668 } 609 669 610 670 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getAllKeys(ExecState& execState, JSValue key, Optional<uint32_t> count) 611 671 { 612 auto onlyResult = IDBKeyRange::only(execState, key); 613 if (onlyResult.hasException()) 614 return Exception { DataError, "Failed to execute 'getAllKeys' on 'IDBObjectStore': The parameter is not a valid key."_s }; 615 616 return getAllKeys(execState, onlyResult.releaseReturnValue(), count); 672 return doGetAllKeys(execState, count, [state=&execState, key]() { 673 auto onlyResult = IDBKeyRange::only(*state, key); 674 if (onlyResult.hasException()) 675 return ExceptionOr<RefPtr<IDBKeyRange>>{ Exception(DataError, "Failed to execute 'getAllKeys' on 'IDBObjectStore': The parameter is not a valid key."_s) }; 676 677 return ExceptionOr<RefPtr<IDBKeyRange>> { onlyResult.releaseReturnValue() }; 678 }); 617 679 } 618 680 -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h
r241196 r243039 74 74 }; 75 75 76 ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, RefPtr<IDBKeyRange> , IDBCursorDirection);76 ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, RefPtr<IDBKeyRange>&&, IDBCursorDirection); 77 77 ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, JSC::JSValue key, IDBCursorDirection); 78 ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, RefPtr<IDBKeyRange> , IDBCursorDirection);78 ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, RefPtr<IDBKeyRange>&&, IDBCursorDirection); 79 79 ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, JSC::JSValue key, IDBCursorDirection); 80 80 ExceptionOr<Ref<IDBRequest>> get(JSC::ExecState&, JSC::JSValue key); … … 92 92 ExceptionOr<Ref<IDBRequest>> count(JSC::ExecState&, IDBKeyRange*); 93 93 ExceptionOr<Ref<IDBRequest>> count(JSC::ExecState&, JSC::JSValue key); 94 ExceptionOr<Ref<IDBRequest>> getAll(JSC::ExecState&, RefPtr<IDBKeyRange> , Optional<uint32_t> count);94 ExceptionOr<Ref<IDBRequest>> getAll(JSC::ExecState&, RefPtr<IDBKeyRange>&&, Optional<uint32_t> count); 95 95 ExceptionOr<Ref<IDBRequest>> getAll(JSC::ExecState&, JSC::JSValue key, Optional<uint32_t> count); 96 ExceptionOr<Ref<IDBRequest>> getAllKeys(JSC::ExecState&, RefPtr<IDBKeyRange> , Optional<uint32_t> count);96 ExceptionOr<Ref<IDBRequest>> getAllKeys(JSC::ExecState&, RefPtr<IDBKeyRange>&&, Optional<uint32_t> count); 97 97 ExceptionOr<Ref<IDBRequest>> getAllKeys(JSC::ExecState&, JSC::JSValue key, Optional<uint32_t> count); 98 98 … … 116 116 ExceptionOr<Ref<IDBRequest>> putOrAdd(JSC::ExecState&, JSC::JSValue, RefPtr<IDBKey>, IndexedDB::ObjectStoreOverwriteMode, InlineKeyCheck); 117 117 ExceptionOr<Ref<IDBRequest>> doCount(JSC::ExecState&, const IDBKeyRangeData&); 118 ExceptionOr<Ref<IDBRequest>> doDelete(JSC::ExecState&, IDBKeyRange*); 118 ExceptionOr<Ref<IDBRequest>> doDelete(JSC::ExecState&, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()> &&); 119 ExceptionOr<Ref<IDBRequest>> doOpenCursor(JSC::ExecState&, IDBCursorDirection, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&&); 120 ExceptionOr<Ref<IDBRequest>> doOpenKeyCursor(JSC::ExecState&, IDBCursorDirection, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&&); 121 ExceptionOr<Ref<IDBRequest>> doGetAll(JSC::ExecState&, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()> &&); 122 ExceptionOr<Ref<IDBRequest>> doGetAllKeys(JSC::ExecState&, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()> &&); 119 123 120 124 const char* activeDOMObjectName() const final;
Note: See TracChangeset
for help on using the changeset viewer.