| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 class IDBRequestTest : public testing::Test { | 74 class IDBRequestTest : public testing::Test { |
| 75 public: | 75 public: |
| 76 IDBRequestTest() | 76 IDBRequestTest() |
| 77 : m_scope(V8ExecutionScope::create(v8::Isolate::GetCurrent())) | 77 : m_scope(V8ExecutionScope::create(v8::Isolate::GetCurrent())) |
| 78 , m_context(adoptRef(new NullExecutionContext())) | 78 , m_context(adoptRef(new NullExecutionContext())) |
| 79 { | 79 { |
| 80 } | 80 } |
| 81 | 81 |
| 82 v8::Isolate* isolate() const { return m_scope->isolate(); } |
| 83 |
| 82 ExecutionContext* executionContext() | 84 ExecutionContext* executionContext() |
| 83 { | 85 { |
| 84 return m_context.get(); | 86 return m_context.get(); |
| 85 } | 87 } |
| 86 | 88 |
| 87 private: | 89 private: |
| 88 OwnPtr<V8ExecutionScope> m_scope; | 90 OwnPtr<V8ExecutionScope> m_scope; |
| 89 RefPtr<ExecutionContext> m_context; | 91 RefPtr<ExecutionContext> m_context; |
| 90 }; | 92 }; |
| 91 | 93 |
| 92 TEST_F(IDBRequestTest, EventsAfterStopping) | 94 TEST_F(IDBRequestTest, EventsAfterStopping) |
| 93 { | 95 { |
| 94 IDBTransaction* transaction = 0; | 96 IDBTransaction* transaction = 0; |
| 95 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(executionContext
(), IDBAny::createUndefined(), transaction); | 97 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(ScriptState::cur
rent(isolate()), IDBAny::createUndefined(), transaction); |
| 96 EXPECT_EQ(request->readyState(), "pending"); | 98 EXPECT_EQ(request->readyState(), "pending"); |
| 97 executionContext()->stopActiveDOMObjects(); | 99 executionContext()->stopActiveDOMObjects(); |
| 98 | 100 |
| 99 // Ensure none of the following raise assertions in stopped state: | 101 // Ensure none of the following raise assertions in stopped state: |
| 100 request->onError(DOMError::create(AbortError, "Description goes here.")); | 102 request->onError(DOMError::create(AbortError, "Description goes here.")); |
| 101 request->onSuccess(Vector<String>()); | 103 request->onSuccess(Vector<String>()); |
| 102 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid()
, nullptr, adoptPtr(new Vector<WebBlobInfo>())); | 104 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid()
, nullptr, adoptPtr(new Vector<WebBlobInfo>())); |
| 103 request->onSuccess(IDBKey::createInvalid()); | 105 request->onSuccess(IDBKey::createInvalid()); |
| 104 request->onSuccess(PassRefPtr<SharedBuffer>(nullptr), adoptPtr(new Vector<We
bBlobInfo>())); | 106 request->onSuccess(PassRefPtr<SharedBuffer>(nullptr), adoptPtr(new Vector<We
bBlobInfo>())); |
| 105 request->onSuccess(PassRefPtr<SharedBuffer>(nullptr), adoptPtr(new Vector<We
bBlobInfo>()), IDBKey::createInvalid(), IDBKeyPath()); | 107 request->onSuccess(PassRefPtr<SharedBuffer>(nullptr), adoptPtr(new Vector<We
bBlobInfo>()), IDBKey::createInvalid(), IDBKeyPath()); |
| 106 request->onSuccess(0LL); | 108 request->onSuccess(0LL); |
| 107 request->onSuccess(); | 109 request->onSuccess(); |
| 108 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), nullptr
, adoptPtr(new Vector<WebBlobInfo>())); | 110 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), nullptr
, adoptPtr(new Vector<WebBlobInfo>())); |
| 109 } | 111 } |
| 110 | 112 |
| 111 TEST_F(IDBRequestTest, AbortErrorAfterAbort) | 113 TEST_F(IDBRequestTest, AbortErrorAfterAbort) |
| 112 { | 114 { |
| 113 IDBTransaction* transaction = 0; | 115 IDBTransaction* transaction = 0; |
| 114 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(executionContext
(), IDBAny::createUndefined(), transaction); | 116 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(ScriptState::cur
rent(isolate()), IDBAny::createUndefined(), transaction); |
| 115 EXPECT_EQ(request->readyState(), "pending"); | 117 EXPECT_EQ(request->readyState(), "pending"); |
| 116 | 118 |
| 117 // Simulate the IDBTransaction having received onAbort from back end and abo
rting the request: | 119 // Simulate the IDBTransaction having received onAbort from back end and abo
rting the request: |
| 118 request->abort(); | 120 request->abort(); |
| 119 | 121 |
| 120 // Now simulate the back end having fired an abort error at the request to c
lear up any intermediaries. | 122 // Now simulate the back end having fired an abort error at the request to c
lear up any intermediaries. |
| 121 // Ensure an assertion is not raised. | 123 // Ensure an assertion is not raised. |
| 122 request->onError(DOMError::create(AbortError, "Description goes here.")); | 124 request->onError(DOMError::create(AbortError, "Description goes here.")); |
| 123 } | 125 } |
| 124 | 126 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 151 TEST_F(IDBRequestTest, ConnectionsAfterStopping) | 153 TEST_F(IDBRequestTest, ConnectionsAfterStopping) |
| 152 { | 154 { |
| 153 const int64_t transactionId = 1234; | 155 const int64_t transactionId = 1234; |
| 154 const int64_t version = 1; | 156 const int64_t version = 1; |
| 155 const int64_t oldVersion = 0; | 157 const int64_t oldVersion = 0; |
| 156 const IDBDatabaseMetadata metadata; | 158 const IDBDatabaseMetadata metadata; |
| 157 RefPtrWillBePersistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallback
s::create(); | 159 RefPtrWillBePersistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallback
s::create(); |
| 158 | 160 |
| 159 { | 161 { |
| 160 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 162 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
| 161 RefPtrWillBeRawPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(
executionContext(), callbacks, transactionId, version); | 163 RefPtrWillBeRawPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(
ScriptState::current(isolate()), callbacks, transactionId, version); |
| 162 EXPECT_EQ(request->readyState(), "pending"); | 164 EXPECT_EQ(request->readyState(), "pending"); |
| 163 | 165 |
| 164 executionContext()->stopActiveDOMObjects(); | 166 executionContext()->stopActiveDOMObjects(); |
| 165 request->onUpgradeNeeded(oldVersion, backend.release(), metadata, blink:
:WebIDBDataLossNone, String()); | 167 request->onUpgradeNeeded(oldVersion, backend.release(), metadata, blink:
:WebIDBDataLossNone, String()); |
| 166 } | 168 } |
| 167 | 169 |
| 168 { | 170 { |
| 169 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 171 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
| 170 RefPtrWillBeRawPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(
executionContext(), callbacks, transactionId, version); | 172 RefPtrWillBeRawPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(
ScriptState::current(isolate()), callbacks, transactionId, version); |
| 171 EXPECT_EQ(request->readyState(), "pending"); | 173 EXPECT_EQ(request->readyState(), "pending"); |
| 172 | 174 |
| 173 executionContext()->stopActiveDOMObjects(); | 175 executionContext()->stopActiveDOMObjects(); |
| 174 request->onSuccess(backend.release(), metadata); | 176 request->onSuccess(backend.release(), metadata); |
| 175 } | 177 } |
| 176 } | 178 } |
| 177 | 179 |
| 178 } // namespace | 180 } // namespace |
| OLD | NEW |