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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 namespace blink { | 48 namespace blink { |
49 namespace { | 49 namespace { |
50 | 50 |
51 TEST(IDBRequestTest, EventsAfterStopping) { | 51 TEST(IDBRequestTest, EventsAfterStopping) { |
52 V8TestingScope scope; | 52 V8TestingScope scope; |
53 IDBTransaction* transaction = nullptr; | 53 IDBTransaction* transaction = nullptr; |
54 IDBRequest* request = IDBRequest::create( | 54 IDBRequest* request = IDBRequest::create( |
55 scope.getScriptState(), IDBAny::createUndefined(), transaction); | 55 scope.getScriptState(), IDBAny::createUndefined(), transaction); |
56 EXPECT_EQ(request->readyState(), "pending"); | 56 EXPECT_EQ(request->readyState(), "pending"); |
57 scope.getExecutionContext()->stopActiveDOMObjects(); | 57 scope.getExecutionContext()->notifyContextDestroyed(); |
58 | 58 |
59 // Ensure none of the following raise assertions in stopped state: | 59 // Ensure none of the following raise assertions in stopped state: |
60 request->onError(DOMException::create(AbortError, "Description goes here.")); | 60 request->onError(DOMException::create(AbortError, "Description goes here.")); |
61 request->onSuccess(Vector<String>()); | 61 request->onSuccess(Vector<String>()); |
62 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid(), | 62 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid(), |
63 IDBValue::create()); | 63 IDBValue::create()); |
64 request->onSuccess(IDBKey::createInvalid()); | 64 request->onSuccess(IDBKey::createInvalid()); |
65 request->onSuccess(IDBValue::create()); | 65 request->onSuccess(IDBValue::create()); |
66 request->onSuccess(static_cast<int64_t>(0)); | 66 request->onSuccess(static_cast<int64_t>(0)); |
67 request->onSuccess(); | 67 request->onSuccess(); |
(...skipping 10 matching lines...) Expand all Loading... |
78 | 78 |
79 // Simulate the IDBTransaction having received onAbort from back end and abort
ing the request: | 79 // Simulate the IDBTransaction having received onAbort from back end and abort
ing the request: |
80 request->abort(); | 80 request->abort(); |
81 | 81 |
82 // Now simulate the back end having fired an abort error at the request to cle
ar up any intermediaries. | 82 // Now simulate the back end having fired an abort error at the request to cle
ar up any intermediaries. |
83 // Ensure an assertion is not raised. | 83 // Ensure an assertion is not raised. |
84 request->onError(DOMException::create(AbortError, "Description goes here.")); | 84 request->onError(DOMException::create(AbortError, "Description goes here.")); |
85 | 85 |
86 // Stop the request lest it be GCed and its destructor | 86 // Stop the request lest it be GCed and its destructor |
87 // finds the object in a pending state (and asserts.) | 87 // finds the object in a pending state (and asserts.) |
88 scope.getExecutionContext()->stopActiveDOMObjects(); | 88 scope.getExecutionContext()->notifyContextDestroyed(); |
89 } | 89 } |
90 | 90 |
91 TEST(IDBRequestTest, ConnectionsAfterStopping) { | 91 TEST(IDBRequestTest, ConnectionsAfterStopping) { |
92 V8TestingScope scope; | 92 V8TestingScope scope; |
93 const int64_t transactionId = 1234; | 93 const int64_t transactionId = 1234; |
94 const int64_t version = 1; | 94 const int64_t version = 1; |
95 const int64_t oldVersion = 0; | 95 const int64_t oldVersion = 0; |
96 const IDBDatabaseMetadata metadata; | 96 const IDBDatabaseMetadata metadata; |
97 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create(); | 97 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create(); |
98 | 98 |
99 { | 99 { |
100 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 100 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
101 EXPECT_CALL(*backend, abort(transactionId)).Times(1); | 101 EXPECT_CALL(*backend, abort(transactionId)).Times(1); |
102 EXPECT_CALL(*backend, close()).Times(1); | 102 EXPECT_CALL(*backend, close()).Times(1); |
103 IDBOpenDBRequest* request = IDBOpenDBRequest::create( | 103 IDBOpenDBRequest* request = IDBOpenDBRequest::create( |
104 scope.getScriptState(), callbacks, transactionId, version); | 104 scope.getScriptState(), callbacks, transactionId, version); |
105 EXPECT_EQ(request->readyState(), "pending"); | 105 EXPECT_EQ(request->readyState(), "pending"); |
106 | 106 |
107 scope.getExecutionContext()->stopActiveDOMObjects(); | 107 scope.getExecutionContext()->notifyContextDestroyed(); |
108 request->onUpgradeNeeded(oldVersion, std::move(backend), metadata, | 108 request->onUpgradeNeeded(oldVersion, std::move(backend), metadata, |
109 WebIDBDataLossNone, String()); | 109 WebIDBDataLossNone, String()); |
110 } | 110 } |
111 | 111 |
112 { | 112 { |
113 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 113 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
114 EXPECT_CALL(*backend, close()).Times(1); | 114 EXPECT_CALL(*backend, close()).Times(1); |
115 IDBOpenDBRequest* request = IDBOpenDBRequest::create( | 115 IDBOpenDBRequest* request = IDBOpenDBRequest::create( |
116 scope.getScriptState(), callbacks, transactionId, version); | 116 scope.getScriptState(), callbacks, transactionId, version); |
117 EXPECT_EQ(request->readyState(), "pending"); | 117 EXPECT_EQ(request->readyState(), "pending"); |
118 | 118 |
119 scope.getExecutionContext()->stopActiveDOMObjects(); | 119 scope.getExecutionContext()->notifyContextDestroyed(); |
120 request->onSuccess(std::move(backend), metadata); | 120 request->onSuccess(std::move(backend), metadata); |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 } // namespace | 124 } // namespace |
125 } // namespace blink | 125 } // namespace blink |
OLD | NEW |