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