| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "content/renderer/pepper/host_globals.h" | 7 #include "content/renderer/pepper/host_globals.h" |
| 8 #include "content/renderer/pepper/host_var_tracker.h" | 8 #include "content/renderer/pepper/host_var_tracker.h" |
| 9 #include "content/renderer/pepper/mock_resource.h" | 9 #include "content/renderer/pepper/mock_resource.h" |
| 10 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 10 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 EXPECT_EQ(1, tracker().GetLiveV8ObjectVarsForTest(pp_instance2)); | 93 EXPECT_EQ(1, tracker().GetLiveV8ObjectVarsForTest(pp_instance2)); |
| 94 // Purposely leak the var. | 94 // Purposely leak the var. |
| 95 var.Release(); | 95 var.Release(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 // Free the instance, this should release the ObjectVar. | 98 // Free the instance, this should release the ObjectVar. |
| 99 instance2 = NULL; | 99 instance2 = NULL; |
| 100 EXPECT_EQ(0, tracker().GetLiveV8ObjectVarsForTest(pp_instance2)); | 100 EXPECT_EQ(0, tracker().GetLiveV8ObjectVarsForTest(pp_instance2)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Make sure that using the same NPObject should give the same PP_Var | 103 // Make sure that using the same v8 object should give the same PP_Var |
| 104 // each time. | 104 // each time. |
| 105 TEST_F(HostVarTrackerTest, ReuseVar) { | 105 TEST_F(HostVarTrackerTest, ReuseVar) { |
| 106 PepperTryCatchForTest try_catch(instance()); | 106 PepperTryCatchForTest try_catch(instance()); |
| 107 | 107 |
| 108 v8::Handle<v8::Value> v8_object = MyObject::Create(v8::Isolate::GetCurrent()); | 108 v8::Handle<v8::Value> v8_object = MyObject::Create(v8::Isolate::GetCurrent()); |
| 109 ppapi::ScopedPPVar pp_object1 = try_catch.FromV8(v8_object); | 109 ppapi::ScopedPPVar pp_object1 = try_catch.FromV8(v8_object); |
| 110 ppapi::ScopedPPVar pp_object2 = try_catch.FromV8(v8_object); | 110 ppapi::ScopedPPVar pp_object2 = try_catch.FromV8(v8_object); |
| 111 | 111 |
| 112 // The two results should be the same. | 112 // The two results should be the same. |
| 113 EXPECT_EQ(pp_object1.get().value.as_id, pp_object2.get().value.as_id); | 113 EXPECT_EQ(pp_object1.get().value.as_id, pp_object2.get().value.as_id); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 125 pp_object1 = ppapi::ScopedPPVar(); | 125 pp_object1 = ppapi::ScopedPPVar(); |
| 126 pp_object2 = ppapi::ScopedPPVar(); | 126 pp_object2 = ppapi::ScopedPPVar(); |
| 127 | 127 |
| 128 // Releasing the resource should free the internal ref, and so making a new | 128 // Releasing the resource should free the internal ref, and so making a new |
| 129 // one now should generate a new ID. | 129 // one now should generate a new ID. |
| 130 ppapi::ScopedPPVar pp_object3 = try_catch.FromV8(v8_object); | 130 ppapi::ScopedPPVar pp_object3 = try_catch.FromV8(v8_object); |
| 131 EXPECT_NE(pp_object1.get().value.as_id, pp_object3.get().value.as_id); | 131 EXPECT_NE(pp_object1.get().value.as_id, pp_object3.get().value.as_id); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace content | 134 } // namespace content |
| OLD | NEW |