From c02e83ca7ae505fc1741b3289b93c0597ddc25dd Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Tue, 20 Feb 2024 02:21:31 -0800 Subject: [PATCH] Add test for Hermes breakpoint persistence Summary: Changelog: [Internal] TSIA bypass-github-export-checks Reviewed By: huntie Differential Revision: D53919695 fbshipit-source-id: 54792111f075d9834a2b61de91251614ad5ce770 --- .../tests/JsiIntegrationTest.cpp | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tests/JsiIntegrationTest.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tests/JsiIntegrationTest.cpp index 11f4496d4470a3..3e306fe5ec3a20 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tests/JsiIntegrationTest.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tests/JsiIntegrationTest.cpp @@ -533,4 +533,44 @@ TYPED_TEST(JsiIntegrationHermesTest, EvaluateExpressionInExecutionContext) { std::to_string(executionContextId))); } +TYPED_TEST(JsiIntegrationHermesTest, ResolveBreakpointAfterReload) { + this->connect(); + + InSequence s; + + this->expectMessageFromPage(JsonParsed(AtJsonPtr("/id", 1))); + this->toPage_->sendMessage(R"({ + "id": 1, + "method": "Debugger.setBreakpointByUrl", + "params": {"lineNumber": 2, "url": "breakpointTest.js"} + })"); + + this->reload(); + + this->expectMessageFromPage(JsonEq(R"({ + "id": 2, + "result": {} + })")); + this->toPage_->sendMessage(R"({ + "id": 2, + "method": "Debugger.enable" + })"); + + auto scriptInfo = this->expectMessageFromPage(JsonParsed(AllOf( + AtJsonPtr("/method", "Debugger.scriptParsed"), + AtJsonPtr("/params/url", "breakpointTest.js")))); + auto breakpointInfo = this->expectMessageFromPage(JsonParsed(AllOf( + AtJsonPtr("/method", "Debugger.breakpointResolved"), + AtJsonPtr("/params/location/lineNumber", 2)))); + this->eval(R"( // line 0 + globalThis.foo = function() { // line 1 + Date.now(); // line 2 + }; + //# sourceURL=breakpointTest.js + )"); + EXPECT_EQ( + breakpointInfo->value()["params"]["location"]["scriptId"], + scriptInfo->value()["params"]["scriptId"]); +} + } // namespace facebook::react::jsinspector_modern