SerializesEverythingInHeapGraphOnce.cpp (1047B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 // Test that everything in the heap graph gets serialized once, and only once. 7 8 #include "DevTools.h" 9 10 DEF_TEST(SerializesEverythingInHeapGraphOnce, { 11 FakeNode nodeA; 12 FakeNode nodeB; 13 FakeNode nodeC; 14 FakeNode nodeD; 15 16 AddEdge(nodeA, nodeB); 17 AddEdge(nodeB, nodeC); 18 AddEdge(nodeC, nodeD); 19 AddEdge(nodeD, nodeA); 20 21 ::testing::NiceMock<MockWriter> writer; 22 23 // Should serialize each node once. 24 ExpectWriteNode(writer, nodeA); 25 ExpectWriteNode(writer, nodeB); 26 ExpectWriteNode(writer, nodeC); 27 ExpectWriteNode(writer, nodeD); 28 29 JS::AutoCheckCannotGC noGC(cx); 30 31 ASSERT_TRUE(WriteHeapGraph(cx, JS::ubi::Node(&nodeA), writer, 32 /* wantNames = */ false, 33 /* zones = */ nullptr, noGC)); 34 });