Skip to content

Commit 30600f7

Browse files
motiz88meta-codesync[bot]
authored andcommitted
Add integration tests for multi-session Debugger.enable (#55542)
Summary: Pull Request resolved: #55542 Adds tests demonstrating that all target versions of Hermes (Legacy Hermes, Static Hermes stable, Static Hermes trunk) support multi-session debugging when integrated into React Native's CDP backend. Changelog: [Internal] Reviewed By: hoxyq Differential Revision: D90888853 fbshipit-source-id: 7ea1be837bde6d71ae2bca2b1487e00c62a44928
1 parent 369a817 commit 30600f7

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

packages/react-native/ReactCommon/jsinspector-modern/tests/JsiIntegrationTest.cpp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,73 @@ TYPED_TEST(JsiIntegrationHermesTest, ResolveColumnBreakpointAfterReload) {
738738
scriptInfo->value()["params"]["scriptId"]);
739739
}
740740

741+
TYPED_TEST(JsiIntegrationHermesTest, TwoConnectionsEnableDebugger) {
742+
this->connect();
743+
auto secondary = this->connectSecondary();
744+
745+
EXPECT_CALL(
746+
this->fromPage(), onMessage(JsonEq(R"({"id": 1, "result": {}})")));
747+
EXPECT_CALL(
748+
secondary.fromPage(), onMessage(JsonEq(R"({"id": 2, "result": {}})")));
749+
750+
this->toPage_->sendMessage(R"({"id": 1, "method": "Debugger.enable"})");
751+
secondary.toPage().sendMessage(R"({"id": 2, "method": "Debugger.enable"})");
752+
}
753+
754+
TYPED_TEST(JsiIntegrationHermesTest, TwoConnectionsDebuggerLifecycle) {
755+
this->connect();
756+
auto secondary = this->connectSecondary();
757+
758+
this->expectMessageFromPage(JsonEq(R"({"id": 1, "result": {}})"));
759+
this->toPage_->sendMessage(R"({"id": 1, "method": "Debugger.enable"})");
760+
761+
// Connections: Main (Debugger enabled), Secondary (Debugger disabled)
762+
// --> Only the main connection receives Debugger events.
763+
this->expectMessageFromPage(JsonParsed(AllOf(
764+
AtJsonPtr("/method", "Debugger.scriptParsed"),
765+
AtJsonPtr("/params/url", "script1.js"))));
766+
this->eval("1 + 1; //# sourceURL=script1.js");
767+
768+
// Connections: Main (Debugger enabled), Secondary (Debugger being enabled)
769+
// --> The secondary connection receives buffered Debugger events.
770+
EXPECT_CALL(
771+
secondary.fromPage(), onMessage(JsonEq(R"({"id": 2, "result": {}})")));
772+
EXPECT_CALL(
773+
secondary.fromPage(),
774+
onMessage(JsonParsed(AllOf(
775+
AtJsonPtr("/method", "Debugger.scriptParsed"),
776+
AtJsonPtr("/params/url", "script1.js")))));
777+
secondary.toPage().sendMessage(R"({"id": 2, "method": "Debugger.enable"})");
778+
779+
// Connections: Main (Debugger enabled), Secondary (Debugger enabled)
780+
// --> Both connections receive Debugger events.
781+
this->expectMessageFromPage(JsonParsed(AllOf(
782+
AtJsonPtr("/method", "Debugger.scriptParsed"),
783+
AtJsonPtr("/params/url", "script2.js"))));
784+
EXPECT_CALL(
785+
secondary.fromPage(),
786+
onMessage(JsonParsed(AllOf(
787+
AtJsonPtr("/method", "Debugger.scriptParsed"),
788+
AtJsonPtr("/params/url", "script2.js")))));
789+
this->eval("2 + 2; //# sourceURL=script2.js");
790+
791+
this->expectMessageFromPage(JsonEq(R"({"id": 3, "result": {}})"));
792+
this->toPage_->sendMessage(R"({"id": 3, "method": "Debugger.disable"})");
793+
794+
// Connections: Main (Debugger disabled), Secondary (Debugger enabled)
795+
// --> Only the secondary connection receives Debugger events.
796+
EXPECT_CALL(
797+
secondary.fromPage(),
798+
onMessage(JsonParsed(AllOf(
799+
AtJsonPtr("/method", "Debugger.scriptParsed"),
800+
AtJsonPtr("/params/url", "script3.js")))));
801+
this->eval("3 + 3; //# sourceURL=script3.js");
802+
803+
EXPECT_CALL(
804+
secondary.fromPage(), onMessage(JsonEq(R"({"id": 4, "result": {}})")));
805+
secondary.toPage().sendMessage(R"({"id": 4, "method": "Debugger.disable"})");
806+
}
807+
741808
TYPED_TEST(JsiIntegrationHermesTest, CDPAgentReentrancyRegressionTest) {
742809
this->connect();
743810

0 commit comments

Comments
 (0)