From: beidson@apple.com Date: Thu, 17 Sep 2015 04:27:46 +0000 (+0000) Subject: Have window.indexedDB.open return an IDBOpenDBRequest. X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=31d850e2685a23b669d3a82984e0887a621f1963 Have window.indexedDB.open return an IDBOpenDBRequest. https://bugs.webkit.org/show_bug.cgi?id=149234 Reviewed by Alex Christensen. Source/WebCore: Test: storage/indexeddb/modern/opendatabase-request.html * Modules/indexeddb/client/IDBFactoryImpl.cpp: (WebCore::IDBClient::IDBFactory::open): (WebCore::IDBClient::IDBFactory::openInternal): * Modules/indexeddb/client/IDBFactoryImpl.h: LayoutTests: * storage/indexeddb/modern/opendatabase-request-expected.txt: Added. * storage/indexeddb/modern/opendatabase-request.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189901 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 1567d55..3e799c3 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +2015-09-16 Brady Eidson + + Have window.indexedDB.open return an IDBOpenDBRequest. + https://bugs.webkit.org/show_bug.cgi?id=149234 + + Reviewed by Alex Christensen. + + * storage/indexeddb/modern/opendatabase-request-expected.txt: Added. + * storage/indexeddb/modern/opendatabase-request.html: Added. + 2015-09-16 Myles C. Maxfield Create a font which can be used for testing font features diff --git a/LayoutTests/storage/indexeddb/modern/opendatabase-request-expected.txt b/LayoutTests/storage/indexeddb/modern/opendatabase-request-expected.txt new file mode 100644 index 0000000..3fad291 --- /dev/null +++ b/LayoutTests/storage/indexeddb/modern/opendatabase-request-expected.txt @@ -0,0 +1,6 @@ +ALERT: [object IDBOpenDBRequest] +ALERT: [object IDBOpenDBRequest] +ALERT: TypeError: Not enough arguments +ALERT: TypeError: Type error +ALERT: Done +This test calls open on window.indexedDB in various ways, verifying that IDBOpenDBRequest objects are returned when expected and exceptions are thrown when expected. diff --git a/LayoutTests/storage/indexeddb/modern/opendatabase-request.html b/LayoutTests/storage/indexeddb/modern/opendatabase-request.html new file mode 100644 index 0000000..0f7e7d5 --- /dev/null +++ b/LayoutTests/storage/indexeddb/modern/opendatabase-request.html @@ -0,0 +1,35 @@ +This test calls open on window.indexedDB in various ways, verifying that IDBOpenDBRequest objects are returned when expected and exceptions are thrown when expected. + diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 1b825c8..b952ced 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,17 @@ +2015-09-16 Brady Eidson + + Have window.indexedDB.open return an IDBOpenDBRequest. + https://bugs.webkit.org/show_bug.cgi?id=149234 + + Reviewed by Alex Christensen. + + Test: storage/indexeddb/modern/opendatabase-request.html + + * Modules/indexeddb/client/IDBFactoryImpl.cpp: + (WebCore::IDBClient::IDBFactory::open): + (WebCore::IDBClient::IDBFactory::openInternal): + * Modules/indexeddb/client/IDBFactoryImpl.h: + 2015-09-16 Antti Koivisto Turn ChildNodeInsertion/RemovalNotifier classes into functions diff --git a/Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.cpp b/Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.cpp index 144f1d6..70fead0 100644 --- a/Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.cpp +++ b/Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.cpp @@ -73,14 +73,47 @@ PassRefPtr IDBFactory::getDatabaseNames(ScriptExecutionCont return nullptr; } -PassRefPtr IDBFactory::open(ScriptExecutionContext*, const String&, ExceptionCode&) +PassRefPtr IDBFactory::open(ScriptExecutionContext* context, const String& name, ExceptionCode& ec) { - return nullptr; + LOG(IndexedDB, "IDBFactory::open"); + + return openInternal(context, name, 0, ec).release(); } -PassRefPtr IDBFactory::open(ScriptExecutionContext*, const String&, unsigned long long, ExceptionCode&) +PassRefPtr IDBFactory::open(ScriptExecutionContext* context, const String& name, unsigned long long version, ExceptionCode& ec) { - return nullptr; + LOG(IndexedDB, "IDBFactory::open"); + + if (!version) { + ec = TypeError; + return nullptr; + } + + return openInternal(context, name, 0, ec).release(); +} + +RefPtr IDBFactory::openInternal(ScriptExecutionContext* context, const String& name, unsigned long long, ExceptionCode& ec) +{ + if (name.isNull()) { + ec = TypeError; + return nullptr; + } + + if (shouldThrowSecurityException(context)) { + ec = SECURITY_ERR; + return nullptr; + } + + ASSERT(context->securityOrigin()); + ASSERT(context->topOrigin()); + IDBDatabaseIdentifier databaseIdentifier(name, *context->securityOrigin(), *context->topOrigin()); + if (!databaseIdentifier.isValid()) { + ec = TypeError; + return nullptr; + } + + auto request = IDBOpenDBRequest::create(context); + return adoptRef(&request.leakRef()); } PassRefPtr IDBFactory::deleteDatabase(ScriptExecutionContext* context, const String& name, ExceptionCode& ec) diff --git a/Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.h b/Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.h index 9c709b4..8c215dd 100644 --- a/Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.h +++ b/Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.h @@ -33,6 +33,8 @@ namespace WebCore { namespace IDBClient { +class IDBOpenDBRequest; + class IDBFactory : public WebCore::IDBFactory { public: static Ref create(); @@ -47,6 +49,8 @@ public: private: IDBFactory(); + + RefPtr openInternal(ScriptExecutionContext*, const String& name, unsigned long long version, ExceptionCode&); }; } // namespace IDBClient