| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 NullExecutionContext::NullExecutionContext() | 69 NullExecutionContext::NullExecutionContext() |
| 70 : m_queue(adoptPtr(new NullEventQueue())) | 70 : m_queue(adoptPtr(new NullEventQueue())) |
| 71 { | 71 { |
| 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(v8::Isolate::GetCurrent()) | 77 : m_scope(v8::Isolate::GetCurrent()) |
| 78 , m_executionContext(adoptRef(new NullExecutionContext())) |
| 78 { | 79 { |
| 79 m_scope.scriptState()->setExecutionContext(adoptRef(new NullExecutionCon
text())); | 80 m_scope.scriptState()->setExecutionContext(m_executionContext.get()); |
| 81 } |
| 82 |
| 83 ~IDBRequestTest() |
| 84 { |
| 85 m_scope.scriptState()->setExecutionContext(0); |
| 80 } | 86 } |
| 81 | 87 |
| 82 v8::Isolate* isolate() const { return m_scope.isolate(); } | 88 v8::Isolate* isolate() const { return m_scope.isolate(); } |
| 83 ScriptState* scriptState() const { return m_scope.scriptState(); } | 89 ScriptState* scriptState() const { return m_scope.scriptState(); } |
| 84 ExecutionContext* executionContext() const { return m_scope.scriptState()->e
xecutionContext(); } | 90 ExecutionContext* executionContext() const { return m_scope.scriptState()->e
xecutionContext(); } |
| 85 | 91 |
| 86 private: | 92 private: |
| 87 V8TestingScope m_scope; | 93 V8TestingScope m_scope; |
| 94 RefPtr<ExecutionContext> m_executionContext; |
| 88 }; | 95 }; |
| 89 | 96 |
| 90 TEST_F(IDBRequestTest, EventsAfterStopping) | 97 TEST_F(IDBRequestTest, EventsAfterStopping) |
| 91 { | 98 { |
| 92 IDBTransaction* transaction = 0; | 99 IDBTransaction* transaction = 0; |
| 93 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi
ned(), transaction); | 100 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi
ned(), transaction); |
| 94 EXPECT_EQ(request->readyState(), "pending"); | 101 EXPECT_EQ(request->readyState(), "pending"); |
| 95 executionContext()->stopActiveDOMObjects(); | 102 executionContext()->stopActiveDOMObjects(); |
| 96 | 103 |
| 97 // Ensure none of the following raise assertions in stopped state: | 104 // Ensure none of the following raise assertions in stopped state: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 174 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
| 168 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call
backs, transactionId, version); | 175 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call
backs, transactionId, version); |
| 169 EXPECT_EQ(request->readyState(), "pending"); | 176 EXPECT_EQ(request->readyState(), "pending"); |
| 170 | 177 |
| 171 executionContext()->stopActiveDOMObjects(); | 178 executionContext()->stopActiveDOMObjects(); |
| 172 request->onSuccess(backend.release(), metadata); | 179 request->onSuccess(backend.release(), metadata); |
| 173 } | 180 } |
| 174 } | 181 } |
| 175 | 182 |
| 176 } // namespace | 183 } // namespace |
| OLD | NEW |