From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../tests/gtest/SerializesEdgeNames.cpp | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 devtools/shared/heapsnapshot/tests/gtest/SerializesEdgeNames.cpp (limited to 'devtools/shared/heapsnapshot/tests/gtest/SerializesEdgeNames.cpp') diff --git a/devtools/shared/heapsnapshot/tests/gtest/SerializesEdgeNames.cpp b/devtools/shared/heapsnapshot/tests/gtest/SerializesEdgeNames.cpp new file mode 100644 index 0000000000..ab47941e39 --- /dev/null +++ b/devtools/shared/heapsnapshot/tests/gtest/SerializesEdgeNames.cpp @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// Test that edge names get serialized correctly. + +#include "DevTools.h" + +using testing::Field; +using testing::IsNull; +using testing::Property; +using testing::Return; + +DEF_TEST(SerializesEdgeNames, { + FakeNode node; + FakeNode referent; + + const char16_t edgeName[] = u"edge name"; + const char16_t emptyStr[] = u""; + + AddEdge(node, referent, edgeName); + AddEdge(node, referent, emptyStr); + AddEdge(node, referent, nullptr); + + ::testing::NiceMock writer; + + // Should get the node with edges once. + EXPECT_CALL( + writer, + writeNode( + AllOf(EdgesLength(cx, 3), + Edge(cx, 0, + Field(&JS::ubi::Edge::name, UniqueUTF16StrEq(edgeName))), + Edge(cx, 1, + Field(&JS::ubi::Edge::name, UniqueUTF16StrEq(emptyStr))), + Edge(cx, 2, Field(&JS::ubi::Edge::name, UniqueIsNull()))), + _)) + .Times(1) + .WillOnce(Return(true)); + + // Should get the referent node that doesn't have any edges once. + ExpectWriteNode(writer, referent); + + JS::AutoCheckCannotGC noGC(cx); + ASSERT_TRUE(WriteHeapGraph(cx, JS::ubi::Node(&node), writer, + /* wantNames = */ true, + /* zones = */ nullptr, noGC)); +}); -- cgit v1.2.3