| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/weak_ptr.h" | 6 #include "base/memory/weak_ptr.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "extensions/common/extension.h" | 8 #include "extensions/common/extension.h" |
| 9 #include "extensions/common/extension_set.h" | 9 #include "extensions/common/extension_set.h" |
| 10 #include "extensions/common/features/feature.h" | 10 #include "extensions/common/features/feature.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 void SetToTrue(bool* value) { | 24 void SetToTrue(bool* value) { |
| 25 if (*value) | 25 if (*value) |
| 26 ADD_FAILURE() << "Value is already true"; | 26 ADD_FAILURE() << "Value is already true"; |
| 27 *value = true; | 27 *value = true; |
| 28 } | 28 } |
| 29 | 29 |
| 30 class GCCallbackTest : public testing::Test { | 30 class GCCallbackTest : public testing::Test { |
| 31 public: | 31 public: |
| 32 GCCallbackTest() : script_context_set_(&extensions_, &active_extensions_) {} | 32 GCCallbackTest() : script_context_set_(&active_extensions_) {} |
| 33 | 33 |
| 34 protected: | 34 protected: |
| 35 base::MessageLoop& message_loop() { return message_loop_; } | 35 base::MessageLoop& message_loop() { return message_loop_; } |
| 36 | 36 |
| 37 ScriptContextSet& script_context_set() { return script_context_set_; } | 37 ScriptContextSet& script_context_set() { return script_context_set_; } |
| 38 | 38 |
| 39 v8::Local<v8::Context> v8_context() { | 39 v8::Local<v8::Context> v8_context() { |
| 40 return v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), v8_context_); | 40 return v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), v8_context_); |
| 41 } | 41 } |
| 42 | 42 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 void TearDown() override { | 67 void TearDown() override { |
| 68 gin_context_holder_.reset(); | 68 gin_context_holder_.reset(); |
| 69 v8_context_.Reset(); | 69 v8_context_.Reset(); |
| 70 RequestGarbageCollection(); | 70 RequestGarbageCollection(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 base::MessageLoop message_loop_; | 73 base::MessageLoop message_loop_; |
| 74 ScopedWebFrame web_frame_; // (this will construct the v8::Isolate) | 74 ScopedWebFrame web_frame_; // (this will construct the v8::Isolate) |
| 75 ExtensionSet extensions_; | |
| 76 ExtensionIdSet active_extensions_; | 75 ExtensionIdSet active_extensions_; |
| 77 ScriptContextSet script_context_set_; | 76 ScriptContextSet script_context_set_; |
| 78 v8::Global<v8::Context> v8_context_; | 77 v8::Global<v8::Context> v8_context_; |
| 79 scoped_ptr<gin::ContextHolder> gin_context_holder_; | 78 scoped_ptr<gin::ContextHolder> gin_context_holder_; |
| 80 | 79 |
| 81 DISALLOW_COPY_AND_ASSIGN(GCCallbackTest); | 80 DISALLOW_COPY_AND_ASSIGN(GCCallbackTest); |
| 82 }; | 81 }; |
| 83 | 82 |
| 84 TEST_F(GCCallbackTest, GCBeforeContextInvalidated) { | 83 TEST_F(GCCallbackTest, GCBeforeContextInvalidated) { |
| 85 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 84 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // Trigger a GC. The callback should not be invoked because the fallback was | 151 // Trigger a GC. The callback should not be invoked because the fallback was |
| 153 // already invoked. | 152 // already invoked. |
| 154 RequestGarbageCollection(); | 153 RequestGarbageCollection(); |
| 155 message_loop().RunUntilIdle(); | 154 message_loop().RunUntilIdle(); |
| 156 | 155 |
| 157 EXPECT_FALSE(callback_invoked); | 156 EXPECT_FALSE(callback_invoked); |
| 158 } | 157 } |
| 159 | 158 |
| 160 } // namespace | 159 } // namespace |
| 161 } // namespace extensions | 160 } // namespace extensions |
| OLD | NEW |