Skip to content

Commit 4fea0b8

Browse files
motiz88meta-codesync[bot]
authored andcommitted
Improve breakpoint integration test coverage for Static Hermes (#55369)
Summary: Pull Request resolved: #55369 The jsinspector-modern test cases to do with breakpoint behaviour are completely disabled for Static Hermes (Hermes V1) because of a bug that still exists on the release branch; let's narrow down the gating of the tests and add other ones that pass on both Legacy Hermes and Static Hermes (including the stable and trunk branches). Changelog: [Internal] Reviewed By: hoxyq Differential Revision: D90888851 fbshipit-source-id: 60660aa5b1f1429393cf970b10125496ca005e3a
1 parent 81ee556 commit 4fea0b8

1 file changed

Lines changed: 91 additions & 6 deletions

File tree

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

Lines changed: 91 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,12 @@ TYPED_TEST(JsiIntegrationHermesTest, EvaluateExpressionInExecutionContext) {
567567
std::to_string(executionContextId)));
568568
}
569569

570-
#if !defined(HERMES_STATIC_HERMES)
571-
// FIXME(T239924718): Breakpoint resolution in Static Hermes is broken for
572-
// locations without column numbers under lazy compilation.
570+
#if !defined(HERMES_STATIC_HERMES_STABLE)
571+
// TODO: Unconditionally enable test for line-only (columnless) breakpoints
572+
// after D83595036 (fix for T239924718) ships to the stable branch of Static
573+
// Hermes.
573574

574-
TYPED_TEST(JsiIntegrationHermesTest, ResolveBreakpointAfterEval) {
575+
TYPED_TEST(JsiIntegrationHermesTest, ResolveColumnlessBreakpointAfterEval) {
575576
this->connect();
576577

577578
InSequence s;
@@ -609,7 +610,7 @@ TYPED_TEST(JsiIntegrationHermesTest, ResolveBreakpointAfterEval) {
609610
})");
610611
}
611612

612-
TYPED_TEST(JsiIntegrationHermesTest, ResolveBreakpointAfterReload) {
613+
TYPED_TEST(JsiIntegrationHermesTest, ResolveColumnlessBreakpointAfterReload) {
613614
this->connect();
614615

615616
InSequence s;
@@ -651,7 +652,91 @@ TYPED_TEST(JsiIntegrationHermesTest, ResolveBreakpointAfterReload) {
651652
scriptInfo->value()["params"]["scriptId"]);
652653
}
653654

654-
#endif // !defined(HERMES_STATIC_HERMES)
655+
#endif // !defined(HERMES_STATIC_HERMES_STABLE)
656+
657+
TYPED_TEST(JsiIntegrationHermesTest, ResolveColumnBreakpointAfterEval) {
658+
this->connect();
659+
660+
InSequence s;
661+
662+
this->expectMessageFromPage(JsonEq(R"({
663+
"id": 1,
664+
"result": {}
665+
})"));
666+
this->toPage_->sendMessage(R"({
667+
"id": 1,
668+
"method": "Debugger.enable"
669+
})");
670+
671+
auto scriptInfo = this->expectMessageFromPage(JsonParsed(AllOf(
672+
AtJsonPtr("/method", "Debugger.scriptParsed"),
673+
AtJsonPtr("/params/url", "breakpointTest.js"))));
674+
this->eval(R"( // line 0
675+
globalThis.foo = function() { // line 1
676+
Date.now(); // line 2
677+
};
678+
//# sourceURL=breakpointTest.js
679+
)");
680+
ASSERT_TRUE(scriptInfo->has_value());
681+
682+
this->expectMessageFromPage(JsonParsed(AllOf(
683+
AtJsonPtr("/id", 2),
684+
AtJsonPtr("/result/locations/0/lineNumber", 2),
685+
AtJsonPtr("/result/locations/0/columnNumber", 6),
686+
AtJsonPtr(
687+
"/result/locations/0/scriptId",
688+
scriptInfo->value()["params"]["scriptId"]))));
689+
this->toPage_->sendMessage(R"({
690+
"id": 2,
691+
"method": "Debugger.setBreakpointByUrl",
692+
"params": {"lineNumber": 2,
693+
"columnNumber": 6,
694+
"url": "breakpointTest.js"}
695+
})");
696+
}
697+
698+
TYPED_TEST(JsiIntegrationHermesTest, ResolveColumnBreakpointAfterReload) {
699+
this->connect();
700+
701+
InSequence s;
702+
703+
this->expectMessageFromPage(JsonEq(R"({
704+
"id": 1,
705+
"result": {}
706+
})"));
707+
this->toPage_->sendMessage(R"({
708+
"id": 1,
709+
"method": "Debugger.enable"
710+
})");
711+
712+
this->expectMessageFromPage(JsonParsed(AtJsonPtr("/id", 2)));
713+
this->toPage_->sendMessage(R"({
714+
"id": 2,
715+
"method": "Debugger.setBreakpointByUrl",
716+
"params": {"lineNumber": 2, "columnNumber": 6, "url": "breakpointTest.js"}
717+
})");
718+
719+
this->reload();
720+
721+
auto scriptInfo = this->expectMessageFromPage(JsonParsed(AllOf(
722+
AtJsonPtr("/method", "Debugger.scriptParsed"),
723+
AtJsonPtr("/params/url", "breakpointTest.js"))));
724+
auto breakpointInfo = this->expectMessageFromPage(JsonParsed(AllOf(
725+
AtJsonPtr("/method", "Debugger.breakpointResolved"),
726+
AtJsonPtr("/params/location/lineNumber", 2),
727+
AtJsonPtr("/params/location/columnNumber", 6))));
728+
this->eval(R"( // line 0
729+
globalThis.foo = function() { // line 1
730+
Date.now(); // line 2
731+
};
732+
//# sourceURL=breakpointTest.js
733+
)");
734+
ASSERT_TRUE(breakpointInfo->has_value());
735+
ASSERT_TRUE(scriptInfo->has_value());
736+
EXPECT_EQ(
737+
breakpointInfo->value()["params"]["location"]["scriptId"],
738+
scriptInfo->value()["params"]["scriptId"]);
739+
}
655740

656741
TYPED_TEST(JsiIntegrationHermesTest, CDPAgentReentrancyRegressionTest) {
657742
this->connect();

0 commit comments

Comments
 (0)