| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "modules/indexeddb/IDBTransaction.h" | 32 #include "modules/indexeddb/IDBTransaction.h" |
| 33 | 33 |
| 34 #include "core/dom/DOMError.h" | 34 #include "core/dom/DOMError.h" |
| 35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
| 36 #include "modules/indexeddb/IDBDatabase.h" | 36 #include "modules/indexeddb/IDBDatabase.h" |
| 37 #include "modules/indexeddb/IDBDatabaseCallbacks.h" | 37 #include "modules/indexeddb/IDBDatabaseCallbacks.h" |
| 38 #include "modules/indexeddb/IDBPendingTransactionMonitor.h" | 38 #include "modules/indexeddb/IDBPendingTransactionMonitor.h" |
| 39 #include "platform/SharedBuffer.h" | 39 #include "platform/SharedBuffer.h" |
| 40 #include "public/platform/WebIDBDatabase.h" |
| 40 | 41 |
| 41 #include <gtest/gtest.h> | 42 #include <gtest/gtest.h> |
| 42 | 43 |
| 43 using namespace WebCore; | 44 using namespace WebCore; |
| 44 | 45 |
| 45 using blink::WebData; | |
| 46 using blink::WebIDBCallbacks; | |
| 47 using blink::WebIDBDatabase; | |
| 48 using blink::WebIDBDatabaseCallbacks; | |
| 49 using blink::WebIDBKey; | |
| 50 using blink::WebIDBKeyPath; | |
| 51 using blink::WebIDBKeyRange; | |
| 52 using blink::WebString; | |
| 53 using blink::WebVector; | |
| 54 | |
| 55 namespace { | 46 namespace { |
| 56 | 47 |
| 57 class IDBTransactionTest : public testing::Test { | 48 class IDBTransactionTest : public testing::Test { |
| 58 public: | 49 public: |
| 59 IDBTransactionTest() | 50 IDBTransactionTest() |
| 60 : m_handleScope(v8::Isolate::GetCurrent()) | 51 : m_handleScope(v8::Isolate::GetCurrent()) |
| 61 , m_scope(v8::Context::New(v8::Isolate::GetCurrent())) | 52 , m_scope(v8::Context::New(v8::Isolate::GetCurrent())) |
| 62 , m_document(Document::create()) | 53 , m_document(Document::create()) |
| 63 { | 54 { |
| 64 } | 55 } |
| 65 | 56 |
| 66 ExecutionContext* executionContext() | 57 ExecutionContext* executionContext() |
| 67 { | 58 { |
| 68 return m_document.get(); | 59 return m_document.get(); |
| 69 } | 60 } |
| 70 | 61 |
| 71 private: | 62 private: |
| 72 v8::HandleScope m_handleScope; | 63 v8::HandleScope m_handleScope; |
| 73 v8::Context::Scope m_scope; | 64 v8::Context::Scope m_scope; |
| 74 RefPtr<Document> m_document; | 65 RefPtr<Document> m_document; |
| 75 }; | 66 }; |
| 76 | 67 |
| 77 class FakeWebIDBDatabase : public WebIDBDatabase { | 68 class FakeWebIDBDatabase : public blink::WebIDBDatabase { |
| 78 public: | 69 public: |
| 79 static PassOwnPtr<FakeWebIDBDatabase> create() { return adoptPtr(new FakeWeb
IDBDatabase()); } | 70 static PassOwnPtr<FakeWebIDBDatabase> create() { return adoptPtr(new FakeWeb
IDBDatabase()); } |
| 80 | 71 |
| 81 virtual void commit(long long transactionId) OVERRIDE { } | 72 virtual void commit(long long transactionId) OVERRIDE { } |
| 82 virtual void abort(long long transactionId) OVERRIDE { } | 73 virtual void abort(long long transactionId) OVERRIDE { } |
| 83 virtual void close() OVERRIDE { } | 74 virtual void close() OVERRIDE { } |
| 84 | 75 |
| 85 private: | 76 private: |
| 86 FakeWebIDBDatabase() { } | 77 FakeWebIDBDatabase() { } |
| 87 }; | 78 }; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 141 |
| 151 // Stop the context, so events don't get queued (which would keep the transa
ction alive). | 142 // Stop the context, so events don't get queued (which would keep the transa
ction alive). |
| 152 executionContext()->stopActiveDOMObjects(); | 143 executionContext()->stopActiveDOMObjects(); |
| 153 | 144 |
| 154 // Fire an abort to make sure this doesn't free the transaction during use.
The test | 145 // Fire an abort to make sure this doesn't free the transaction during use.
The test |
| 155 // will not fail if it is, but ASAN would notice the error. | 146 // will not fail if it is, but ASAN would notice the error. |
| 156 db->onAbort(transactionId, DOMError::create(AbortError, "Aborted")); | 147 db->onAbort(transactionId, DOMError::create(AbortError, "Aborted")); |
| 157 } | 148 } |
| 158 | 149 |
| 159 } // namespace | 150 } // namespace |
| OLD | NEW |