| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
| 33 #include "core/dom/ExecutionContext.h" | 33 #include "core/dom/ExecutionContext.h" |
| 34 #include "core/testing/NullExecutionContext.h" | 34 #include "core/testing/NullExecutionContext.h" |
| 35 #include "modules/indexeddb/IDBDatabaseCallbacks.h" | 35 #include "modules/indexeddb/IDBDatabaseCallbacks.h" |
| 36 #include "modules/indexeddb/IDBKey.h" | 36 #include "modules/indexeddb/IDBKey.h" |
| 37 #include "modules/indexeddb/IDBOpenDBRequest.h" | 37 #include "modules/indexeddb/IDBOpenDBRequest.h" |
| 38 #include "modules/indexeddb/IDBValue.h" | 38 #include "modules/indexeddb/IDBValue.h" |
| 39 #include "modules/indexeddb/MockWebIDBDatabase.h" | 39 #include "modules/indexeddb/MockWebIDBDatabase.h" |
| 40 #include "platform/SharedBuffer.h" | 40 #include "platform/SharedBuffer.h" |
| 41 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
| 42 #include "wtf/OwnPtr.h" |
| 43 #include "wtf/PassOwnPtr.h" |
| 42 #include "wtf/PassRefPtr.h" | 44 #include "wtf/PassRefPtr.h" |
| 43 #include "wtf/Vector.h" | 45 #include "wtf/Vector.h" |
| 44 #include "wtf/dtoa/utils.h" | 46 #include "wtf/dtoa/utils.h" |
| 45 #include <memory> | |
| 46 #include <v8.h> | 47 #include <v8.h> |
| 47 | 48 |
| 48 namespace blink { | 49 namespace blink { |
| 49 namespace { | 50 namespace { |
| 50 | 51 |
| 51 TEST(IDBRequestTest, EventsAfterStopping) | 52 TEST(IDBRequestTest, EventsAfterStopping) |
| 52 { | 53 { |
| 53 V8TestingScope scope; | 54 V8TestingScope scope; |
| 54 IDBTransaction* transaction = nullptr; | 55 IDBTransaction* transaction = nullptr; |
| 55 IDBRequest* request = IDBRequest::create(scope.getScriptState(), IDBAny::cre
ateUndefined(), transaction); | 56 IDBRequest* request = IDBRequest::create(scope.getScriptState(), IDBAny::cre
ateUndefined(), transaction); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 TEST(IDBRequestTest, ConnectionsAfterStopping) | 90 TEST(IDBRequestTest, ConnectionsAfterStopping) |
| 90 { | 91 { |
| 91 V8TestingScope scope; | 92 V8TestingScope scope; |
| 92 const int64_t transactionId = 1234; | 93 const int64_t transactionId = 1234; |
| 93 const int64_t version = 1; | 94 const int64_t version = 1; |
| 94 const int64_t oldVersion = 0; | 95 const int64_t oldVersion = 0; |
| 95 const IDBDatabaseMetadata metadata; | 96 const IDBDatabaseMetadata metadata; |
| 96 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create(); | 97 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create(); |
| 97 | 98 |
| 98 { | 99 { |
| 99 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create
(); | 100 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
| 100 EXPECT_CALL(*backend, abort(transactionId)) | 101 EXPECT_CALL(*backend, abort(transactionId)) |
| 101 .Times(1); | 102 .Times(1); |
| 102 EXPECT_CALL(*backend, close()) | 103 EXPECT_CALL(*backend, close()) |
| 103 .Times(1); | 104 .Times(1); |
| 104 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scope.getScriptStat
e(), callbacks, transactionId, version); | 105 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scope.getScriptStat
e(), callbacks, transactionId, version); |
| 105 EXPECT_EQ(request->readyState(), "pending"); | 106 EXPECT_EQ(request->readyState(), "pending"); |
| 106 | 107 |
| 107 scope.getExecutionContext()->stopActiveDOMObjects(); | 108 scope.getExecutionContext()->stopActiveDOMObjects(); |
| 108 request->onUpgradeNeeded(oldVersion, std::move(backend), metadata, WebID
BDataLossNone, String()); | 109 request->onUpgradeNeeded(oldVersion, std::move(backend), metadata, WebID
BDataLossNone, String()); |
| 109 } | 110 } |
| 110 | 111 |
| 111 { | 112 { |
| 112 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create
(); | 113 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
| 113 EXPECT_CALL(*backend, close()) | 114 EXPECT_CALL(*backend, close()) |
| 114 .Times(1); | 115 .Times(1); |
| 115 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scope.getScriptStat
e(), callbacks, transactionId, version); | 116 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scope.getScriptStat
e(), callbacks, transactionId, version); |
| 116 EXPECT_EQ(request->readyState(), "pending"); | 117 EXPECT_EQ(request->readyState(), "pending"); |
| 117 | 118 |
| 118 scope.getExecutionContext()->stopActiveDOMObjects(); | 119 scope.getExecutionContext()->stopActiveDOMObjects(); |
| 119 request->onSuccess(std::move(backend), metadata); | 120 request->onSuccess(std::move(backend), metadata); |
| 120 } | 121 } |
| 121 } | 122 } |
| 122 | 123 |
| 123 } // namespace | 124 } // namespace |
| 124 } // namespace blink | 125 } // namespace blink |
| OLD | NEW |