| 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" | |
| 44 #include "wtf/PassRefPtr.h" | 42 #include "wtf/PassRefPtr.h" |
| 45 #include "wtf/Vector.h" | 43 #include "wtf/Vector.h" |
| 46 #include "wtf/dtoa/utils.h" | 44 #include "wtf/dtoa/utils.h" |
| 45 #include <memory> |
| 47 #include <v8.h> | 46 #include <v8.h> |
| 48 | 47 |
| 49 namespace blink { | 48 namespace blink { |
| 50 namespace { | 49 namespace { |
| 51 | 50 |
| 52 TEST(IDBRequestTest, EventsAfterStopping) | 51 TEST(IDBRequestTest, EventsAfterStopping) |
| 53 { | 52 { |
| 54 V8TestingScope scope; | 53 V8TestingScope scope; |
| 55 IDBTransaction* transaction = nullptr; | 54 IDBTransaction* transaction = nullptr; |
| 56 IDBRequest* request = IDBRequest::create(scope.getScriptState(), IDBAny::cre
ateUndefined(), transaction); | 55 IDBRequest* request = IDBRequest::create(scope.getScriptState(), IDBAny::cre
ateUndefined(), transaction); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 TEST(IDBRequestTest, ConnectionsAfterStopping) | 89 TEST(IDBRequestTest, ConnectionsAfterStopping) |
| 91 { | 90 { |
| 92 V8TestingScope scope; | 91 V8TestingScope scope; |
| 93 const int64_t transactionId = 1234; | 92 const int64_t transactionId = 1234; |
| 94 const int64_t version = 1; | 93 const int64_t version = 1; |
| 95 const int64_t oldVersion = 0; | 94 const int64_t oldVersion = 0; |
| 96 const IDBDatabaseMetadata metadata; | 95 const IDBDatabaseMetadata metadata; |
| 97 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create(); | 96 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create(); |
| 98 | 97 |
| 99 { | 98 { |
| 100 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 99 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create
(); |
| 101 EXPECT_CALL(*backend, abort(transactionId)) | 100 EXPECT_CALL(*backend, abort(transactionId)) |
| 102 .Times(1); | 101 .Times(1); |
| 103 EXPECT_CALL(*backend, close()) | 102 EXPECT_CALL(*backend, close()) |
| 104 .Times(1); | 103 .Times(1); |
| 105 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scope.getScriptStat
e(), callbacks, transactionId, version); | 104 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scope.getScriptStat
e(), callbacks, transactionId, version); |
| 106 EXPECT_EQ(request->readyState(), "pending"); | 105 EXPECT_EQ(request->readyState(), "pending"); |
| 107 | 106 |
| 108 scope.getExecutionContext()->stopActiveDOMObjects(); | 107 scope.getExecutionContext()->stopActiveDOMObjects(); |
| 109 request->onUpgradeNeeded(oldVersion, std::move(backend), metadata, WebID
BDataLossNone, String()); | 108 request->onUpgradeNeeded(oldVersion, std::move(backend), metadata, WebID
BDataLossNone, String()); |
| 110 } | 109 } |
| 111 | 110 |
| 112 { | 111 { |
| 113 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 112 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create
(); |
| 114 EXPECT_CALL(*backend, close()) | 113 EXPECT_CALL(*backend, close()) |
| 115 .Times(1); | 114 .Times(1); |
| 116 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scope.getScriptStat
e(), callbacks, transactionId, version); | 115 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scope.getScriptStat
e(), callbacks, transactionId, version); |
| 117 EXPECT_EQ(request->readyState(), "pending"); | 116 EXPECT_EQ(request->readyState(), "pending"); |
| 118 | 117 |
| 119 scope.getExecutionContext()->stopActiveDOMObjects(); | 118 scope.getExecutionContext()->stopActiveDOMObjects(); |
| 120 request->onSuccess(std::move(backend), metadata); | 119 request->onSuccess(std::move(backend), metadata); |
| 121 } | 120 } |
| 122 } | 121 } |
| 123 | 122 |
| 124 } // namespace | 123 } // namespace |
| 125 } // namespace blink | 124 } // namespace blink |
| OLD | NEW |