Commit 07b0574a authored by Jakob Linke's avatar Jakob Linke Committed by V8 LUCI CQ

Revert "[test] Migrate cctest/test-inspector to unittests/"

This reverts commit 437b311a.

Reason for revert: Causes issues for other CLs: https://ci.chromium.org/ui/p/v8/builders/try/v8_linux_chromium_gn_rel/76508/overview

Original change's description:
> [test] Migrate cctest/test-inspector to unittests/
>
> test-inspector.cc -> inspector-unittest.cc
>
> Bug: v8:12781
> Change-Id: I37d2bc2d023ffd91b94d5a09cdbfe4a6e22fecf1
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3813062
> Reviewed-by: Jakob Linke <jgruber@chromium.org>
> Commit-Queue: Jakob Linke <jgruber@chromium.org>
> Reviewed-by: Hannes Payer <hpayer@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#82512}

Bug: v8:12781
Change-Id: I3355e5828814fdd489f7d31ecb694419b95f9c5b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3829939Reviewed-by: 's avatarLiviu Rau <liviurau@google.com>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#82516}
parent a4840410
......@@ -20,7 +20,6 @@ no_check_targets = [
"//:v8_internal_headers",
"//src/inspector:inspector",
"//test/cctest:cctest_sources",
"//test/unittests:unittests_sources",
"//third_party/icu:*",
]
......
......@@ -188,6 +188,7 @@ v8_source_set("cctest_sources") {
"test-icache.cc",
"test-ignition-statistics-extension.cc",
"test-inobject-slack-tracking.cc",
"test-inspector.cc",
"test-js-weak-refs.cc",
"test-liveedit.cc",
"test-lockers.cc",
......
......@@ -9,8 +9,7 @@
#include "include/v8-primitive.h"
#include "src/inspector/string-util.h"
#include "src/inspector/v8-inspector-impl.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "test/cctest/cctest.h"
using v8_inspector::String16;
using v8_inspector::StringBuffer;
......@@ -21,11 +20,6 @@ using v8_inspector::V8ContextInfo;
using v8_inspector::V8Inspector;
using v8_inspector::V8InspectorSession;
namespace v8 {
namespace internal {
using InspectorTest = TestWithContext;
namespace {
class NoopChannel : public V8Inspector::Channel {
......@@ -48,8 +42,9 @@ void WrapOnInterrupt(v8::Isolate* isolate, void* data) {
} // namespace
TEST_F(InspectorTest, WrapInsideWrapOnInterrupt) {
v8::Isolate* isolate = v8_isolate();
TEST(WrapInsideWrapOnInterrupt) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope handle_scope(isolate);
v8_inspector::V8InspectorClient default_client;
......@@ -57,7 +52,7 @@ TEST_F(InspectorTest, WrapInsideWrapOnInterrupt) {
V8Inspector::create(isolate, &default_client);
const char* name = "";
StringView name_view(reinterpret_cast<const uint8_t*>(name), strlen(name));
V8ContextInfo context_info(v8_context(), 1, name_view);
V8ContextInfo context_info(env.local(), 1, name_view);
inspector->contextCreated(context_info);
NoopChannel channel;
......@@ -70,11 +65,10 @@ TEST_F(InspectorTest, WrapInsideWrapOnInterrupt) {
StringView object_group_view(reinterpret_cast<const uint8_t*>(object_group),
strlen(object_group));
isolate->RequestInterrupt(&WrapOnInterrupt, session.get());
session->wrapObject(v8_context(), v8::Null(isolate), object_group_view,
false);
session->wrapObject(env.local(), v8::Null(isolate), object_group_view, false);
}
TEST_F(InspectorTest, BinaryFromBase64) {
TEST(BinaryFromBase64) {
auto checkBinary = [](const v8_inspector::protocol::Binary& binary,
const std::vector<uint8_t>& values) {
std::vector<uint8_t> binary_vector(binary.data(),
......@@ -139,7 +133,7 @@ TEST_F(InspectorTest, BinaryFromBase64) {
}
}
TEST_F(InspectorTest, BinaryToBase64) {
TEST(BinaryToBase64) {
uint8_t input[] = {'a', 'b', 'c'};
{
auto binary = v8_inspector::protocol::Binary::fromSpan(input, 0);
......@@ -163,7 +157,7 @@ TEST_F(InspectorTest, BinaryToBase64) {
}
}
TEST_F(InspectorTest, BinaryBase64RoundTrip) {
TEST(BinaryBase64RoundTrip) {
std::array<uint8_t, 256> values;
for (uint16_t b = 0x0; b <= 0xFF; ++b) values[b] = b;
auto binary =
......@@ -179,18 +173,20 @@ TEST_F(InspectorTest, BinaryBase64RoundTrip) {
}
}
TEST_F(InspectorTest, NoInterruptOnGetAssociatedData) {
v8::Isolate* isolate = v8_isolate();
TEST(NoInterruptOnGetAssociatedData) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope handle_scope(isolate);
v8_inspector::V8InspectorClient default_client;
std::unique_ptr<v8_inspector::V8InspectorImpl> inspector(
new v8_inspector::V8InspectorImpl(isolate, &default_client));
v8::Local<v8::Value> error = v8::Exception::Error(NewString("custom error"));
v8::Local<v8::Name> key = NewString("key");
v8::Local<v8::Value> value = NewString("value");
inspector->associateExceptionData(v8_context(), error, key, value);
v8::Local<v8::Context> context = env->GetIsolate()->GetCurrentContext();
v8::Local<v8::Value> error = v8::Exception::Error(v8_str("custom error"));
v8::Local<v8::Name> key = v8_str("key");
v8::Local<v8::Value> value = v8_str("value");
inspector->associateExceptionData(context, error, key, value);
struct InterruptRecorder {
static void handler(v8::Isolate* isolate, void* data) {
......@@ -206,20 +202,21 @@ TEST_F(InspectorTest, NoInterruptOnGetAssociatedData) {
inspector->getAssociatedExceptionData(error).ToLocalChecked();
CHECK(!recorder.WasInvoked);
CHECK_EQ(data->Get(v8_context(), key).ToLocalChecked(), value);
CHECK_EQ(data->Get(context, key).ToLocalChecked(), value);
TryRunJS("0");
CompileRun("0");
CHECK(recorder.WasInvoked);
}
TEST_F(InspectorTest, NoConsoleAPIForUntrustedClient) {
v8::Isolate* isolate = v8_isolate();
TEST(NoConsoleAPIForUntrustedClient) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope handle_scope(isolate);
v8_inspector::V8InspectorClient default_client;
std::unique_ptr<V8Inspector> inspector =
V8Inspector::create(isolate, &default_client);
V8ContextInfo context_info(v8_context(), 1, toStringView(""));
V8ContextInfo context_info(env.local(), 1, toStringView(""));
inspector->contextCreated(context_info);
class TestChannel : public V8Inspector::Channel {
......@@ -258,15 +255,16 @@ TEST_F(InspectorTest, NoConsoleAPIForUntrustedClient) {
untrusted_session->dispatchProtocolMessage(toStringView(kCommand));
}
TEST_F(InspectorTest, ApiCreatedTasksAreCleanedUp) {
TEST(ApiCreatedTasksAreCleanedUp) {
i::FLAG_experimental_async_stack_tagging_api = true;
v8::Isolate* isolate = v8_isolate();
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope handle_scope(isolate);
v8_inspector::V8InspectorClient default_client;
std::unique_ptr<v8_inspector::V8InspectorImpl> inspector =
std::make_unique<v8_inspector::V8InspectorImpl>(isolate, &default_client);
V8ContextInfo context_info(v8_context(), 1, toStringView(""));
V8ContextInfo context_info(env.local(), 1, toStringView(""));
inspector->contextCreated(context_info);
// Trigger V8Console creation.
......@@ -275,22 +273,19 @@ TEST_F(InspectorTest, ApiCreatedTasksAreCleanedUp) {
{
v8::HandleScope handle_scope(isolate);
v8::MaybeLocal<v8::Value> result = TryRunJS(isolate, NewString(R"(
v8::MaybeLocal<v8::Value> result = CompileRun(env.local(), R"(
globalThis['task'] = console.createTask('Task');
)"));
)");
CHECK(!result.IsEmpty());
// Run GC and check that the task is still here.
CollectAllGarbage();
CcTest::CollectAllGarbage();
CHECK_EQ(console->AllConsoleTasksForTest().size(), 1);
}
// Get rid of the task on the context, run GC and check we no longer have
// the TaskInfo in the inspector.
v8_context()->Global()->Delete(v8_context(), NewString("task")).Check();
CollectAllGarbage();
env->Global()->Delete(env.local(), v8_str("task")).Check();
CcTest::CollectAllGarbage();
CHECK_EQ(console->AllConsoleTasksForTest().size(), 0);
}
} // namespace internal
} // namespace v8
......@@ -394,7 +394,6 @@ v8_source_set("unittests_sources") {
"heap/slot-set-unittest.cc",
"heap/spaces-unittest.cc",
"heap/unmapper-unittest.cc",
"inspector/inspector-unittest.cc",
"interpreter/bytecode-array-builder-unittest.cc",
"interpreter/bytecode-array-iterator-unittest.cc",
"interpreter/bytecode-array-random-iterator-unittest.cc",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment