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
+2015-09-16 Brady Eidson <beidson@apple.com>
+
+ 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 <mmaxfield@apple.com>
Create a font which can be used for testing font features
--- /dev/null
+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.
--- /dev/null
+This test calls open on window.indexedDB in various ways, verifying that IDBOpenDBRequest objects are returned when expected and exceptions are thrown when expected.
+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+function done()
+{
+ alert("Done");
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+var request = window.indexedDB.open("TestDatabase");
+alert(request);
+
+request = window.indexedDB.open("");
+alert(request);
+
+try {
+ var request = window.indexedDB.open();
+} catch (e) {
+ alert(e);
+}
+
+try {
+ var request = window.indexedDB.open("name", 0);
+} catch (e) {
+ alert(e);
+}
+
+done();
+</script>
+2015-09-16 Brady Eidson <beidson@apple.com>
+
+ 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 <antti@apple.com>
Turn ChildNodeInsertion/RemovalNotifier classes into functions
return nullptr;
}
-PassRefPtr<WebCore::IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext*, const String&, ExceptionCode&)
+PassRefPtr<WebCore::IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
{
- return nullptr;
+ LOG(IndexedDB, "IDBFactory::open");
+
+ return openInternal(context, name, 0, ec).release();
}
-PassRefPtr<WebCore::IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext*, const String&, unsigned long long, ExceptionCode&)
+PassRefPtr<WebCore::IDBOpenDBRequest> 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<IDBOpenDBRequest> 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<WebCore::IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
namespace WebCore {
namespace IDBClient {
+class IDBOpenDBRequest;
+
class IDBFactory : public WebCore::IDBFactory {
public:
static Ref<IDBFactory> create();
private:
IDBFactory();
+
+ RefPtr<IDBOpenDBRequest> openInternal(ScriptExecutionContext*, const String& name, unsigned long long version, ExceptionCode&);
};
} // namespace IDBClient