From 75f5905ab853875d67fb073248a6a4afe6f1806a Mon Sep 17 00:00:00 2001 From: Rob Hogan Date: Tue, 12 Mar 2024 08:32:40 -0700 Subject: [PATCH] Re-enable stale execution context test under new Hermes CDP Agent Summary: Re-enable a test now that D54649943 added correct handling of stale execution context IDs. NOTE: There's a minor difference in returned error code. The test now allows either, though note that the old implementation is more consistent with Chrome itself which returns -32000 (server error). Semantically -32600 (invalid request) seems more appropriate. Changelog: [Internal] Differential Revision: D54805777 --- .../tests/JsiIntegrationTest.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tests/JsiIntegrationTest.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tests/JsiIntegrationTest.cpp index ce89fed22456..4501770b9ac9 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tests/JsiIntegrationTest.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tests/JsiIntegrationTest.cpp @@ -494,11 +494,7 @@ TYPED_TEST(JsiIntegrationHermesTest, EvaluateExpression) { })"); } -// TODO(T181299386): Restore stale execution context validation under -// HermesRuntimeAgentDelegateNew -TYPED_TEST( - JsiIntegrationHermesLegacyTest, - EvaluateExpressionInExecutionContext) { +TYPED_TEST(JsiIntegrationHermesTest, EvaluateExpressionInExecutionContext) { this->connect(); InSequence s; @@ -546,8 +542,14 @@ TYPED_TEST( this->reload(); // Now the old execution context is stale. - this->expectMessageFromPage( - JsonParsed(AllOf(AtJsonPtr("/id", 3), AtJsonPtr("/error/code", -32000)))); + this->expectMessageFromPage(JsonParsed(AllOf( + AtJsonPtr("/id", 3), + AtJsonPtr( + "/error/code", + // HermesRuntimeAgentDelegateNew responds more correctly with -32600 + // (invalid request), old responds -32000 (server error). Accept + // either. + AnyOf(-32600, -32000))))); this->toPage_->sendMessage(sformat( R"({{ "id": 3,