react-native 0.83.3 → 0.83.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Utilities/Appearance.js +6 -1
- package/React/Base/RCTVersion.m +1 -1
- package/React/DevSupport/RCTFrameTimingsObserver.h +24 -0
- package/React/DevSupport/RCTFrameTimingsObserver.mm +298 -0
- package/React/FBReactNativeSpec/FBReactNativeSpecJSI.h +16 -0
- package/ReactAndroid/api/ReactAndroid.api +0 -9
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgelessDevSupportManager.kt +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.kt +7 -7
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorFlags.kt +4 -0
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/FrameTimingSequence.kt +16 -0
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/FrameTimingsObserver.kt +275 -0
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/TracingState.kt +17 -0
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/TracingStateListener.kt +15 -0
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/{interfaces → inspector}/TracingStateProvider.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/perfmonitor/PerfMonitorInspectorTargetBinding.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/perfmonitor/PerfMonitorOverlayManager.kt +4 -4
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/perfmonitor/PerfMonitorOverlayView.kt +3 -3
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/perfmonitor/PerfMonitorUpdateListener.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt +13 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt +21 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt +5 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +5 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt +23 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt +5 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/tracing/PerformanceTracer.kt +39 -0
- package/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkEventUtil.kt +20 -19
- package/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.kt +6 -12
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt +86 -4
- package/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImplDevHelper.kt +3 -3
- package/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostInspectorTarget.kt +10 -6
- package/ReactAndroid/src/main/jni/react/devsupport/JInspectorFlags.cpp +22 -0
- package/ReactAndroid/src/main/jni/react/devsupport/JInspectorFlags.h +2 -0
- package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp +29 -1
- package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h +7 -1
- package/ReactAndroid/src/main/jni/react/runtime/jni/JReactHostInspectorTarget.cpp +196 -17
- package/ReactAndroid/src/main/jni/react/runtime/jni/JReactHostInspectorTarget.h +168 -18
- package/ReactAndroid/src/main/jni/third-party/folly/CMakeLists.txt +1 -0
- package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
- package/ReactCommon/jsinspector-modern/HostAgent.cpp +45 -10
- package/ReactCommon/jsinspector-modern/HostAgent.h +2 -2
- package/ReactCommon/jsinspector-modern/HostTarget.cpp +14 -7
- package/ReactCommon/jsinspector-modern/HostTarget.h +101 -14
- package/ReactCommon/jsinspector-modern/HostTargetTraceRecording.cpp +39 -8
- package/ReactCommon/jsinspector-modern/HostTargetTraceRecording.h +42 -5
- package/ReactCommon/jsinspector-modern/HostTargetTracing.cpp +54 -21
- package/ReactCommon/jsinspector-modern/HostTargetTracing.h +89 -0
- package/ReactCommon/jsinspector-modern/InspectorFlags.cpp +12 -0
- package/ReactCommon/jsinspector-modern/InspectorFlags.h +12 -0
- package/ReactCommon/jsinspector-modern/InspectorInterfaces.cpp +3 -7
- package/ReactCommon/jsinspector-modern/InstanceAgent.cpp +2 -11
- package/ReactCommon/jsinspector-modern/NetworkIOAgent.cpp +1 -1
- package/ReactCommon/jsinspector-modern/TracingAgent.cpp +29 -13
- package/ReactCommon/jsinspector-modern/TracingAgent.h +5 -4
- package/ReactCommon/jsinspector-modern/tests/HostTargetTest.cpp +65 -0
- package/ReactCommon/jsinspector-modern/tests/InspectorMocks.h +23 -2
- package/ReactCommon/jsinspector-modern/tests/JsiIntegrationTest.cpp +1 -0
- package/ReactCommon/jsinspector-modern/tests/NetworkReporterTest.cpp +1 -0
- package/ReactCommon/jsinspector-modern/tests/TracingTest.cpp +335 -0
- package/ReactCommon/jsinspector-modern/tests/TracingTest.h +95 -0
- package/ReactCommon/jsinspector-modern/tests/utils/InspectorFlagOverridesGuard.cpp +10 -0
- package/ReactCommon/jsinspector-modern/tests/utils/InspectorFlagOverridesGuard.h +3 -1
- package/ReactCommon/jsinspector-modern/tracing/CMakeLists.txt +1 -0
- package/ReactCommon/jsinspector-modern/tracing/FrameTimingSequence.h +61 -0
- package/ReactCommon/jsinspector-modern/tracing/HostTracingProfile.h +43 -0
- package/ReactCommon/jsinspector-modern/tracing/HostTracingProfileSerializer.cpp +165 -0
- package/ReactCommon/jsinspector-modern/tracing/HostTracingProfileSerializer.h +50 -0
- package/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp +16 -14
- package/ReactCommon/jsinspector-modern/tracing/PerformanceTracerSection.h +113 -0
- package/ReactCommon/jsinspector-modern/tracing/React-jsinspectortracing.podspec +1 -0
- package/ReactCommon/jsinspector-modern/tracing/TimeWindowedBuffer.h +158 -0
- package/ReactCommon/jsinspector-modern/tracing/TraceEvent.h +2 -1
- package/ReactCommon/jsinspector-modern/tracing/TraceEventGenerator.cpp +100 -0
- package/ReactCommon/jsinspector-modern/tracing/TraceEventGenerator.h +60 -0
- package/ReactCommon/jsinspector-modern/tracing/TraceEventSerializer.cpp +44 -1
- package/ReactCommon/jsinspector-modern/tracing/TraceEventSerializer.h +7 -0
- package/ReactCommon/jsinspector-modern/tracing/TraceRecordingState.h +18 -7
- package/ReactCommon/jsinspector-modern/tracing/TracingCategory.h +136 -0
- package/ReactCommon/jsinspector-modern/tracing/tests/TimeWindowedBufferTest.cpp +352 -0
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +9 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +11 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +65 -29
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +6 -2
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +9 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h +19 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +3 -1
- package/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm +3 -1
- package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +11 -1
- package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +5 -1
- package/ReactCommon/react/performance/timeline/PerformanceObserver.cpp +18 -6
- package/ReactCommon/react/performance/timeline/PerformanceObserver.h +2 -0
- package/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm +115 -0
- package/ReactCommon/{jsinspector-modern → react/utils}/Base64.h +2 -2
- package/gradle/libs.versions.toml +1 -1
- package/package.json +8 -8
- package/scripts/cocoapods/utils.rb +1 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +11 -1
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +3 -1
- package/third-party-podspecs/RCT-Folly.podspec +1 -1
- package/third-party-podspecs/fmt.podspec +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/TracingState.kt +0 -19
- package/ReactCommon/jsinspector-modern/tracing/TraceRecordingStateSerializer.cpp +0 -68
- package/ReactCommon/jsinspector-modern/tracing/TraceRecordingStateSerializer.h +0 -42
- package/ReactCommon/jsinspector-modern/tracing/TracingState.h +0 -24
|
@@ -21,6 +21,14 @@ bool InspectorFlags::getAssertSingleHostState() const {
|
|
|
21
21
|
return loadFlagsAndAssertUnchanged().assertSingleHostState;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
bool InspectorFlags::getScreenshotCaptureEnabled() const {
|
|
25
|
+
return loadFlagsAndAssertUnchanged().screenshotCaptureEnabled;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
bool InspectorFlags::getFrameRecordingEnabled() const {
|
|
29
|
+
return loadFlagsAndAssertUnchanged().frameRecordingEnabled;
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
bool InspectorFlags::getFuseboxEnabled() const {
|
|
25
33
|
if (fuseboxDisabledForTest_) {
|
|
26
34
|
return false;
|
|
@@ -54,6 +62,10 @@ const InspectorFlags::Values& InspectorFlags::loadFlagsAndAssertUnchanged()
|
|
|
54
62
|
InspectorFlags::Values newValues = {
|
|
55
63
|
.assertSingleHostState =
|
|
56
64
|
ReactNativeFeatureFlags::fuseboxAssertSingleHostState(),
|
|
65
|
+
.screenshotCaptureEnabled =
|
|
66
|
+
ReactNativeFeatureFlags::fuseboxScreenshotCaptureEnabled(),
|
|
67
|
+
.frameRecordingEnabled =
|
|
68
|
+
ReactNativeFeatureFlags::fuseboxFrameRecordingEnabled(),
|
|
57
69
|
.fuseboxEnabled =
|
|
58
70
|
#if defined(REACT_NATIVE_DEBUGGER_ENABLED)
|
|
59
71
|
true,
|
|
@@ -36,6 +36,16 @@ class InspectorFlags {
|
|
|
36
36
|
*/
|
|
37
37
|
bool getIsProfilingBuild() const;
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Flag determining if Page.captureScreenshot CDP method is enabled.
|
|
41
|
+
*/
|
|
42
|
+
bool getScreenshotCaptureEnabled() const;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Flag determining if frame recording (timings + screenshots) is enabled.
|
|
46
|
+
*/
|
|
47
|
+
bool getFrameRecordingEnabled() const;
|
|
48
|
+
|
|
39
49
|
/**
|
|
40
50
|
* Flag determining if network inspection is enabled.
|
|
41
51
|
*/
|
|
@@ -61,6 +71,8 @@ class InspectorFlags {
|
|
|
61
71
|
private:
|
|
62
72
|
struct Values {
|
|
63
73
|
bool assertSingleHostState;
|
|
74
|
+
bool screenshotCaptureEnabled;
|
|
75
|
+
bool frameRecordingEnabled;
|
|
64
76
|
bool fuseboxEnabled;
|
|
65
77
|
bool isProfilingBuild;
|
|
66
78
|
bool networkInspectionEnabled;
|
|
@@ -143,13 +143,9 @@ int InspectorImpl::addPage(
|
|
|
143
143
|
pageId,
|
|
144
144
|
Page{pageId, description, vm, std::move(connectFunc), capabilities});
|
|
145
145
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
for (const auto& listenerWeak : listeners_) {
|
|
150
|
-
if (auto listener = listenerWeak.lock()) {
|
|
151
|
-
listener->unstable_onHostTargetAdded();
|
|
152
|
-
}
|
|
146
|
+
for (const auto& listenerWeak : listeners_) {
|
|
147
|
+
if (auto listener = listenerWeak.lock()) {
|
|
148
|
+
listener->unstable_onHostTargetAdded();
|
|
153
149
|
}
|
|
154
150
|
}
|
|
155
151
|
|
|
@@ -15,15 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|
namespace facebook::react::jsinspector_modern {
|
|
17
17
|
|
|
18
|
-
namespace {
|
|
19
|
-
|
|
20
|
-
// The size of the timeline for the trace recording that happened in the
|
|
21
|
-
// background.
|
|
22
|
-
constexpr HighResDuration kBackgroundTracePerformanceTracerWindowSize =
|
|
23
|
-
HighResDuration::fromMilliseconds(20000);
|
|
24
|
-
|
|
25
|
-
} // namespace
|
|
26
|
-
|
|
27
18
|
InstanceAgent::InstanceAgent(
|
|
28
19
|
FrontendChannel frontendChannel,
|
|
29
20
|
InstanceTarget& target,
|
|
@@ -171,8 +162,8 @@ void InstanceAgent::maybeSendPendingConsoleMessages() {
|
|
|
171
162
|
InstanceTracingAgent::InstanceTracingAgent(tracing::TraceRecordingState& state)
|
|
172
163
|
: tracing::TargetTracingAgent(state) {
|
|
173
164
|
auto& performanceTracer = tracing::PerformanceTracer::getInstance();
|
|
174
|
-
if (state.
|
|
175
|
-
performanceTracer.startTracing(
|
|
165
|
+
if (state.windowSize) {
|
|
166
|
+
performanceTracer.startTracing(*state.windowSize);
|
|
176
167
|
} else {
|
|
177
168
|
performanceTracer.startTracing();
|
|
178
169
|
}
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
#include "TracingAgent.h"
|
|
9
9
|
|
|
10
|
+
#include <jsinspector-modern/tracing/HostTracingProfileSerializer.h>
|
|
10
11
|
#include <jsinspector-modern/tracing/PerformanceTracer.h>
|
|
11
12
|
#include <jsinspector-modern/tracing/RuntimeSamplingProfileTraceEventSerializer.h>
|
|
12
13
|
#include <jsinspector-modern/tracing/TraceEventSerializer.h>
|
|
13
|
-
#include <jsinspector-modern/tracing/TraceRecordingStateSerializer.h>
|
|
14
14
|
#include <jsinspector-modern/tracing/TracingMode.h>
|
|
15
15
|
|
|
16
16
|
namespace facebook::react::jsinspector_modern {
|
|
@@ -74,8 +74,25 @@ bool TracingAgent::handleRequest(const cdp::PreparsedRequest& req) {
|
|
|
74
74
|
return true;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
/**
|
|
78
|
+
* This logic has to be updated with the next upgrade of Chrome
|
|
79
|
+
* DevTools Frotnend fork.
|
|
80
|
+
*
|
|
81
|
+
* At the moment of writing this, our fork uses categories field, which is
|
|
82
|
+
* marked as depreacted in CDP spec.
|
|
83
|
+
*
|
|
84
|
+
* Latest versions of Chrome DevTools in stable channel of Chromium are
|
|
85
|
+
* already using traceConfig field.
|
|
86
|
+
*/
|
|
87
|
+
std::set<tracing::Category> enabledCategories;
|
|
88
|
+
if (req.params.isObject() && req.params.count("categories") != 0 &&
|
|
89
|
+
req.params["categories"].isString()) {
|
|
90
|
+
enabledCategories = tracing::parseSerializedTracingCategories(
|
|
91
|
+
req.params["categories"].getString());
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
bool didNotHaveAlreadyRunningRecording = hostTargetController_.startTracing(
|
|
95
|
+
tracing::Mode::CDP, std::move(enabledCategories));
|
|
79
96
|
if (!didNotHaveAlreadyRunningRecording) {
|
|
80
97
|
frontendChannel_(
|
|
81
98
|
cdp::jsonError(
|
|
@@ -91,37 +108,36 @@ bool TracingAgent::handleRequest(const cdp::PreparsedRequest& req) {
|
|
|
91
108
|
|
|
92
109
|
return true;
|
|
93
110
|
} else if (req.method == "Tracing.end") {
|
|
94
|
-
|
|
95
|
-
auto state = hostTargetController_.stopTracing();
|
|
111
|
+
auto tracingProfile = hostTargetController_.stopTracing();
|
|
96
112
|
|
|
97
113
|
sessionState_.hasPendingTraceRecording = false;
|
|
98
114
|
// Send response to Tracing.end request.
|
|
99
115
|
frontendChannel_(cdp::jsonResult(req.id));
|
|
100
116
|
|
|
101
|
-
|
|
117
|
+
emitHostTracingProfile(std::move(tracingProfile));
|
|
102
118
|
return true;
|
|
103
119
|
}
|
|
104
120
|
|
|
105
121
|
return false;
|
|
106
122
|
}
|
|
107
123
|
|
|
108
|
-
void TracingAgent::
|
|
109
|
-
tracing::
|
|
124
|
+
void TracingAgent::emitExternalHostTracingProfile(
|
|
125
|
+
tracing::HostTracingProfile tracingProfile) const {
|
|
110
126
|
frontendChannel_(
|
|
111
127
|
cdp::jsonNotification("ReactNativeApplication.traceRequested"));
|
|
112
|
-
|
|
128
|
+
emitHostTracingProfile(std::move(tracingProfile));
|
|
113
129
|
}
|
|
114
130
|
|
|
115
|
-
void TracingAgent::
|
|
116
|
-
tracing::
|
|
131
|
+
void TracingAgent::emitHostTracingProfile(
|
|
132
|
+
tracing::HostTracingProfile tracingProfile) const {
|
|
117
133
|
auto dataCollectedCallback = [this](folly::dynamic&& eventsChunk) {
|
|
118
134
|
frontendChannel_(
|
|
119
135
|
cdp::jsonNotification(
|
|
120
136
|
"Tracing.dataCollected",
|
|
121
137
|
folly::dynamic::object("value", std::move(eventsChunk))));
|
|
122
138
|
};
|
|
123
|
-
tracing::
|
|
124
|
-
std::move(
|
|
139
|
+
tracing::HostTracingProfileSerializer::emitAsDataCollectedChunks(
|
|
140
|
+
std::move(tracingProfile),
|
|
125
141
|
dataCollectedCallback,
|
|
126
142
|
TRACE_EVENT_CHUNK_SIZE,
|
|
127
143
|
PROFILE_TRACE_EVENT_CHUNK_SIZE);
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
#include "InspectorInterfaces.h"
|
|
12
12
|
|
|
13
13
|
#include <jsinspector-modern/cdp/CdpJson.h>
|
|
14
|
+
#include <jsinspector-modern/tracing/HostTracingProfile.h>
|
|
14
15
|
#include <jsinspector-modern/tracing/Timing.h>
|
|
15
16
|
#include <react/timing/primitives.h>
|
|
16
17
|
|
|
@@ -41,9 +42,9 @@ class TracingAgent {
|
|
|
41
42
|
bool handleRequest(const cdp::PreparsedRequest &req);
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
|
-
* Emits the
|
|
45
|
+
* Emits the HostTracingProfile that was stashed externally by the HostTarget.
|
|
45
46
|
*/
|
|
46
|
-
void
|
|
47
|
+
void emitExternalHostTracingProfile(tracing::HostTracingProfile tracingProfile) const;
|
|
47
48
|
|
|
48
49
|
private:
|
|
49
50
|
/**
|
|
@@ -56,10 +57,10 @@ class TracingAgent {
|
|
|
56
57
|
HostTargetController &hostTargetController_;
|
|
57
58
|
|
|
58
59
|
/**
|
|
59
|
-
* Emits
|
|
60
|
+
* Emits captured HostTracingProfile in a series of
|
|
60
61
|
* Tracing.dataCollected events, followed by a Tracing.tracingComplete event.
|
|
61
62
|
*/
|
|
62
|
-
void
|
|
63
|
+
void emitHostTracingProfile(tracing::HostTracingProfile tracingProfile) const;
|
|
63
64
|
};
|
|
64
65
|
|
|
65
66
|
} // namespace facebook::react::jsinspector_modern
|
|
@@ -1526,4 +1526,69 @@ TEST_F(HostTargetTest, IOReadSizeValidation) {
|
|
|
1526
1526
|
})");
|
|
1527
1527
|
}
|
|
1528
1528
|
|
|
1529
|
+
TEST_F(HostTargetTest, TracingDelegateIsNotifiedOnCDPRequest) {
|
|
1530
|
+
connect();
|
|
1531
|
+
InSequence s;
|
|
1532
|
+
|
|
1533
|
+
EXPECT_CALL(
|
|
1534
|
+
hostTargetDelegate_.getTracingDelegateMock(),
|
|
1535
|
+
onTracingStarted(Eq(tracing::Mode::CDP), Eq(false)))
|
|
1536
|
+
.Times(1)
|
|
1537
|
+
.RetiresOnSaturation();
|
|
1538
|
+
EXPECT_CALL(fromPage(), onMessage(JsonEq(R"({
|
|
1539
|
+
"id": 1,
|
|
1540
|
+
"result": {}
|
|
1541
|
+
})")));
|
|
1542
|
+
toPage_->sendMessage(R"({
|
|
1543
|
+
"id": 1,
|
|
1544
|
+
"method": "Tracing.start"
|
|
1545
|
+
})");
|
|
1546
|
+
|
|
1547
|
+
EXPECT_CALL(hostTargetDelegate_.getTracingDelegateMock(), onTracingStopped())
|
|
1548
|
+
.Times(1)
|
|
1549
|
+
.RetiresOnSaturation();
|
|
1550
|
+
EXPECT_CALL(fromPage(), onMessage(JsonEq(R"({
|
|
1551
|
+
"id": 1,
|
|
1552
|
+
"result": {}
|
|
1553
|
+
})")));
|
|
1554
|
+
EXPECT_CALL(
|
|
1555
|
+
fromPage(),
|
|
1556
|
+
onMessage(JsonParsed(
|
|
1557
|
+
testing::AllOf(
|
|
1558
|
+
AtJsonPtr("/method", "Tracing.tracingComplete"),
|
|
1559
|
+
AtJsonPtr("/params/dataLossOccurred", false)))));
|
|
1560
|
+
toPage_->sendMessage(R"({
|
|
1561
|
+
"id": 1,
|
|
1562
|
+
"method": "Tracing.end"
|
|
1563
|
+
})");
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
TEST_F(HostTargetTest, TracingDelegateIsNotifiedOnDirectTracingCall) {
|
|
1567
|
+
connect();
|
|
1568
|
+
|
|
1569
|
+
EXPECT_CALL(
|
|
1570
|
+
hostTargetDelegate_.getTracingDelegateMock(),
|
|
1571
|
+
onTracingStarted(Eq(tracing::Mode::Background), Eq(false)))
|
|
1572
|
+
.Times(1)
|
|
1573
|
+
.RetiresOnSaturation();
|
|
1574
|
+
page_->startTracing(tracing::Mode::Background, {});
|
|
1575
|
+
|
|
1576
|
+
EXPECT_CALL(hostTargetDelegate_.getTracingDelegateMock(), onTracingStopped())
|
|
1577
|
+
.Times(1)
|
|
1578
|
+
.RetiresOnSaturation();
|
|
1579
|
+
page_->stopTracing();
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
TEST_F(HostTargetProtocolTest, CaptureScreenshotNotSupportedWhenFlagDisabled) {
|
|
1583
|
+
EXPECT_CALL(
|
|
1584
|
+
fromPage(),
|
|
1585
|
+
onMessage(JsonParsed(AllOf(
|
|
1586
|
+
AtJsonPtr("/error/code", Eq(-32601)), AtJsonPtr("/id", Eq(1))))))
|
|
1587
|
+
.RetiresOnSaturation();
|
|
1588
|
+
toPage_->sendMessage(R"({
|
|
1589
|
+
"id": 1,
|
|
1590
|
+
"method": "Page.captureScreenshot"
|
|
1591
|
+
})");
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1529
1594
|
} // namespace facebook::react::jsinspector_modern
|
|
@@ -87,13 +87,13 @@ class MockInspectorPackagerConnectionDelegate : public InspectorPackagerConnecti
|
|
|
87
87
|
explicit MockInspectorPackagerConnectionDelegate(folly::Executor &executor) : executor_(executor)
|
|
88
88
|
{
|
|
89
89
|
using namespace testing;
|
|
90
|
-
ON_CALL(*this, scheduleCallback(_, _)).WillByDefault(
|
|
90
|
+
ON_CALL(*this, scheduleCallback(_, _)).WillByDefault([this](auto callback, auto delay) {
|
|
91
91
|
if (auto scheduledExecutor = dynamic_cast<folly::ScheduledExecutor *>(&executor_)) {
|
|
92
92
|
scheduledExecutor->scheduleAt(callback, scheduledExecutor->now() + delay);
|
|
93
93
|
} else {
|
|
94
94
|
executor_.add(callback);
|
|
95
95
|
}
|
|
96
|
-
})
|
|
96
|
+
});
|
|
97
97
|
EXPECT_CALL(*this, scheduleCallback(_, _)).Times(AnyNumber());
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -113,6 +113,12 @@ class MockInspectorPackagerConnectionDelegate : public InspectorPackagerConnecti
|
|
|
113
113
|
folly::Executor &executor_;
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
+
class MockHostTargetTracingDelegate : public HostTargetTracingDelegate {
|
|
117
|
+
public:
|
|
118
|
+
MOCK_METHOD(void, onTracingStarted, (tracing::Mode tracingMode, bool screenshotsCategoryEnabled), (override));
|
|
119
|
+
MOCK_METHOD(void, onTracingStopped, (), (override));
|
|
120
|
+
};
|
|
121
|
+
|
|
116
122
|
class MockHostTargetDelegate : public HostTargetDelegate {
|
|
117
123
|
public:
|
|
118
124
|
// HostTargetDelegate methods
|
|
@@ -131,6 +137,21 @@ class MockHostTargetDelegate : public HostTargetDelegate {
|
|
|
131
137
|
loadNetworkResource,
|
|
132
138
|
(const LoadNetworkResourceRequest ¶ms, ScopedExecutor<NetworkRequestListener> executor),
|
|
133
139
|
(override));
|
|
140
|
+
MOCK_METHOD(std::optional<std::string>, captureScreenshot, (const PageCaptureScreenshotRequest &request), (override));
|
|
141
|
+
|
|
142
|
+
HostTargetTracingDelegate *getTracingDelegate() override
|
|
143
|
+
{
|
|
144
|
+
return mockTracingDelegate_.get();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
MockHostTargetTracingDelegate &getTracingDelegateMock()
|
|
148
|
+
{
|
|
149
|
+
return *mockTracingDelegate_;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private:
|
|
153
|
+
std::unique_ptr<MockHostTargetTracingDelegate> mockTracingDelegate_ =
|
|
154
|
+
std::make_unique<MockHostTargetTracingDelegate>();
|
|
134
155
|
};
|
|
135
156
|
|
|
136
157
|
class MockInstanceTargetDelegate : public InstanceTargetDelegate {};
|
|
@@ -358,6 +358,7 @@ TYPED_TEST(JsiIntegrationPortableTest, ReactNativeApplicationEnable) {
|
|
|
358
358
|
"method": "ReactNativeApplication.metadataUpdated",
|
|
359
359
|
"params": {
|
|
360
360
|
"integrationName": "JsiIntegrationTest",
|
|
361
|
+
"unstable_frameRecordingEnabled": false,
|
|
361
362
|
"unstable_isProfilingBuild": false,
|
|
362
363
|
"unstable_networkInspectionEnabled": false
|
|
363
364
|
}
|