Index: test/cctest/test-heap-profiler.cc |
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc |
index d3bcf478fb441f1203d673204c56a43b8dffe4ef..92ad0a4002a1fbd967a3bf03a4324ec8be8c290d 100644 |
--- a/test/cctest/test-heap-profiler.cc |
+++ b/test/cctest/test-heap-profiler.cc |
@@ -833,4 +833,35 @@ TEST(HeapSnapshotsDiff) { |
CHECK(s1_A_id != s2_A_id); |
} |
+ |
+namespace v8 { |
+namespace internal { |
+ |
+class HeapSnapshotTester { |
+ public: |
+ static int CalculateNetworkSize(JSObject* obj) { |
+ return HeapSnapshot::CalculateNetworkSize(obj); |
+ } |
+}; |
+ |
+} } // namespace v8::internal |
+ |
+// http://code.google.com/p/v8/issues/detail?id=822 |
+// Trying to call CalculateNetworkSize on an object with elements set |
+// to non-FixedArray may cause an assertion error in debug builds. |
+TEST(Issue822) { |
+ v8::HandleScope scope; |
+ LocalContext context; |
+ const int kElementCount = 260; |
+ uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount)); |
+ i::Handle<i::PixelArray> pixels = i::Factory::NewPixelArray(kElementCount, |
+ pixel_data); |
+ v8::Handle<v8::Object> obj = v8::Object::New(); |
+ // Set the elements to be the pixels. |
+ obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); |
+ i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); |
+ // This call must not cause an assertion error in debug builds. |
+ i::HeapSnapshotTester::CalculateNetworkSize(*jsobj); |
+} |
+ |
#endif // ENABLE_LOGGING_AND_PROFILING |