OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/host_var_tracker.h" | 5 #include "content/renderer/pepper/host_var_tracker.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/test/scoped_async_task_scheduler.h" |
10 #include "content/renderer/pepper/host_globals.h" | 11 #include "content/renderer/pepper/host_globals.h" |
11 #include "content/renderer/pepper/mock_resource.h" | 12 #include "content/renderer/pepper/mock_resource.h" |
12 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 13 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
13 #include "content/renderer/pepper/pepper_try_catch.h" | 14 #include "content/renderer/pepper/pepper_try_catch.h" |
14 #include "content/renderer/pepper/v8_var_converter.h" | 15 #include "content/renderer/pepper/v8_var_converter.h" |
15 #include "content/renderer/pepper/v8object_var.h" | 16 #include "content/renderer/pepper/v8object_var.h" |
16 #include "content/test/ppapi_unittest.h" | 17 #include "content/test/ppapi_unittest.h" |
17 #include "gin/handle.h" | 18 #include "gin/handle.h" |
18 #include "gin/wrappable.h" | 19 #include "gin/wrappable.h" |
19 #include "ppapi/c/pp_var.h" | 20 #include "ppapi/c/pp_var.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 HostVarTrackerTest() {} | 73 HostVarTrackerTest() {} |
73 | 74 |
74 void TearDown() override { | 75 void TearDown() override { |
75 v8::Isolate::GetCurrent()->RequestGarbageCollectionForTesting( | 76 v8::Isolate::GetCurrent()->RequestGarbageCollectionForTesting( |
76 v8::Isolate::kFullGarbageCollection); | 77 v8::Isolate::kFullGarbageCollection); |
77 EXPECT_EQ(0, g_v8objects_alive); | 78 EXPECT_EQ(0, g_v8objects_alive); |
78 PpapiUnittest::TearDown(); | 79 PpapiUnittest::TearDown(); |
79 } | 80 } |
80 | 81 |
81 HostVarTracker& tracker() { return *HostGlobals::Get()->host_var_tracker(); } | 82 HostVarTracker& tracker() { return *HostGlobals::Get()->host_var_tracker(); } |
| 83 |
| 84 private: |
| 85 // Required by gin::V8Platform::CallOnBackgroundThread(). Can't be a |
| 86 // ScopedTaskScheduler because v8 synchronously waits for tasks to run. |
| 87 base::test::ScopedAsyncTaskScheduler scoped_async_task_scheduler_; |
82 }; | 88 }; |
83 | 89 |
84 TEST_F(HostVarTrackerTest, DeleteObjectVarWithInstance) { | 90 TEST_F(HostVarTrackerTest, DeleteObjectVarWithInstance) { |
85 v8::Isolate* test_isolate = v8::Isolate::GetCurrent(); | 91 v8::Isolate* test_isolate = v8::Isolate::GetCurrent(); |
86 | 92 |
87 // Make a second instance (the test harness already creates & manages one). | 93 // Make a second instance (the test harness already creates & manages one). |
88 scoped_refptr<PepperPluginInstanceImpl> instance2( | 94 scoped_refptr<PepperPluginInstanceImpl> instance2( |
89 PepperPluginInstanceImpl::Create(NULL, module(), NULL, GURL())); | 95 PepperPluginInstanceImpl::Create(NULL, module(), NULL, GURL())); |
90 PP_Instance pp_instance2 = instance2->pp_instance(); | 96 PP_Instance pp_instance2 = instance2->pp_instance(); |
91 | 97 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 pp_object1 = ppapi::ScopedPPVar(); | 139 pp_object1 = ppapi::ScopedPPVar(); |
134 pp_object2 = ppapi::ScopedPPVar(); | 140 pp_object2 = ppapi::ScopedPPVar(); |
135 | 141 |
136 // Releasing the resource should free the internal ref, and so making a new | 142 // Releasing the resource should free the internal ref, and so making a new |
137 // one now should generate a new ID. | 143 // one now should generate a new ID. |
138 ppapi::ScopedPPVar pp_object3 = try_catch.FromV8(v8_object); | 144 ppapi::ScopedPPVar pp_object3 = try_catch.FromV8(v8_object); |
139 EXPECT_NE(pp_object1.get().value.as_id, pp_object3.get().value.as_id); | 145 EXPECT_NE(pp_object1.get().value.as_id, pp_object3.get().value.as_id); |
140 } | 146 } |
141 | 147 |
142 } // namespace content | 148 } // namespace content |
OLD | NEW |