Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index a8f340db2e4e89627fa1718cea71b7bf5ca73e88..78151881655a8e270f8f7226aaf51562f1d11ce6 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -5229,7 +5229,9 @@ THREADED_TEST(IndependentWeakHandle) { |
bool object_a_disposed = false; |
object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag); |
+ CHECK(!object_a.IsIndependent()); |
object_a.MarkIndependent(); |
+ CHECK(object_a.IsIndependent()); |
HEAP->PerformScavenge(); |
CHECK(object_a_disposed); |
} |
@@ -16177,6 +16179,43 @@ TEST(DontDeleteCellLoadICAPI) { |
} |
+TEST(PersistentHandleVisitor) { |
+ v8::HandleScope scope; |
+ LocalContext context; |
+ v8::Persistent<v8::Object> object = |
+ v8::Persistent<v8::Object>::New(v8::Object::New()); |
+ CHECK_EQ(0, object.WrapperClassId()); |
+ object.SetWrapperClassId(42); |
+ CHECK_EQ(42, object.WrapperClassId()); |
+ |
+ class Visitor : public v8::PersistentHandleVisitor { |
+ public: |
+ explicit Visitor(v8::Persistent<v8::Object> object) |
+ : counter_(0), object_(object) { } |
+ |
+ virtual void VisitPersistentHandle(Persistent<Value> value, |
+ uint16_t class_id) { |
+ if (class_id == 42) { |
+ CHECK(value->IsObject()); |
+ v8::Persistent<v8::Object> visited = |
+ v8::Persistent<v8::Object>::Cast(value); |
+ CHECK_EQ(42, visited.WrapperClassId()); |
+ CHECK_EQ(object_, visited); |
+ ++counter_; |
+ } |
+ } |
+ |
+ int counter_; |
+ v8::Persistent<v8::Object> object_; |
+ } visitor(object); |
+ |
+ v8::V8::VisitHandlesWithClassIds(&visitor); |
+ CHECK_EQ(1, visitor.counter_); |
+ |
+ object.Dispose(); |
+} |
+ |
+ |
TEST(RegExp) { |
v8::HandleScope scope; |
LocalContext context; |