diff --git a/packages/react-native/ReactCommon/jsi/jsi/test/testlib.cpp b/packages/react-native/ReactCommon/jsi/jsi/test/testlib.cpp index 1ded399f8319..37b71538b87e 100644 --- a/packages/react-native/ReactCommon/jsi/jsi/test/testlib.cpp +++ b/packages/react-native/ReactCommon/jsi/jsi/test/testlib.cpp @@ -2719,6 +2719,17 @@ TEST_P(JSITest, ArrayBufferDetachedTest) { return; } + // Skip the rest if the runtime has no way to detach an ArrayBuffer from JS. + bool canDetach = + eval( + "typeof buf.transfer === 'function' || " + "(typeof HermesInternal !== 'undefined' && " + " typeof HermesInternal.detachArrayBuffer === 'function')") + .getBool(); + if (!canDetach) { + return; + } + // Detach the ArrayBuffer. Use transfer() if available, otherwise fall back // to HermesInternal.detach for Hermes runtime. eval( diff --git a/packages/react-native/ReactCommon/jsi/jsi/test/testlib.h b/packages/react-native/ReactCommon/jsi/jsi/test/testlib.h index b56d41b83838..8eee03a34312 100644 --- a/packages/react-native/ReactCommon/jsi/jsi/test/testlib.h +++ b/packages/react-native/ReactCommon/jsi/jsi/test/testlib.h @@ -22,6 +22,7 @@ class Runtime; using RuntimeFactory = std::function()>; std::vector runtimeGenerators(); +std::vector runtimeGeneratorsWithSandBox(); class JSITestBase : public ::testing::TestWithParam { public: