mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
chore: make contentTracing.stopRecording() failure clearer (#38520)
chore: make contentTracing.stopRecording() failure clearer Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
@@ -77,15 +77,20 @@ void StopTracing(gin_helper::Promise<base::FilePath> promise,
|
||||
}
|
||||
},
|
||||
std::move(promise), *file_path);
|
||||
if (file_path) {
|
||||
|
||||
auto* instance = TracingController::GetInstance();
|
||||
if (!instance->IsTracing()) {
|
||||
std::move(resolve_or_reject)
|
||||
.Run(absl::make_optional(
|
||||
"Failed to stop tracing - no trace in progress"));
|
||||
} else if (file_path) {
|
||||
auto split_callback = base::SplitOnceCallback(std::move(resolve_or_reject));
|
||||
auto endpoint = TracingController::CreateFileEndpoint(
|
||||
*file_path,
|
||||
base::BindOnce(std::move(split_callback.first), absl::nullopt));
|
||||
if (!TracingController::GetInstance()->StopTracing(endpoint)) {
|
||||
if (!instance->StopTracing(endpoint)) {
|
||||
std::move(split_callback.second)
|
||||
.Run(absl::make_optional(
|
||||
"Failed to stop tracing (was a trace in progress?)"));
|
||||
.Run(absl::make_optional("Failed to stop tracing"));
|
||||
}
|
||||
} else {
|
||||
std::move(resolve_or_reject)
|
||||
|
||||
@@ -113,7 +113,7 @@ ifdescribe(!(['arm', 'arm64', 'ia32'].includes(process.arch)))('contentTracing',
|
||||
});
|
||||
|
||||
it('rejects if no trace is happening', async () => {
|
||||
await expect(contentTracing.stopRecording()).to.be.rejected();
|
||||
await expect(contentTracing.stopRecording()).to.be.rejectedWith('Failed to stop tracing - no trace in progress');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user