WebKit Bugzilla
Attachment 361349 Details for
Bug 189435
: IndexedDB tests leak documents
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189435-20190206173644.patch (text/plain), 30.60 KB, created by
Sihui Liu
on 2019-02-06 17:36:45 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Sihui Liu
Created:
2019-02-06 17:36:45 PST
Size:
30.60 KB
patch
obsolete
>Subversion Revision: 240850 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index f5995799fcff27682e84d143433aff35d4be80cc..1458890f5cccf8d811e6cc13ebff22fda39db73a 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,53 @@ >+2019-02-06 Sihui Liu <sihui_liu@apple.com> >+ >+ IndexedDB tests leak documents >+ https://bugs.webkit.org/show_bug.cgi?id=189435 >+ <rdar://problem/44240043> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Remove use of JSC::Strong in IndexedDatabase. >+ >+ * Modules/indexeddb/IDBCursor.cpp: >+ (WebCore::IDBCursor::update): >+ (WebCore::IDBCursor::deleteFunction): >+ (WebCore::IDBCursor::setGetResult): >+ (WebCore::IDBCursor::key): >+ (WebCore::IDBCursor::primaryKey): >+ (WebCore::IDBCursor::value): >+ * Modules/indexeddb/IDBCursor.h: >+ (WebCore::IDBCursor::cachedKey): >+ (WebCore::IDBCursor::cachedPrimaryKey): >+ (WebCore::IDBCursor::cachedValue): >+ (WebCore::IDBCursor::key const): Deleted. >+ (WebCore::IDBCursor::primaryKey const): Deleted. >+ (WebCore::IDBCursor::value const): Deleted. >+ * Modules/indexeddb/IDBCursor.idl: >+ * Modules/indexeddb/IDBCursorWithValue.idl: >+ * Modules/indexeddb/IDBRequest.cpp: >+ (WebCore::IDBRequest::IDBRequest): >+ (WebCore::IDBRequest::~IDBRequest): >+ (WebCore::IDBRequest::result const): >+ (WebCore::IDBRequest::setResult): >+ (WebCore::IDBRequest::setResultToStructuredClone): >+ (WebCore::IDBRequest::setResultToUndefined): >+ (WebCore::IDBRequest::resultCursor): >+ (WebCore::IDBRequest::willIterateCursor): >+ (WebCore::IDBRequest::didOpenOrIterateCursor): >+ * Modules/indexeddb/IDBRequest.h: >+ (WebCore::IDBRequest::cachedResult): >+ * Modules/indexeddb/IDBRequest.idl: >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * bindings/js/JSIDBCursorCustom.cpp: >+ (WebCore::JSIDBCursor::key const): >+ (WebCore::JSIDBCursor::primaryKey const): >+ (WebCore::JSIDBCursor::visitAdditionalChildren): >+ * bindings/js/JSIDBCursorWithValueCustom.cpp: >+ (WebCore::JSIDBCursorWithValue::value const): >+ (WebCore::JSIDBCursorWithValue::visitAdditionalChildren): >+ * inspector/agents/InspectorIndexedDBAgent.cpp: >+ > 2019-02-01 Simon Fraser <simon.fraser@apple.com> > > REGRESSION (r240698): fast/scrolling/sticky-to-fixed.html can cause a crash >diff --git a/Source/WebCore/Modules/indexeddb/IDBCursor.cpp b/Source/WebCore/Modules/indexeddb/IDBCursor.cpp >index 9b59cffce546669e8fce3f4642fe1a1bb740c93a..55490775a55a945e659fe11a006f4a2cbeb80caa 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBCursor.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBCursor.cpp >@@ -128,7 +128,8 @@ ExceptionOr<Ref<IDBRequest>> IDBCursor::update(ExecState& state, JSValue value) > return Exception { DataError, "Failed to execute 'update' on 'IDBCursor': The effective object store of this cursor uses in-line keys and evaluating the key path of the value parameter results in a different value than the cursor's effective key."_s }; > } > >- auto putResult = effectiveObjectStore().putForCursorUpdate(state, value, m_currentPrimaryKey.get()); >+ JSValue key = m_cachedPrimaryKey ? JSValue(m_cachedPrimaryKey) : primaryKey(state); >+ auto putResult = effectiveObjectStore().putForCursorUpdate(state, value, key); > if (putResult.hasException()) > return putResult.releaseException(); > >@@ -299,7 +300,8 @@ ExceptionOr<Ref<WebCore::IDBRequest>> IDBCursor::deleteFunction(ExecState& state > if (!isKeyCursorWithValue()) > return Exception { InvalidStateError, "Failed to execute 'delete' on 'IDBCursor': The cursor is a key cursor."_s }; > >- auto result = effectiveObjectStore().deleteFunction(state, m_currentPrimaryKey.get()); >+ JSValue key = m_cachedPrimaryKey ? JSValue(m_cachedPrimaryKey) : primaryKey(state); >+ auto result = effectiveObjectStore().deleteFunction(state, key); > if (result.hasException()) > return result.releaseException(); > >@@ -309,47 +311,52 @@ ExceptionOr<Ref<WebCore::IDBRequest>> IDBCursor::deleteFunction(ExecState& state > return WTFMove(request); > } > >-void IDBCursor::setGetResult(IDBRequest& request, const IDBGetResult& getResult) >+void IDBCursor::setGetResult(IDBRequest&, const IDBGetResult& getResult) > { > LOG(IndexedDB, "IDBCursor::setGetResult - current key %s", getResult.keyData().loggingString().substring(0, 100).utf8().data()); > ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current()); > >- auto* context = request.scriptExecutionContext(); >- if (!context) >- return; >- >- auto* exec = context->execState(); >- if (!exec) >- return; >+ m_cachedKey = { }; >+ m_cachedPrimaryKey = { }; >+ m_cachedValue = { }; > > if (!getResult.isDefined()) { >- m_currentKey = { }; > m_currentKeyData = { }; >- m_currentPrimaryKey = { }; >+ m_currentKey = nullptr; > m_currentPrimaryKeyData = { }; >+ m_currentPrimaryKey = nullptr; > m_currentValue = { }; > > m_gotValue = false; > return; > } > >- auto& vm = context->vm(); >- >- // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object >- // of the IDBCursor wrapper can be used, rather than the lexicalGlobalObject. >- m_currentKey = { vm, toJS(*exec, *exec->lexicalGlobalObject(), getResult.keyData().maybeCreateIDBKey().get()) }; > m_currentKeyData = getResult.keyData(); >- m_currentPrimaryKey = { vm, toJS(*exec, *exec->lexicalGlobalObject(), getResult.primaryKeyData().maybeCreateIDBKey().get()) }; >+ m_currentKey = m_currentKeyData.maybeCreateIDBKey(); > m_currentPrimaryKeyData = getResult.primaryKeyData(); >+ m_currentPrimaryKey = m_currentPrimaryKeyData.maybeCreateIDBKey(); > > if (isKeyCursorWithValue()) >- m_currentValue = { vm, deserializeIDBValueToJSValue(*exec, getResult.value()) }; >- else >- m_currentValue = { }; >+ m_currentValue = getResult.value(); > > m_gotValue = true; > } > >+JSValue IDBCursor::key(ExecState& state) >+{ >+ return toJS(state, *state.lexicalGlobalObject(), m_currentKey.get()); >+} >+ >+JSValue IDBCursor::primaryKey(ExecState& state) >+{ >+ return toJS(state, *state.lexicalGlobalObject(), m_currentPrimaryKey.get()); >+} >+ >+JSC::JSValue IDBCursor::value(ExecState& state) >+{ >+ return deserializeIDBValueToJSValue(state, m_currentValue); >+} >+ > } // namespace WebCore > > #endif // ENABLE(INDEXED_DATABASE) >diff --git a/Source/WebCore/Modules/indexeddb/IDBCursor.h b/Source/WebCore/Modules/indexeddb/IDBCursor.h >index 9ba27f370361b1df3502b4cc6c572d5d75015bbc..75c1272350a59ddd6f062893afb141b9c330f229 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBCursor.h >+++ b/Source/WebCore/Modules/indexeddb/IDBCursor.h >@@ -30,6 +30,8 @@ > #include "ExceptionOr.h" > #include "IDBCursorDirection.h" > #include "IDBCursorInfo.h" >+#include "IDBValue.h" >+#include "JSValueInWrappedObject.h" > #include <JavaScriptCore/Strong.h> > #include <wtf/Variant.h> > #include <wtf/WeakPtr.h> >@@ -52,9 +54,13 @@ public: > > const Source& source() const; > IDBCursorDirection direction() const; >- JSC::JSValue key() const; >- JSC::JSValue primaryKey() const; >- JSC::JSValue value() const; >+ >+ JSC::JSValue key(JSC::ExecState&); >+ JSC::JSValue primaryKey(JSC::ExecState&); >+ JSC::JSValue value(JSC::ExecState&); >+ JSValueInWrappedObject& cachedKey() { return m_cachedKey; } >+ JSValueInWrappedObject& cachedPrimaryKey() { return m_cachedPrimaryKey; } >+ JSValueInWrappedObject& cachedValue() { return m_cachedValue; } > > ExceptionOr<Ref<IDBRequest>> update(JSC::ExecState&, JSC::JSValue); > ExceptionOr<void> advance(unsigned); >@@ -92,14 +98,15 @@ private: > > bool m_gotValue { false }; > >+ RefPtr<IDBKey> m_currentKey; >+ RefPtr<IDBKey> m_currentPrimaryKey; > IDBKeyData m_currentKeyData; > IDBKeyData m_currentPrimaryKeyData; >+ IDBValue m_currentValue; > >- // FIXME: The following uses of JSC::Strong are incorrect and can lead to storage leaks >- // due to reference cycles; we should use JSValueInWrappedObject instead. >- JSC::Strong<JSC::Unknown> m_currentKey; >- JSC::Strong<JSC::Unknown> m_currentPrimaryKey; >- JSC::Strong<JSC::Unknown> m_currentValue; >+ JSValueInWrappedObject m_cachedKey; >+ JSValueInWrappedObject m_cachedPrimaryKey; >+ JSValueInWrappedObject m_cachedValue; > }; > > >@@ -113,21 +120,6 @@ inline IDBCursorDirection IDBCursor::direction() const > return m_info.cursorDirection(); > } > >-inline JSC::JSValue IDBCursor::key() const >-{ >- return m_currentKey.get(); >-} >- >-inline JSC::JSValue IDBCursor::primaryKey() const >-{ >- return m_currentPrimaryKey.get(); >-} >- >-inline JSC::JSValue IDBCursor::value() const >-{ >- return m_currentValue.get(); >-} >- > } // namespace WebCore > > #endif // ENABLE(INDEXED_DATABASE) >diff --git a/Source/WebCore/Modules/indexeddb/IDBCursor.idl b/Source/WebCore/Modules/indexeddb/IDBCursor.idl >index fccb30fee0f8930dacffc2058217a8ab858ea244..06e3a503d27ced94d943536ca4f3eca1241e1d47 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBCursor.idl >+++ b/Source/WebCore/Modules/indexeddb/IDBCursor.idl >@@ -31,8 +31,8 @@ > ] interface IDBCursor { > readonly attribute (IDBObjectStore or IDBIndex) source; > readonly attribute IDBCursorDirection direction; >- readonly attribute any key; >- readonly attribute any primaryKey; >+ [CustomGetter] readonly attribute any key; >+ [CustomGetter] readonly attribute any primaryKey; > > [CallWith=ExecState, MayThrowException] IDBRequest update(any value); > [MayThrowException] void advance([EnforceRange] unsigned long count); >diff --git a/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.idl b/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.idl >index 5b047d51b16b651a07a8662fbda77035c4fcadbf..ba52c4c057654ff908b1ea837a7a2dc8746b2f12 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.idl >+++ b/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.idl >@@ -28,5 +28,5 @@ > SkipVTableValidation, > JSCustomMarkFunction, > ] interface IDBCursorWithValue : IDBCursor { >- readonly attribute any value; >+ [CustomGetter] readonly attribute any value; > }; >diff --git a/Source/WebCore/Modules/indexeddb/IDBRequest.cpp b/Source/WebCore/Modules/indexeddb/IDBRequest.cpp >index 67178727f80d24412469f837478be1546564f665..22234d5ed164a282a7504fc325c03ae6baa7dac1 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBRequest.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBRequest.cpp >@@ -85,6 +85,7 @@ IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBClient::IDBConnection > , m_resourceIdentifier(connectionProxy) > , m_connectionProxy(connectionProxy) > { >+ m_result = OtherResultType::Empty; > suspendIfNeeded(); > } > >@@ -95,6 +96,7 @@ IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBObjectStore& objectSt > , m_source(&objectStore) > , m_connectionProxy(transaction.database().connectionProxy()) > { >+ m_result = OtherResultType::Empty; > suspendIfNeeded(); > } > >@@ -111,6 +113,7 @@ IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBCursor& cursor, IDBTr > [this] (const auto& value) { this->m_source = IDBRequest::Source { value }; } > ); > >+ m_result = OtherResultType::Empty; > cursor.setRequest(*this); > } > >@@ -121,6 +124,7 @@ IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBIndex& index, IDBTran > , m_source(&index) > , m_connectionProxy(transaction.database().connectionProxy()) > { >+ m_result = OtherResultType::Empty; > suspendIfNeeded(); > } > >@@ -132,12 +136,14 @@ IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBObjectStore& objectSt > , m_requestedObjectStoreRecordType(type) > , m_connectionProxy(transaction.database().connectionProxy()) > { >+ m_result = OtherResultType::Empty; > suspendIfNeeded(); > } > > IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBIndex& index, IndexedDB::IndexRecordType requestedRecordType, IDBTransaction& transaction) > : IDBRequest(context, index, transaction) > { >+ m_result = OtherResultType::Empty; > m_requestedIndexRecordType = requestedRecordType; > } > >@@ -145,20 +151,18 @@ IDBRequest::~IDBRequest() > { > ASSERT(&originThread() == &Thread::current()); > >- if (m_result) { >- WTF::switchOn(m_result.value(), >- [] (RefPtr<IDBCursor>& cursor) { cursor->clearRequest(); }, >- [] (const auto&) { } >- ); >- } >+ WTF::switchOn(m_result, >+ [] (RefPtr<IDBCursor>& cursor) { cursor->clearRequest(); }, >+ [] (const auto&) { } >+ ); > } > >-ExceptionOr<Optional<IDBRequest::Result>> IDBRequest::result() const >+ExceptionOr<IDBRequest::Result> IDBRequest::result() const > { > if (!isDone()) > return Exception { InvalidStateError, "Failed to read the 'result' property from 'IDBRequest': The request has not finished."_s }; > >- return Optional<IDBRequest::Result> { m_result }; >+ return IDBRequest::Result { m_result }; > } > > ExceptionOr<DOMException*> IDBRequest::error() const >@@ -358,11 +362,10 @@ void IDBRequest::setResult(const IDBKeyData& keyData) > if (!state) > return; > >- // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object >- // of the IDBRequest wrapper can be used, rather than the lexicalGlobalObject. > VM& vm = context->vm(); > JSLockHolder lock(vm); >- m_result = Result { JSC::Strong<JSC::Unknown> { vm, toJS<IDLIDBKeyData>(*state, *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), keyData) } }; >+ m_result = keyData; >+ m_cachedResult = { }; > } > > void IDBRequest::setResult(const Vector<IDBKeyData>& keyDatas) >@@ -377,11 +380,10 @@ void IDBRequest::setResult(const Vector<IDBKeyData>& keyDatas) > if (!state) > return; > >- // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object >- // of the IDBRequest wrapper can be used, rather than the lexicalGlobalObject. > VM& vm = context->vm(); > JSLockHolder lock(vm); >- m_result = Result { JSC::Strong<JSC::Unknown> { vm, toJS<IDLSequence<IDLIDBKeyData>>(*state, *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), keyDatas) } }; >+ m_result = keyDatas; >+ m_cachedResult = { }; > } > > void IDBRequest::setResult(const Vector<IDBValue>& values) >@@ -396,11 +398,10 @@ void IDBRequest::setResult(const Vector<IDBValue>& values) > if (!state) > return; > >- // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object >- // of the IDBRequest wrapper can be used, rather than the lexicalGlobalObject. > VM& vm = context->vm(); > JSLockHolder lock(vm); >- m_result = Result { JSC::Strong<JSC::Unknown> { vm, toJS<IDLSequence<IDLIDBValue>>(*state, *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), values) } }; >+ m_result = values; >+ m_cachedResult = { }; > } > > void IDBRequest::setResult(uint64_t number) >@@ -411,7 +412,8 @@ void IDBRequest::setResult(uint64_t number) > if (!context) > return; > >- m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), toJS<IDLUnrestrictedDouble>(number) } }; >+ m_result = number; >+ m_cachedResult = { }; > } > > void IDBRequest::setResultToStructuredClone(const IDBValue& value) >@@ -428,32 +430,25 @@ void IDBRequest::setResultToStructuredClone(const IDBValue& value) > if (!state) > return; > >- // FIXME: This conversion should be done lazily, when script needs the JSValues, so that global object >- // of the IDBRequest wrapper can be used, rather than the lexicalGlobalObject. > VM& vm = context->vm(); > JSLockHolder lock(vm); >- m_result = Result { JSC::Strong<JSC::Unknown> { vm, toJS<IDLIDBValue>(*state, *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), value) } }; >+ m_result = value; >+ m_cachedResult = { }; > } > > void IDBRequest::setResultToUndefined() > { > ASSERT(&originThread() == &Thread::current()); > >- auto* context = scriptExecutionContext(); >- if (!context) >- return; >- >- m_result = Result { JSC::Strong<JSC::Unknown> { context->vm(), JSC::jsUndefined() } }; >+ m_result = OtherResultType::Undefined; >+ m_cachedResult = { }; > } > > IDBCursor* IDBRequest::resultCursor() > { > ASSERT(&originThread() == &Thread::current()); > >- if (!m_result) >- return nullptr; >- >- return WTF::switchOn(m_result.value(), >+ return WTF::switchOn(m_result, > [] (const RefPtr<IDBCursor>& cursor) -> IDBCursor* { return cursor.get(); }, > [] (const auto&) -> IDBCursor* { return nullptr; } > ); >@@ -470,7 +465,8 @@ void IDBRequest::willIterateCursor(IDBCursor& cursor) > > m_pendingCursor = &cursor; > m_hasPendingActivity = true; >- m_result = WTF::nullopt; >+ m_result = OtherResultType::Empty; >+ m_cachedResult = { }; > m_readyState = ReadyState::Pending; > m_domError = nullptr; > m_idbError = IDBError { }; >@@ -481,12 +477,13 @@ void IDBRequest::didOpenOrIterateCursor(const IDBResultData& resultData) > ASSERT(&originThread() == &Thread::current()); > ASSERT(m_pendingCursor); > >- m_result = WTF::nullopt; >+ m_result = OtherResultType::Empty; >+ m_cachedResult = { }; > > if (resultData.type() == IDBResultType::IterateCursorSuccess || resultData.type() == IDBResultType::OpenCursorSuccess) { > m_pendingCursor->setGetResult(*this, resultData.getResult()); > if (resultData.getResult().isDefined()) >- m_result = Result { m_pendingCursor }; >+ m_result = m_pendingCursor; > } > > m_pendingCursor = nullptr; >@@ -529,7 +526,8 @@ void IDBRequest::setResult(Ref<IDBDatabase>&& database) > { > ASSERT(&originThread() == &Thread::current()); > >- m_result = Result { RefPtr<IDBDatabase> { WTFMove(database) } }; >+ m_result = RefPtr<IDBDatabase> { WTFMove(database) }; >+ m_cachedResult = { }; > } > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/indexeddb/IDBRequest.h b/Source/WebCore/Modules/indexeddb/IDBRequest.h >index a3433a5926993fe8f7920d263ebaddbdaaf5f6b3..cfb325b5676329e87bc953358575937ea9f227ec 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBRequest.h >+++ b/Source/WebCore/Modules/indexeddb/IDBRequest.h >@@ -31,8 +31,11 @@ > #include "ExceptionOr.h" > #include "IDBActiveDOMObject.h" > #include "IDBError.h" >+#include "IDBKeyData.h" > #include "IDBResourceIdentifier.h" >+#include "IDBValue.h" > #include "IndexedDB.h" >+#include "JSValueInWrappedObject.h" > #include <JavaScriptCore/Strong.h> > #include <wtf/Function.h> > #include <wtf/Scope.h> >@@ -45,11 +48,9 @@ class Event; > class IDBCursor; > class IDBDatabase; > class IDBIndex; >-class IDBKeyData; > class IDBObjectStore; > class IDBResultData; > class IDBTransaction; >-class IDBValue; > class ThreadSafeDataBuffer; > > namespace IDBClient { >@@ -59,6 +60,11 @@ class IDBConnectionToServer; > > class IDBRequest : public EventTargetWithInlineData, public IDBActiveDOMObject, public RefCounted<IDBRequest>, public CanMakeWeakPtr<IDBRequest> { > public: >+ enum class OtherResultType { >+ Empty, >+ Undefined >+ }; >+ > static Ref<IDBRequest> create(ScriptExecutionContext&, IDBObjectStore&, IDBTransaction&); > static Ref<IDBRequest> create(ScriptExecutionContext&, IDBCursor&, IDBTransaction&); > static Ref<IDBRequest> create(ScriptExecutionContext&, IDBIndex&, IDBTransaction&); >@@ -69,10 +75,9 @@ public: > > virtual ~IDBRequest(); > >- // FIXME: The following use of JSC::Strong is incorrect and can lead to storage leaks >- // due to reference cycles; we should use JSValueInWrappedObject instead. >- using Result = Variant<RefPtr<IDBCursor>, RefPtr<IDBDatabase>, JSC::Strong<JSC::Unknown>>; >- ExceptionOr<Optional<Result>> result() const; >+ using Result = Variant<RefPtr<IDBCursor>, RefPtr<IDBDatabase>, IDBKeyData, Vector<IDBKeyData>, IDBValue, Vector<IDBValue>, uint64_t, OtherResultType>; >+ ExceptionOr<Result> result() const; >+ JSValueInWrappedObject& cachedResult() { return m_cachedResult; } > > using Source = Variant<RefPtr<IDBObjectStore>, RefPtr<IDBIndex>, RefPtr<IDBCursor>>; > const Optional<Source>& source() const { return m_source; } >@@ -80,7 +85,7 @@ public: > ExceptionOr<DOMException*> error() const; > > RefPtr<IDBTransaction> transaction() const; >- >+ > enum class ReadyState { Pending, Done }; > ReadyState readyState() const { return m_readyState; } > >@@ -165,7 +170,8 @@ private: > IDBError m_idbError; > IDBResourceIdentifier m_resourceIdentifier; > >- Optional<Result> m_result; >+ JSValueInWrappedObject m_cachedResult; >+ Result m_result; > Optional<Source> m_source; > > bool m_hasPendingActivity { true }; >diff --git a/Source/WebCore/Modules/indexeddb/IDBRequest.idl b/Source/WebCore/Modules/indexeddb/IDBRequest.idl >index 7751e205282b8e8a58895155f4b54e0aaabb04ad..85bbde9168b50cec42fd14c3dd65b9d9fef22483 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBRequest.idl >+++ b/Source/WebCore/Modules/indexeddb/IDBRequest.idl >@@ -31,9 +31,10 @@ > ActiveDOMObject, > Conditional=INDEXED_DATABASE, > GenerateIsReachable=Impl, >+ JSCustomMarkFunction, > SkipVTableValidation, > ] interface IDBRequest : EventTarget { >- readonly attribute (IDBCursor or IDBDatabase or any)? result; >+ [CustomGetter] readonly attribute (IDBCursor or IDBDatabase or any) result; > readonly attribute DOMException? error; > readonly attribute (IDBObjectStore or IDBIndex or IDBCursor)? source; > readonly attribute IDBTransaction transaction; >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 378c0653b8090cf01c3b0dadca3959130e7f8584..b94941a6a0f783b5d91ece7704df5cbda148c899 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -488,6 +488,7 @@ bindings/js/JSIDBCursorCustom.cpp > bindings/js/JSIDBCursorWithValueCustom.cpp > bindings/js/JSIDBIndexCustom.cpp > bindings/js/JSIDBObjectStoreCustom.cpp >+bindings/js/JSIDBRequestCustom.cpp > bindings/js/JSIDBTransactionCustom.cpp > bindings/js/JSImageDataCustom.cpp > bindings/js/JSIntersectionObserverEntryCustom.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index dd9174dee6fa26220479c4a036e1c4efc2383b61..f20f5a0965b1006564e4a920f553a0b0e7587081 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -4043,6 +4043,7 @@ > C9D851F01B39DC780085062E /* MediaSessionMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = C9D851EE1B39DC780085062E /* MediaSessionMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; }; > C9F87CFE1B28F40E00979B83 /* MediaSessionEvents.h in Headers */ = {isa = PBXBuildFile; fileRef = C9F87CFD1B28E5F600979B83 /* MediaSessionEvents.h */; settings = {ATTRIBUTES = (Private, ); }; }; > CA3BF67E10D99BAE00E6CE53 /* ScrollAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ CA6C1530220B98CC0055CBFC /* JSValueInWrappedObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 931AE3B81FB80EAE00F5EFB2 /* JSValueInWrappedObject.h */; settings = {ATTRIBUTES = (Private, ); }; }; > CAE9F910146441F000C245B0 /* CSSAspectRatioValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */; }; > CB38FD521CCF939400592A3F /* JSPerformanceEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = CB38FD4E1CCF937E00592A3F /* JSPerformanceEntry.h */; }; > CB38FD5B1CD2325B00592A3F /* JSPerformanceResourceTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = CB38FD591CD2314500592A3F /* JSPerformanceResourceTiming.h */; }; >@@ -13528,6 +13529,7 @@ > CA1635DC2072E76900E7D2CE /* ReferrerPolicy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReferrerPolicy.cpp; sourceTree = "<group>"; }; > CA3BF67B10D99BAE00E6CE53 /* ScrollAnimator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollAnimator.cpp; sourceTree = "<group>"; }; > CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollAnimator.h; sourceTree = "<group>"; }; >+ CA6C152F220B4A550055CBFC /* JSIDBRequestCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSIDBRequestCustom.cpp; sourceTree = "<group>"; }; > CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSAspectRatioValue.cpp; sourceTree = "<group>"; }; > CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSAspectRatioValue.h; sourceTree = "<group>"; }; > CB38FD4A1CCCF2DD00592A3F /* PerformanceEntry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceEntry.cpp; sourceTree = "<group>"; }; >@@ -20953,6 +20955,7 @@ > 831C46C31F9EE5E000EBD450 /* JSExtendableMessageEventCustom.cpp */, > 4131F3B11F9552810059995A /* JSFetchEventCustom.cpp */, > BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */, >+ CA6C152F220B4A550055CBFC /* JSIDBRequestCustom.cpp */, > 410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */, > A1677E242144532800A08C34 /* JSPaymentMethodChangeEventCustom.cpp */, > A10D6E942144C99800FDD14D /* JSPaymentResponseCustom.cpp */, >@@ -30466,6 +30469,7 @@ > 7C73FB0D191EF5A8007DE061 /* JSUserMessageHandlersNamespace.h in Headers */, > 572B402C21769020000AD43E /* JSUserVerificationRequirement.h in Headers */, > 15C77093100D3CA8005BA267 /* JSValidityState.h in Headers */, >+ CA6C1530220B98CC0055CBFC /* JSValueInWrappedObject.h in Headers */, > BE8EF04B171C9014009B48C3 /* JSVideoTrack.h in Headers */, > BE8EF04D171C9014009B48C3 /* JSVideoTrackList.h in Headers */, > 46E791491F97E01A00199739 /* JSVisibilityState.h in Headers */, >diff --git a/Source/WebCore/bindings/js/JSIDBCursorCustom.cpp b/Source/WebCore/bindings/js/JSIDBCursorCustom.cpp >index bafe2fe0bf427af9c14a217945b6b23bd06c9b93..6b92fa9bbb2fe43ec25d4dd5b0a850d830b47868 100644 >--- a/Source/WebCore/bindings/js/JSIDBCursorCustom.cpp >+++ b/Source/WebCore/bindings/js/JSIDBCursorCustom.cpp >@@ -28,6 +28,7 @@ > > #if ENABLE(INDEXED_DATABASE) > >+#include "IDBBindingUtilities.h" > #include "JSDOMBinding.h" > #include "JSIDBCursorWithValue.h" > >@@ -35,11 +36,27 @@ > namespace WebCore { > using namespace JSC; > >+JSC::JSValue JSIDBCursor::key(JSC::ExecState& state) const >+{ >+ return cachedPropertyValue(state, *this, wrapped().cachedKey(), [&] { >+ return wrapped().key(state); >+ }); >+} >+ >+JSC::JSValue JSIDBCursor::primaryKey(JSC::ExecState& state) const >+{ >+ return cachedPropertyValue(state, *this, wrapped().cachedPrimaryKey(), [&] { >+ return wrapped().primaryKey(state); >+ }); >+} >+ > void JSIDBCursor::visitAdditionalChildren(SlotVisitor& visitor) > { > auto& cursor = wrapped(); > if (auto* request = cursor.request()) > visitor.addOpaqueRoot(request); >+ cursor.cachedKey().visit(visitor); >+ cursor.cachedPrimaryKey().visit(visitor); > } > > JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<IDBCursor>&& cursor) >diff --git a/Source/WebCore/bindings/js/JSIDBCursorWithValueCustom.cpp b/Source/WebCore/bindings/js/JSIDBCursorWithValueCustom.cpp >index 8c323b6010f56e24007eddf7ee23d0025c46c54b..e9bf4aed7552b6787dac6f8967d5fa3baa77e21e 100644 >--- a/Source/WebCore/bindings/js/JSIDBCursorWithValueCustom.cpp >+++ b/Source/WebCore/bindings/js/JSIDBCursorWithValueCustom.cpp >@@ -28,15 +28,24 @@ > > #if ENABLE(INDEXED_DATABASE) > >+#include "IDBBindingUtilities.h" > #include "IDBCursorWithValue.h" > #include <JavaScriptCore/HeapInlines.h> > > namespace WebCore { > using namespace JSC; > >+JSC::JSValue JSIDBCursorWithValue::value(JSC::ExecState& state) const >+{ >+ return cachedPropertyValue(state, *this, wrapped().cachedValue(), [&] { >+ return wrapped().value(state); >+ }); >+} >+ > void JSIDBCursorWithValue::visitAdditionalChildren(SlotVisitor& visitor) > { > JSIDBCursor::visitAdditionalChildren(visitor); >+ wrapped().cachedValue().visit(visitor); > } > > } // namespace WebCore >diff --git a/Source/WebCore/inspector/agents/InspectorIndexedDBAgent.cpp b/Source/WebCore/inspector/agents/InspectorIndexedDBAgent.cpp >index 6d5881ea0e664cbbce2a85f8d9de093fb43ccac0..ade0e13066c81616f9da5e60fcc4a79e54998a0e 100644 >--- a/Source/WebCore/inspector/agents/InspectorIndexedDBAgent.cpp >+++ b/Source/WebCore/inspector/agents/InspectorIndexedDBAgent.cpp >@@ -137,12 +137,12 @@ public: > } > > auto resultValue = result.releaseReturnValue(); >- if (!resultValue || !WTF::holds_alternative<RefPtr<IDBDatabase>>(resultValue.value())) { >+ if (!WTF::holds_alternative<RefPtr<IDBDatabase>>(resultValue)) { > m_executableWithDatabase->requestCallback().sendFailure("Unexpected result type."); > return; > } > >- auto databaseResult = WTF::get<RefPtr<IDBDatabase>>(resultValue.value()); >+ auto databaseResult = WTF::get<RefPtr<IDBDatabase>>(resultValue); > m_executableWithDatabase->execute(*databaseResult); > databaseResult->close(); > } >@@ -363,7 +363,7 @@ public: > return this == &other; > } > >- void handleEvent(ScriptExecutionContext&, Event& event) override >+ void handleEvent(ScriptExecutionContext& context, Event& event) override > { > if (event.type() != eventNames().successEvent) { > m_requestCallback->sendFailure("Unexpected event type."); >@@ -379,12 +379,12 @@ public: > } > > auto resultValue = result.releaseReturnValue(); >- if (!resultValue || !WTF::holds_alternative<RefPtr<IDBCursor>>(resultValue.value())) { >+ if (!WTF::holds_alternative<RefPtr<IDBCursor>>(resultValue)) { > end(false); > return; > } > >- auto cursor = WTF::get<RefPtr<IDBCursor>>(resultValue.value()); >+ auto cursor = WTF::get<RefPtr<IDBCursor>>(resultValue); > > if (m_skipCount) { > if (cursor->advance(m_skipCount).hasException()) >@@ -404,10 +404,11 @@ public: > return; > } > >+ auto* state = context.execState(); > auto dataEntry = DataEntry::create() >- .setKey(m_injectedScript.wrapObject(cursor->key(), String(), true)) >- .setPrimaryKey(m_injectedScript.wrapObject(cursor->primaryKey(), String(), true)) >- .setValue(m_injectedScript.wrapObject(cursor->value(), String(), true)) >+ .setKey(m_injectedScript.wrapObject(cursor->key(*state), String(), true)) >+ .setPrimaryKey(m_injectedScript.wrapObject(cursor->primaryKey(*state), String(), true)) >+ .setValue(m_injectedScript.wrapObject(cursor->value(*state), String(), true)) > .release(); > m_result->addItem(WTFMove(dataEntry)); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189435
:
361349
|
361403
|
361483